Skip to content

Commit

Permalink
SONAR-22422 Create missing C/C++ tutorials for GitLab
Browse files Browse the repository at this point in the history
Co-authored-by: Benjamin Raymond <31401273+7PH@users.noreply.github.com>
  • Loading branch information
2 people authored and sonartech committed Jun 20, 2024
1 parent 9309dac commit 255d54f
Show file tree
Hide file tree
Showing 12 changed files with 978 additions and 216 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,16 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { Link } from '@sonarsource/echoes-react';
import { Dictionary } from 'lodash';
import * as React from 'react';
import { FormattedMessage } from 'react-intl';
import withAvailableFeatures, {
WithAvailableFeaturesProps,
} from '../../../app/components/available-features/withAvailableFeatures';
import { DocLink } from '../../../helpers/doc-links';
import { useDocUrl } from '../../../helpers/docs';
import { translate } from '../../../helpers/l10n';
import { Feature } from '../../../types/features';
import { Component } from '../../../types/types';
import { CompilationInfo } from '../components/CompilationInfo';
import CreateYmlFile from '../components/CreateYmlFile';
import { JreRequiredWarning } from '../components/JreRequiredWarning';
import { Arch, AutoConfig, BuildTools, TutorialConfig } from '../types';
import { isCFamily } from '../utils';
import { PreambuleYaml } from './PreambuleYaml';
Expand Down Expand Up @@ -78,7 +74,6 @@ const showJreWarning = (config: TutorialConfig, arch: Arch) => {
export function AnalysisCommand(props: Readonly<AnalysisCommandProps>) {
const { config, arch, mainBranchName, component } = props;
const branchesEnabled = props.hasFeature(Feature.BranchSupport);
const scannerRequirementsUrl = useDocUrl(DocLink.SonarScannerRequirements);

if (!config.buildTool) {
return null;
Expand All @@ -93,29 +88,13 @@ export function AnalysisCommand(props: Readonly<AnalysisCommandProps>) {
projectName: component.name,
});

const warning = showJreWarning(config, arch) && (
<p className="sw-mb-2">
<FormattedMessage
defaultMessage={translate('onboarding.analysis.sq_scanner.jre_required_warning')}
id="onboarding.analysis.sq_scanner.jre_required_warning"
values={{
link: (
<Link to={scannerRequirementsUrl}>
{translate('onboarding.analysis.sq_scanner.jre_required_warning.link')}
</Link>
),
}}
/>
</p>
);

return (
<>
<PreambuleYaml buildTool={config.buildTool} component={component} />
<CreateYmlFile
yamlFileName="bitbucket-pipelines.yml"
yamlTemplate={yamlTemplate}
warning={warning}
warning={showJreWarning(config, arch) && <JreRequiredWarning />}
/>
{isCFamily(config.buildTool) && <CompilationInfo />}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ definitions:
- step: &build-step
name: Build the project, and run the SonarQube analysis
script:
- export SONAR_SCANNER_VERSION=5.0.1.3006
- export SONAR_SCANNER_VERSION=6.0.0.4432
- mkdir $HOME/.sonar
- curl -sSLo $HOME/.sonar/build-wrapper-linux-aarch64.zip \${SONAR_HOST_URL}/static/cpp/build-wrapper-linux-aarch64.zip
- unzip -o $HOME/.sonar/build-wrapper-linux-aarch64.zip -d $HOME/.sonar/
Expand Down Expand Up @@ -139,7 +139,7 @@ definitions:
- step: &build-step
name: Build the project, and run the SonarQube analysis
script:
- export SONAR_SCANNER_VERSION=5.0.1.3006
- export SONAR_SCANNER_VERSION=6.0.0.4432
- mkdir $HOME/.sonar
- curl -sSLo $HOME/.sonar/build-wrapper-linux-aarch64.zip \${SONAR_HOST_URL}/static/cpp/build-wrapper-linux-aarch64.zip
- unzip -o $HOME/.sonar/build-wrapper-linux-aarch64.zip -d $HOME/.sonar/
Expand Down Expand Up @@ -173,7 +173,7 @@ definitions:
- step: &build-step
name: Build the project, and run the SonarQube analysis
script:
- export SONAR_SCANNER_VERSION=5.0.1.3006
- export SONAR_SCANNER_VERSION=6.0.0.4432
- mkdir $HOME/.sonar
- curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip \${SONAR_HOST_URL}/static/cpp/build-wrapper-linux-x86.zip
- unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
Expand Down Expand Up @@ -211,7 +211,7 @@ definitions:
- step: &build-step
name: Build the project, and run the SonarQube analysis
script:
- export SONAR_SCANNER_VERSION=5.0.1.3006
- export SONAR_SCANNER_VERSION=6.0.0.4432
- mkdir $HOME/.sonar
- curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip \${SONAR_HOST_URL}/static/cpp/build-wrapper-linux-x86.zip
- unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
import { AutoConfig, BuildTools, OSs } from '../../types';
import {
SONAR_SCANNER_CLI_LATEST_VERSION,
getBuildWrapperExecutableLinux,
getBuildWrapperFolderLinux,
getScannerUrlSuffix,
Expand All @@ -45,7 +46,7 @@ definitions:
- step: &build-step
name: Build the project, and run the SonarQube analysis
script:
- export SONAR_SCANNER_VERSION=5.0.1.3006
- export SONAR_SCANNER_VERSION=${SONAR_SCANNER_CLI_LATEST_VERSION}
- mkdir $HOME/.sonar
- curl -sSLo $HOME/.sonar/${buildWrapperFolder}.zip \${SONAR_HOST_URL}/static/cpp/${buildWrapperFolder}.zip
- unzip -o $HOME/.sonar/${buildWrapperFolder}.zip -d $HOME/.sonar/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { ClipboardIconButton, CodeSnippet, FlagMessage, NumberedListItem } from 'design-system';
import { ClipboardIconButton, CodeSnippet, NumberedListItem } from 'design-system';
import * as React from 'react';
import { FormattedMessage } from 'react-intl';
import { translate } from '../../../helpers/l10n';
Expand Down Expand Up @@ -45,13 +45,7 @@ export default function CreateYmlFile(props: Readonly<CreateYmlFileProps>) {
),
}}
/>
{warning && (
<div>
<FlagMessage className="sw-mt-2 sw-w-abs-600" variant="warning">
{warning}
</FlagMessage>
</div>
)}
{warning}
<CodeSnippet className="sw-p-6 sw-overflow-auto" snippet={yamlTemplate} language="yml" />
</NumberedListItem>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* SonarQube
* Copyright (C) 2009-2024 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { LinkStandalone } from '@sonarsource/echoes-react';
import { FlagMessage } from 'design-system';
import React from 'react';
import { FormattedMessage } from 'react-intl';
import { DocLink } from '../../../helpers/doc-links';
import { useDocUrl } from '../../../helpers/docs';
import { translate } from '../../../helpers/l10n';

export function JreRequiredWarning() {
const scannerRequirementsUrl = useDocUrl(DocLink.SonarScannerRequirements);

return (
<div>
<FlagMessage className="sw-mt-2 sw-w-abs-600" variant="warning">
<p className="sw-mb-2">
<FormattedMessage
defaultMessage={translate('onboarding.analysis.sq_scanner.jre_required_warning')}
id="onboarding.analysis.sq_scanner.jre_required_warning"
values={{
link: (
<LinkStandalone to={scannerRequirementsUrl}>
{translate('onboarding.analysis.sq_scanner.jre_required_warning.link')}
</LinkStandalone>
),
}}
/>
</p>
</FlagMessage>
</div>
);
}
Loading

0 comments on commit 255d54f

Please sign in to comment.