diff options
author | Vincenzo Pellegrini <vincenzo.pellegrini@sonarsource.com> | 2024-06-17 12:17:41 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-06-17 20:02:36 +0000 |
commit | 5f8b5e97529ffdb3aaccf6ee54cc530a9b2ef0b1 (patch) | |
tree | 06201170f21c0a1deac7228c2d23928effcf0869 /server | |
parent | bf7c885eeff7c46a1a444038380fa33d0c686df4 (diff) | |
download | sonarqube-5f8b5e97529ffdb3aaccf6ee54cc530a9b2ef0b1.tar.gz sonarqube-5f8b5e97529ffdb3aaccf6ee54cc530a9b2ef0b1.zip |
SONAR-22358 Update CFamily project onboarding example to run on both x64 and Linux ARM64 (#11243)
Diffstat (limited to 'server')
25 files changed, 1135 insertions, 360 deletions
diff --git a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/AzurePipelinesTutorial-it.tsx b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/AzurePipelinesTutorial-it.tsx index 3f58c95ae0c..bdb521f43ec 100644 --- a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/AzurePipelinesTutorial-it.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/AzurePipelinesTutorial-it.tsx @@ -98,6 +98,8 @@ it('should render correctly and allow token generation', async () => { await user.click(getTutorialBuildButtons().autoConfigManual.get()); await user.click(getTutorialBuildButtons().linuxButton.get()); assertManualCppStepIsCorrectlyRendered(OSs.Linux); + await user.click(getTutorialBuildButtons().arm64Button.get()); + assertManualCppStepIsCorrectlyRendered(OSs.Linux, 'arm64'); await user.click(getTutorialBuildButtons().windowsButton.get()); assertObjCStepIsCorrectlyRendered(OSs.Windows); await user.click(getTutorialBuildButtons().macosButton.get()); @@ -106,7 +108,10 @@ it('should render correctly and allow token generation', async () => { // Analysis step: C Family await user.click(getTutorialBuildButtons().objCBuildButton.get()); await user.click(getTutorialBuildButtons().linuxButton.get()); + await user.click(getTutorialBuildButtons().x86_64Button.get()); assertObjCStepIsCorrectlyRendered(OSs.Linux); + await user.click(getTutorialBuildButtons().arm64Button.get()); + assertObjCStepIsCorrectlyRendered(OSs.Linux, 'arm64'); await user.click(getTutorialBuildButtons().windowsButton.get()); assertObjCStepIsCorrectlyRendered(OSs.Windows); await user.click(getTutorialBuildButtons().macosButton.get()); @@ -165,14 +170,16 @@ function assertGradleStepIsCorrectlyRendered() { expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot('gradle, copy additional properties'); } -function assertObjCStepIsCorrectlyRendered(os: string) { - expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot(`objectivec ${os}, copy shell script`); +function assertObjCStepIsCorrectlyRendered(os: string, arch: string = 'x86_64') { + expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot( + `objectivec ${os} ${arch}, copy shell script`, + ); expect(getCopyToClipboardValue(1, 'Copy to clipboard')).toBe('foo'); expect(getCopyToClipboardValue(2, 'Copy to clipboard')).toMatchSnapshot( - `objectivec ${os}, copy additional properties`, + `objectivec ${os} ${arch}, copy additional properties`, ); expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot( - `objectivec ${os}, copy build-wrapper command`, + `objectivec ${os} ${arch}, copy build-wrapper command`, ); } @@ -180,14 +187,16 @@ function assertAutomaticCppStepIsCorrectlyRendered() { assertOtherStepIsCorrectlyRendered(); } -function assertManualCppStepIsCorrectlyRendered(os: string) { - expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot(`manual-cpp ${os}, copy shell script`); +function assertManualCppStepIsCorrectlyRendered(os: string, arch: string = 'x86_64') { + expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot( + `manual-cpp ${os} ${arch}, copy shell script`, + ); expect(getCopyToClipboardValue(1, 'Copy to clipboard')).toBe('foo'); expect(getCopyToClipboardValue(2, 'Copy to clipboard')).toMatchSnapshot( - `manual-cpp ${os}, copy additional properties`, + `manual-cpp ${os} ${arch}, copy additional properties`, ); expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot( - `manual-cpp ${os}, copy build-wrapper command`, + `manual-cpp ${os} ${arch}, copy build-wrapper command`, ); } diff --git a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/__snapshots__/AzurePipelinesTutorial-it.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/__snapshots__/AzurePipelinesTutorial-it.tsx.snap index 3e7f2240b79..e68cb7998ee 100644 --- a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/__snapshots__/AzurePipelinesTutorial-it.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/__snapshots__/AzurePipelinesTutorial-it.tsx.snap @@ -9,11 +9,20 @@ sonar.projectName=MyProject " `; -exports[`should render correctly and allow token generation: manual-cpp linux, copy additional properties 1`] = `"sonar.cfamily.compile-commands=bw-output/compile_commands.json"`; +exports[`should render correctly and allow token generation: manual-cpp linux arm64, copy additional properties 1`] = `"sonar.cfamily.compile-commands=bw-output/compile_commands.json"`; -exports[`should render correctly and allow token generation: manual-cpp linux, copy build-wrapper command 1`] = `"./build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output <your build command here>"`; +exports[`should render correctly and allow token generation: manual-cpp linux arm64, copy build-wrapper command 1`] = `"./build-wrapper-linux-aarch64/build-wrapper-linux-aarch64 --out-dir bw-output <your build command here>"`; -exports[`should render correctly and allow token generation: manual-cpp linux, copy shell script 1`] = ` +exports[`should render correctly and allow token generation: manual-cpp linux arm64, copy shell script 1`] = ` +"curl 'http://localhost/static/cpp/build-wrapper-linux-aarch64.zip' --output build-wrapper.zip +unzip build-wrapper.zip" +`; + +exports[`should render correctly and allow token generation: manual-cpp linux x86_64, copy additional properties 1`] = `"sonar.cfamily.compile-commands=bw-output/compile_commands.json"`; + +exports[`should render correctly and allow token generation: manual-cpp linux x86_64, copy build-wrapper command 1`] = `"./build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output <your build command here>"`; + +exports[`should render correctly and allow token generation: manual-cpp linux x86_64, copy shell script 1`] = ` "curl 'http://localhost/static/cpp/build-wrapper-linux-x86.zip' --output build-wrapper.zip unzip build-wrapper.zip" `; @@ -27,47 +36,56 @@ sonar.projectName=MyProject " `; -exports[`should render correctly and allow token generation: objectivec linux, copy additional properties 1`] = `"sonar.cfamily.compile-commands=bw-output/compile_commands.json"`; +exports[`should render correctly and allow token generation: objectivec linux arm64, copy additional properties 1`] = `"sonar.cfamily.compile-commands=bw-output/compile_commands.json"`; + +exports[`should render correctly and allow token generation: objectivec linux arm64, copy build-wrapper command 1`] = `"./build-wrapper-linux-aarch64/build-wrapper-linux-aarch64 --out-dir bw-output <your build command here>"`; + +exports[`should render correctly and allow token generation: objectivec linux arm64, copy shell script 1`] = ` +"curl 'http://localhost/static/cpp/build-wrapper-linux-aarch64.zip' --output build-wrapper.zip +unzip build-wrapper.zip" +`; + +exports[`should render correctly and allow token generation: objectivec linux x86_64, copy additional properties 1`] = `"sonar.cfamily.compile-commands=bw-output/compile_commands.json"`; -exports[`should render correctly and allow token generation: objectivec linux, copy build-wrapper command 1`] = `"./build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output <your build command here>"`; +exports[`should render correctly and allow token generation: objectivec linux x86_64, copy build-wrapper command 1`] = `"./build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output <your build command here>"`; -exports[`should render correctly and allow token generation: objectivec linux, copy shell script 1`] = ` +exports[`should render correctly and allow token generation: objectivec linux x86_64, copy shell script 1`] = ` "curl 'http://localhost/static/cpp/build-wrapper-linux-x86.zip' --output build-wrapper.zip unzip build-wrapper.zip" `; -exports[`should render correctly and allow token generation: objectivec mac, copy additional properties 1`] = `"sonar.cfamily.compile-commands=bw-output/compile_commands.json"`; +exports[`should render correctly and allow token generation: objectivec mac x86_64, copy additional properties 1`] = `"sonar.cfamily.compile-commands=bw-output/compile_commands.json"`; -exports[`should render correctly and allow token generation: objectivec mac, copy additional properties 2`] = `"sonar.cfamily.compile-commands=bw-output/compile_commands.json"`; +exports[`should render correctly and allow token generation: objectivec mac x86_64, copy additional properties 2`] = `"sonar.cfamily.compile-commands=bw-output/compile_commands.json"`; -exports[`should render correctly and allow token generation: objectivec mac, copy build-wrapper command 1`] = `"./build-wrapper-macosx-x86/build-wrapper-macosx-x86 --out-dir bw-output <your build command here>"`; +exports[`should render correctly and allow token generation: objectivec mac x86_64, copy build-wrapper command 1`] = `"./build-wrapper-macosx-x86/build-wrapper-macosx-x86 --out-dir bw-output <your build command here>"`; -exports[`should render correctly and allow token generation: objectivec mac, copy build-wrapper command 2`] = `"./build-wrapper-macosx-x86/build-wrapper-macosx-x86 --out-dir bw-output <your build command here>"`; +exports[`should render correctly and allow token generation: objectivec mac x86_64, copy build-wrapper command 2`] = `"./build-wrapper-macosx-x86/build-wrapper-macosx-x86 --out-dir bw-output <your build command here>"`; -exports[`should render correctly and allow token generation: objectivec mac, copy shell script 1`] = ` +exports[`should render correctly and allow token generation: objectivec mac x86_64, copy shell script 1`] = ` "curl 'http://localhost/static/cpp/build-wrapper-macosx-x86.zip' --output build-wrapper.zip unzip build-wrapper.zip" `; -exports[`should render correctly and allow token generation: objectivec mac, copy shell script 2`] = ` +exports[`should render correctly and allow token generation: objectivec mac x86_64, copy shell script 2`] = ` "curl 'http://localhost/static/cpp/build-wrapper-macosx-x86.zip' --output build-wrapper.zip unzip build-wrapper.zip" `; -exports[`should render correctly and allow token generation: objectivec win, copy additional properties 1`] = `"sonar.cfamily.compile-commands=bw-output/compile_commands.json"`; +exports[`should render correctly and allow token generation: objectivec win x86_64, copy additional properties 1`] = `"sonar.cfamily.compile-commands=bw-output/compile_commands.json"`; -exports[`should render correctly and allow token generation: objectivec win, copy additional properties 2`] = `"sonar.cfamily.compile-commands=bw-output/compile_commands.json"`; +exports[`should render correctly and allow token generation: objectivec win x86_64, copy additional properties 2`] = `"sonar.cfamily.compile-commands=bw-output/compile_commands.json"`; -exports[`should render correctly and allow token generation: objectivec win, copy build-wrapper command 1`] = `"build-wrapper-win-x86/build-wrapper-win-x86-64.exe --out-dir bw-output <your build command here>"`; +exports[`should render correctly and allow token generation: objectivec win x86_64, copy build-wrapper command 1`] = `"build-wrapper-win-x86/build-wrapper-win-x86-64.exe --out-dir bw-output <your build command here>"`; -exports[`should render correctly and allow token generation: objectivec win, copy build-wrapper command 2`] = `"build-wrapper-win-x86/build-wrapper-win-x86-64.exe --out-dir bw-output <your build command here>"`; +exports[`should render correctly and allow token generation: objectivec win x86_64, copy build-wrapper command 2`] = `"build-wrapper-win-x86/build-wrapper-win-x86-64.exe --out-dir bw-output <your build command here>"`; -exports[`should render correctly and allow token generation: objectivec win, copy shell script 1`] = ` +exports[`should render correctly and allow token generation: objectivec win x86_64, copy shell script 1`] = ` "Invoke-WebRequest -Uri 'http://localhost/static/cpp/build-wrapper-win-x86.zip' -OutFile 'build-wrapper.zip' Expand-Archive -Path 'build-wrapper.zip' -DestinationPath '.'" `; -exports[`should render correctly and allow token generation: objectivec win, copy shell script 2`] = ` +exports[`should render correctly and allow token generation: objectivec win x86_64, copy shell script 2`] = ` "Invoke-WebRequest -Uri 'http://localhost/static/cpp/build-wrapper-win-x86.zip' -OutFile 'build-wrapper.zip' Expand-Archive -Path 'build-wrapper.zip' -DestinationPath '.'" `; diff --git a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/ClangGCC.tsx b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/ClangGCC.tsx index eaab6c03151..8fac8158624 100644 --- a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/ClangGCC.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/ClangGCC.tsx @@ -31,7 +31,8 @@ import { CompilationInfo } from '../../components/CompilationInfo'; import GithubCFamilyExampleRepositories from '../../components/GithubCFamilyExampleRepositories'; import RenderOptions from '../../components/RenderOptions'; import SentenceWithHighlights from '../../components/SentenceWithHighlights'; -import { AutoConfig, BuildTools, OSs, TutorialConfig, TutorialModes } from '../../types'; +import { Arch, AutoConfig, BuildTools, OSs, TutorialConfig, TutorialModes } from '../../types'; +import { getBuildWrapperExecutableLinux, getBuildWrapperFolderLinux } from '../../utils'; import AlertClassicEditor from './AlertClassicEditor'; import Other from './Other'; import PrepareAnalysisCommand, { PrepareType } from './PrepareAnalysisCommand'; @@ -53,16 +54,16 @@ type OsConstant = { export default function ClangGCC(props: ClangGCCProps) { const { config, projectKey } = props; const [os, setOs] = React.useState<OSs>(OSs.Linux); + const [arch, setArch] = React.useState<Arch>(Arch.X86_64); const host = getHostUrl(); const codeSnippetDownload: OsConstant = { [OSs.Linux]: { - script: `curl '${host}/static/cpp/build-wrapper-linux-x86.zip' --output build-wrapper.zip + script: `curl '${host}/static/cpp/${getBuildWrapperFolderLinux(arch)}.zip' --output build-wrapper.zip unzip build-wrapper.zip`, highlightScriptKey: 'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.build_wrapper.ccpp.nix', - scriptBuild: - './build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output <your build command here>', + scriptBuild: `./${getBuildWrapperFolderLinux(arch)}/${getBuildWrapperExecutableLinux(arch)} --out-dir bw-output <your build command here>`, }, [OSs.Windows]: { script: `Invoke-WebRequest -Uri '${host}/static/cpp/build-wrapper-win-x86.zip' -OutFile 'build-wrapper.zip' @@ -96,6 +97,20 @@ unzip build-wrapper.zip`, optionLabelKey="onboarding.build.other.os" options={Object.values(OSs)} /> + {os === OSs.Linux && ( + <> + <div className="sw-mt-4"> + {translate('onboarding.tutorial.with.azure_pipelines.architecture')} + </div> + <RenderOptions + label={translate('onboarding.tutorial.with.azure_pipelines.architecture')} + checked={arch} + onCheck={(value: Arch) => setArch(value)} + optionLabelKey="onboarding.build.other.architecture" + options={[Arch.X86_64, Arch.Arm64]} + /> + </> + )} <GithubCFamilyExampleRepositories className="sw-mt-4 sw-w-abs-600" diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/AnalysisCommand.tsx b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/AnalysisCommand.tsx index 66bf5fa08fd..fa956930e0b 100644 --- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/AnalysisCommand.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/AnalysisCommand.tsx @@ -26,7 +26,7 @@ import { Feature } from '../../../types/features'; import { Component } from '../../../types/types'; import { CompilationInfo } from '../components/CompilationInfo'; import CreateYmlFile from '../components/CreateYmlFile'; -import { BuildTools, TutorialConfig } from '../types'; +import { Arch, BuildTools, TutorialConfig } from '../types'; import { isCFamily } from '../utils'; import { PreambuleYaml } from './PreambuleYaml'; import cFamilyExample from './commands/CFamily'; @@ -36,12 +36,14 @@ import mavenExample from './commands/Maven'; import othersExample from './commands/Others'; export interface AnalysisCommandProps extends WithAvailableFeaturesProps { + arch: Arch; component: Component; config: TutorialConfig; mainBranchName: string; } export type BuildToolExampleBuilder = (data: { + arch?: Arch; branchesEnabled?: boolean; config: TutorialConfig; mainBranchName?: string; @@ -58,8 +60,8 @@ const YamlTemplate: Dictionary<BuildToolExampleBuilder> = { [BuildTools.Other]: othersExample, }; -export function AnalysisCommand(props: AnalysisCommandProps) { - const { config, mainBranchName, component } = props; +export function AnalysisCommand(props: Readonly<AnalysisCommandProps>) { + const { config, arch, mainBranchName, component } = props; const branchesEnabled = props.hasFeature(Feature.BranchSupport); if (!config.buildTool) { @@ -67,6 +69,7 @@ export function AnalysisCommand(props: AnalysisCommandProps) { } const yamlTemplate = YamlTemplate[config.buildTool]({ + arch, config, branchesEnabled, mainBranchName, diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/BitbucketPipelinesTutorial.tsx b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/BitbucketPipelinesTutorial.tsx index 21e6173ac78..08e8672d118 100644 --- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/BitbucketPipelinesTutorial.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/BitbucketPipelinesTutorial.tsx @@ -25,9 +25,10 @@ import { Component } from '../../../types/types'; import { LoggedInUser } from '../../../types/users'; import AllSet from '../components/AllSet'; import GithubCFamilyExampleRepositories from '../components/GithubCFamilyExampleRepositories'; +import RenderOptions from '../components/RenderOptions'; import YamlFileStep from '../components/YamlFileStep'; -import { TutorialConfig, TutorialModes } from '../types'; -import { shouldShowGithubCFamilyExampleRepositories } from '../utils'; +import { Arch, OSs, TutorialConfig, TutorialModes } from '../types'; +import { shouldShowArchSelector, shouldShowGithubCFamilyExampleRepositories } from '../utils'; import AnalysisCommand from './AnalysisCommand'; import RepositoryVariables from './RepositoryVariables'; @@ -46,12 +47,15 @@ export interface BitbucketPipelinesTutorialProps { willRefreshAutomatically?: boolean; } -export default function BitbucketPipelinesTutorial(props: BitbucketPipelinesTutorialProps) { +export default function BitbucketPipelinesTutorial( + props: Readonly<BitbucketPipelinesTutorialProps>, +) { const { almBinding, baseUrl, currentUser, component, willRefreshAutomatically, mainBranchName } = props; const [config, setConfig] = React.useState<TutorialConfig>({}); const [done, setDone] = React.useState(false); + const [arch, setArch] = React.useState<Arch>(Arch.X86_64); React.useEffect(() => { setDone(Boolean(config.buildTool)); @@ -82,8 +86,21 @@ export default function BitbucketPipelinesTutorial(props: BitbucketPipelinesTuto ci={TutorialModes.BitbucketPipelines} /> )} + {shouldShowArchSelector(OSs.Linux, config) && ( + <div className="sw-my-4"> + <RenderOptions + label={translate('onboarding.build.other.architecture')} + checked={arch} + onCheck={(value: Arch) => setArch(value)} + optionLabelKey="onboarding.build.other.architecture" + options={[Arch.X86_64, Arch.Arm64]} + titleLabelKey="onboarding.build.other.architecture" + /> + </div> + )} <AnalysisCommand config={config} + arch={arch} component={component} mainBranchName={mainBranchName} /> diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/BitbucketPipelinesTutorial-it.tsx b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/BitbucketPipelinesTutorial-it.tsx index 76f46695e44..0f3a5e8d3e2 100644 --- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/BitbucketPipelinesTutorial-it.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/BitbucketPipelinesTutorial-it.tsx @@ -103,15 +103,30 @@ it('should follow and complete all steps', async () => { expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot( 'C++ (manual) and Objective-C: bitbucket-pipelines.yml', ); + await user.click(ui.arm64Button.get()); + expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot( + 'C++ (manual arm64) and Objective-C: sonar-project.properties', + ); + expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot( + 'C++ (manual arm64) and Objective-C: bitbucket-pipelines.yml', + ); // Objective-C await user.click(ui.objCBuildButton.get()); + await user.click(ui.x86_64Button.get()); expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot( 'C++ (manual) and Objective-C: bitbucket-pipelines.yml', ); expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot( 'C++ (manual) and Objective-C: sonar-project.properties', ); + await user.click(ui.arm64Button.get()); + expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot( + 'C++ (manual arm64) and Objective-C: bitbucket-pipelines.yml', + ); + expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot( + 'C++ (manual arm64) and Objective-C: sonar-project.properties', + ); // Other await user.click(ui.otherBuildButton.get()); diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/BitbucketPipelinesTutorial-it.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/BitbucketPipelinesTutorial-it.tsx.snap index 39b68ed6fdd..af497235e2f 100644 --- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/BitbucketPipelinesTutorial-it.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/BitbucketPipelinesTutorial-it.tsx.snap @@ -93,6 +93,78 @@ exports[`should follow and complete all steps: C++ (automatic) and other: sonar- exports[`should follow and complete all steps: C++ (automatic) and other: sonar-project.properties 2`] = `"sonar.projectKey=my-project"`; +exports[`should follow and complete all steps: C++ (manual arm64) and Objective-C: bitbucket-pipelines.yml 1`] = ` +"image: <image ready for your build toolchain> + +definitions: + steps: + - step: &build-step + name: Build the project, and run the SonarQube analysis + script: + - export SONAR_SCANNER_VERSION=5.0.1.3006 + - 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/ + - curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-\${SONAR_SCANNER_VERSION}-linux.zip + - unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ + - export PATH="$PATH:$HOME/.sonar/sonar-scanner-\${SONAR_SCANNER_VERSION}-linux/bin" + - <any step required before running your build, like ./configure> + - $HOME/.sonar/build-wrapper-linux-aarch64/build-wrapper-linux-aarch64 --out-dir bw-output <your clean build command> + - sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json + caches: + sonar: ~/.sonar + +clone: + depth: full + +pipelines: + branches: + '{main}': + - step: *build-step + + pull-requests: + '**': + - step: *build-step" +`; + +exports[`should follow and complete all steps: C++ (manual arm64) and Objective-C: bitbucket-pipelines.yml 2`] = `"sonar.projectKey=my-project"`; + +exports[`should follow and complete all steps: C++ (manual arm64) and Objective-C: sonar-project.properties 1`] = `"sonar.projectKey=my-project"`; + +exports[`should follow and complete all steps: C++ (manual arm64) and Objective-C: sonar-project.properties 2`] = ` +"image: <image ready for your build toolchain> + +definitions: + steps: + - step: &build-step + name: Build the project, and run the SonarQube analysis + script: + - export SONAR_SCANNER_VERSION=5.0.1.3006 + - 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/ + - curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-\${SONAR_SCANNER_VERSION}-linux.zip + - unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ + - export PATH="$PATH:$HOME/.sonar/sonar-scanner-\${SONAR_SCANNER_VERSION}-linux/bin" + - <any step required before running your build, like ./configure> + - $HOME/.sonar/build-wrapper-linux-aarch64/build-wrapper-linux-aarch64 --out-dir bw-output <your clean build command> + - sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json + caches: + sonar: ~/.sonar + +clone: + depth: full + +pipelines: + branches: + '{main}': + - step: *build-step + + pull-requests: + '**': + - step: *build-step" +`; + exports[`should follow and complete all steps: C++ (manual) and Objective-C: bitbucket-pipelines.yml 1`] = ` "image: <image ready for your build toolchain> diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/CFamily.ts b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/CFamily.ts index 2f694274649..70df56f6ce9 100644 --- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/CFamily.ts +++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/CFamily.ts @@ -18,13 +18,21 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { AutoConfig, BuildTools } from '../../types'; +import { getBuildWrapperExecutableLinux, getBuildWrapperFolderLinux } from '../../utils'; import { BuildToolExampleBuilder } from '../AnalysisCommand'; import othersExample from './Others'; -const cFamilyExample: BuildToolExampleBuilder = ({ config, branchesEnabled, mainBranchName }) => { +const cFamilyExample: BuildToolExampleBuilder = ({ + config, + arch, + branchesEnabled, + mainBranchName, +}) => { if (config.buildTool === BuildTools.Cpp && config.autoConfig === AutoConfig.Automatic) { return othersExample({ config, branchesEnabled, mainBranchName }); } + const buildWrapperExecutable = getBuildWrapperExecutableLinux(arch); + const buildWrapperFolder = getBuildWrapperFolderLinux(arch); return `image: <image ready for your build toolchain> definitions: @@ -34,13 +42,13 @@ definitions: script: - export SONAR_SCANNER_VERSION=5.0.1.3006 - 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/ + - curl -sSLo $HOME/.sonar/${buildWrapperFolder}.zip \${SONAR_HOST_URL}/static/cpp/${buildWrapperFolder}.zip + - unzip -o $HOME/.sonar/${buildWrapperFolder}.zip -d $HOME/.sonar/ - curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-\${SONAR_SCANNER_VERSION}-linux.zip - unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ - export PATH="$PATH:$HOME/.sonar/sonar-scanner-\${SONAR_SCANNER_VERSION}-linux/bin" - <any step required before running your build, like ./configure> - - $HOME/.sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output <your clean build command> + - $HOME/.sonar/${buildWrapperFolder}/${buildWrapperExecutable} --out-dir bw-output <your clean build command> - sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json caches: sonar: ~/.sonar diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/GithubActionTutorial-it.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/GithubActionTutorial-it.tsx index 3f946d6a27b..06ff90c6eb6 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/GithubActionTutorial-it.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/GithubActionTutorial-it.tsx @@ -99,6 +99,10 @@ it('should follow and complete all steps', async () => { expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot( 'C++ Linux: .github/workflows/build.yml', ); + await user.click(ui.arm64Button.get()); + expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot( + 'C++ Linux arm64: .github/workflows/build.yml', + ); await user.click(ui.windowsButton.get()); expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot( 'C++ Windows: .github/workflows/build.yml', @@ -115,9 +119,14 @@ it('should follow and complete all steps', async () => { ); await user.click(ui.linuxButton.get()); + await user.click(ui.x86_64Button.get()); expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot( 'Objective-C Linux: .github/workflows/build.yml', ); + await user.click(ui.arm64Button.get()); + expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot( + 'Objective-C Linux arm64: .github/workflows/build.yml', + ); await user.click(ui.windowsButton.get()); expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot( 'Objective-C Windows: .github/workflows/build.yml', diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/__snapshots__/GithubActionTutorial-it.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/__snapshots__/GithubActionTutorial-it.tsx.snap index 3cc30b5bdf0..2ace2a276ea 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/__snapshots__/GithubActionTutorial-it.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/__snapshots__/GithubActionTutorial-it.tsx.snap @@ -120,6 +120,42 @@ exports[`should follow and complete all steps: C++ (automatic) and other: sonar- exports[`should follow and complete all steps: C++ (automatic) and other: sonar-project.properties 2`] = `"sonar.projectKey=my-project"`; +exports[`should follow and complete all steps: C++ Linux arm64: .github/workflows/build.yml 1`] = ` +"name: Build + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build: + name: Build and analyze + runs-on: ubuntu-latest + env: + BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Install sonar-scanner and build-wrapper + env: + SONAR_HOST_URL: \${{secrets.SONAR_HOST_URL}} + uses: SonarSource/sonarqube-github-c-cpp@v1 + - name: Run build-wrapper + run: | + build-wrapper-linux-aarch64 --out-dir \${{ env.BUILD_WRAPPER_OUT_DIR }} <insert_your_clean_build_command> + - name: Run sonar-scanner + env: + GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: \${{secrets.SONAR_HOST_URL}} + run: | + sonar-scanner --define sonar.cfamily.compile-commands="\${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"" +`; + exports[`should follow and complete all steps: C++ Linux: .github/workflows/build.yml 1`] = ` "name: Build @@ -340,6 +376,42 @@ jobs: run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=my-project -Dsonar.projectName='MyProject'" `; +exports[`should follow and complete all steps: Objective-C Linux arm64: .github/workflows/build.yml 1`] = ` +"name: Build + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build: + name: Build and analyze + runs-on: ubuntu-latest + env: + BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Install sonar-scanner and build-wrapper + env: + SONAR_HOST_URL: \${{secrets.SONAR_HOST_URL}} + uses: SonarSource/sonarqube-github-c-cpp@v1 + - name: Run build-wrapper + run: | + build-wrapper-linux-aarch64 --out-dir \${{ env.BUILD_WRAPPER_OUT_DIR }} <insert_your_clean_build_command> + - name: Run sonar-scanner + env: + GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: \${{secrets.SONAR_HOST_URL}} + run: | + sonar-scanner --define sonar.cfamily.compile-commands="\${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"" +`; + exports[`should follow and complete all steps: Objective-C Linux: .github/workflows/build.yml 1`] = ` "name: Build diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/CFamily.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/CFamily.tsx index 7c0513374fc..ae686befe7d 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/CFamily.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/CFamily.tsx @@ -26,7 +26,8 @@ import CreateYmlFile from '../../components/CreateYmlFile'; import DefaultProjectKey from '../../components/DefaultProjectKey'; import GithubCFamilyExampleRepositories from '../../components/GithubCFamilyExampleRepositories'; import RenderOptions from '../../components/RenderOptions'; -import { AutoConfig, BuildTools, OSs, TutorialConfig, TutorialModes } from '../../types'; +import { Arch, AutoConfig, BuildTools, OSs, TutorialConfig, TutorialModes } from '../../types'; +import { getBuildWrapperExecutableLinux } from '../../utils'; import { generateGitHubActionsYaml } from '../utils'; import MonorepoDocLinkFallback from './MonorepoDocLinkFallback'; import Others from './Others'; @@ -39,23 +40,25 @@ export interface CFamilyProps { monorepo?: boolean; } -const STEPS = { - [OSs.Linux]: ` +const STEPS = (os?: OSs, arch?: Arch) => { + if (OSs.Linux === os) { + return ` - name: Install sonar-scanner and build-wrapper env: SONAR_HOST_URL: \${{secrets.SONAR_HOST_URL}} uses: SonarSource/sonarqube-github-c-cpp@v1 - name: Run build-wrapper run: | - build-wrapper-linux-x86-64 --out-dir \${{ env.BUILD_WRAPPER_OUT_DIR }} <insert_your_clean_build_command> + ${getBuildWrapperExecutableLinux(arch)} --out-dir \${{ env.BUILD_WRAPPER_OUT_DIR }} <insert_your_clean_build_command> - name: Run sonar-scanner env: GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: \${{secrets.SONAR_HOST_URL}} run: | - sonar-scanner --define sonar.cfamily.compile-commands="\${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"`, - [OSs.MacOS]: ` + sonar-scanner --define sonar.cfamily.compile-commands="\${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"`; + } else if (OSs.MacOS === os) { + return ` - name: Install sonar-scanner and build-wrapper env: SONAR_HOST_URL: \${{secrets.SONAR_HOST_URL}} @@ -69,8 +72,9 @@ const STEPS = { SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: \${{secrets.SONAR_HOST_URL}} run: | - sonar-scanner --define sonar.cfamily.compile-commands="\${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"`, - [OSs.Windows]: ` + sonar-scanner --define sonar.cfamily.compile-commands="\${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"`; + } else if (OSs.Windows === os) { + return ` - name: Install sonar-scanner and build-wrapper env: SONAR_HOST_URL: \${{secrets.SONAR_HOST_URL}} @@ -84,12 +88,16 @@ const STEPS = { SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: \${{secrets.SONAR_HOST_URL}} run: | - sonar-scanner --define sonar.cfamily.compile-commands="\${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"`, + sonar-scanner --define sonar.cfamily.compile-commands="\${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"`; + } + + return ''; }; -export default function CFamily(props: CFamilyProps) { +export default function CFamily(props: Readonly<CFamilyProps>) { const { config, component, branchesEnabled, mainBranchName, monorepo } = props; const [os, setOs] = React.useState<OSs>(OSs.Linux); + const [arch, setArch] = React.useState<Arch>(Arch.X86_64); if (config.buildTool === BuildTools.Cpp && config.autoConfig === AutoConfig.Automatic) { return <Others {...props} />; @@ -112,6 +120,18 @@ export default function CFamily(props: CFamilyProps) { optionLabelKey="onboarding.build.other.os" options={Object.values(OSs)} /> + {os === OSs.Linux && ( + <> + <div className="sw-mt-4">{translate('onboarding.build.other.architecture')}</div> + <RenderOptions + label={translate('onboarding.build.other.architecture')} + checked={arch} + onCheck={(value: Arch) => setArch(value)} + optionLabelKey="onboarding.build.other.architecture" + options={[Arch.X86_64, Arch.Arm64]} + /> + </> + )} <GithubCFamilyExampleRepositories className="sw-mt-4 sw-w-abs-600" os={os} @@ -128,7 +148,7 @@ export default function CFamily(props: CFamilyProps) { mainBranchName, !!branchesEnabled, runsOn[os], - STEPS[os], + STEPS(os, arch), `env: BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed`, )} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/JenkinsTutorial-it.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/JenkinsTutorial-it.tsx index 9380803e1ae..98dcb166e66 100644 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/JenkinsTutorial-it.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/JenkinsTutorial-it.tsx @@ -149,6 +149,11 @@ it.each([AlmKeys.BitbucketCloud, AlmKeys.BitbucketServer, AlmKeys.GitHub, AlmKey `c++ (manual) and objectivec: linux jenkinsfile`, ); + await user.click(ui.arm64Button.get()); + expect(getCopyToClipboardValue(3, 'Copy')).toMatchSnapshot( + `c++ (manual) and objectivec: linux arm64 jenkinsfile`, + ); + await user.click(ui.windowsButton.get()); expect(getCopyToClipboardValue(3, 'Copy')).toMatchSnapshot( `c++ (manual) and objectivec: windows jenkinsfile`, @@ -164,19 +169,19 @@ it.each([AlmKeys.BitbucketCloud, AlmKeys.BitbucketServer, AlmKeys.GitHub, AlmKey expect(getCopyToClipboardValue(2, 'Copy')).toMatchSnapshot(`sonar-project.properties code`); await user.click(ui.linuxButton.get()); + await user.click(ui.x86_64Button.get()); + expect(getCopyToClipboardValue(3, 'Copy')).toMatchSnapshot(`objectivec: linux jenkinsfile`); + + await user.click(ui.arm64Button.get()); expect(getCopyToClipboardValue(3, 'Copy')).toMatchSnapshot( - `c++ (manual) and objectivec: linux jenkinsfile`, + `objectivec: linux arm64 jenkinsfile`, ); await user.click(ui.windowsButton.get()); - expect(getCopyToClipboardValue(3, 'Copy')).toMatchSnapshot( - `c++ (manual) and objectivec: windows jenkinsfile`, - ); + expect(getCopyToClipboardValue(3, 'Copy')).toMatchSnapshot(`objectivec: windows jenkinsfile`); await user.click(ui.macosButton.get()); - expect(getCopyToClipboardValue(3, 'Copy')).toMatchSnapshot( - `c++ (manual) and objectivec: macos jenkinsfile`, - ); + expect(getCopyToClipboardValue(3, 'Copy')).toMatchSnapshot(`objectivec: macos jenkinsfile`); // Other await user.click(ui.otherBuildButton.get()); diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/JenkinsTutorial-it.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/JenkinsTutorial-it.tsx.snap index e540489c9a7..cb6312f809a 100644 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/JenkinsTutorial-it.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/JenkinsTutorial-it.tsx.snap @@ -58,18 +58,18 @@ exports[`bitbucket: can select devops platform and complete all the steps with c exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: c++ (automatic and other): build tools sonar-project.properties code 2`] = `"sonar.projectKey=my-project"`; -exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: c++ (manual) and objectivec: linux jenkinsfile 1`] = ` +exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: c++ (manual) and objectivec: linux arm64 jenkinsfile 1`] = ` "node { stage('SCM') { checkout scm } stage('Download Build Wrapper') { sh "mkdir -p .sonar" - sh "curl -sSLo build-wrapper-linux-x86.zip http://localhost:9000/static/cpp/build-wrapper-linux-x86.zip" - sh "unzip -o build-wrapper-linux-x86.zip -d .sonar" + sh "curl -sSLo build-wrapper-linux-aarch64.zip http://localhost:9000/static/cpp/build-wrapper-linux-aarch64.zip" + sh "unzip -o build-wrapper-linux-aarch64.zip -d .sonar" } stage('Build') { - sh ".sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output <your clean build command>" + sh ".sonar/build-wrapper-linux-aarch64/build-wrapper-linux-aarch64 --out-dir bw-output <your clean build command>" } stage('SonarQube Analysis') { def scannerHome = tool 'SonarScanner'; @@ -80,7 +80,7 @@ exports[`bitbucket: can select devops platform and complete all the steps with c }" `; -exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: c++ (manual) and objectivec: linux jenkinsfile 2`] = ` +exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: c++ (manual) and objectivec: linux jenkinsfile 1`] = ` "node { stage('SCM') { checkout scm @@ -128,32 +128,6 @@ exports[`bitbucket: can select devops platform and complete all the steps with c }" `; -exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: c++ (manual) and objectivec: macos jenkinsfile 2`] = ` -"node { - stage('SCM') { - checkout scm - } - stage('Download Build Wrapper') { - sh ''' - mkdir -p .sonar - curl -sSLo build-wrapper-macosx-x86.zip http://localhost:9000/static/cpp/build-wrapper-macosx-x86.zip - unzip -o build-wrapper-macosx-x86.zip -d .sonar - ''' - } - stage('Build') { - sh ''' - .sonar/build-wrapper-macosx-x86/build-wrapper-macosx-x86 --out-dir bw-output <your clean build command> - ''' - } - stage('SonarQube Analysis') { - def scannerHome = tool 'SonarScanner'; - withSonarQubeEnv() { - sh "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json" - } - } -}" -`; - exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: c++ (manual) and objectivec: windows jenkinsfile 1`] = ` "node { stage('SCM') { @@ -186,79 +160,149 @@ exports[`bitbucket: can select devops platform and complete all the steps with c }" `; -exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: c++ (manual) and objectivec: windows jenkinsfile 2`] = ` +exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: gradle jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + withSonarQubeEnv() { + sh "./gradlew sonar" + } + } +}" +`; + +exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: jenkins url 1`] = `"***JENKINS_SERVER_URL***/bitbucket-scmsource-hook/notify?server_url=***BITBUCKET_URL***"`; + +exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: linux dotnet core jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner for .NET' + withSonarQubeEnv() { + sh "dotnet \${scannerHome}/SonarScanner.MSBuild.dll begin /k:\\"my-project\\"" + sh "dotnet build" + sh "dotnet \${scannerHome}/SonarScanner.MSBuild.dll end" + } + } +} +" +`; + +exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: maven jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def mvn = tool 'Default Maven'; + withSonarQubeEnv() { + sh "\${mvn}/bin/mvn clean verify sonar:sonar -Dsonar.projectKey=my-project -Dsonar.projectName='MyProject'" + } + } +}" +`; + +exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: objectivec: linux arm64 jenkinsfile 1`] = ` "node { stage('SCM') { checkout scm } stage('Download Build Wrapper') { - powershell ''' - $path = "$HOME/.sonar/build-wrapper-win-x86.zip" - rm build-wrapper-win-x86 -Recurse -Force -ErrorAction SilentlyContinue - rm $path -Force -ErrorAction SilentlyContinue - mkdir $HOME/.sonar - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - (New-Object System.Net.WebClient).DownloadFile(http://localhost:9000/static/cpp/build-wrapper-win-x86.zip", $path) - Add-Type -AssemblyName System.IO.Compression.FileSystem - [System.IO.Compression.ZipFile]::ExtractToDirectory($path, "$HOME/.sonar") - ''' + sh "mkdir -p .sonar" + sh "curl -sSLo build-wrapper-linux-aarch64.zip http://localhost:9000/static/cpp/build-wrapper-linux-aarch64.zip" + sh "unzip -o build-wrapper-linux-aarch64.zip -d .sonar" } stage('Build') { - powershell ''' - $env:Path += ";$HOME/.sonar/build-wrapper-win-x86" - build-wrapper-win-x86-64 --out-dir bw-output <your clean build command> - ''' + sh ".sonar/build-wrapper-linux-aarch64/build-wrapper-linux-aarch64 --out-dir bw-output <your clean build command>" } stage('SonarQube Analysis') { def scannerHome = tool 'SonarScanner'; withSonarQubeEnv() { - powershell "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json" + sh "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json" } } }" `; -exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: gradle jenkinsfile 1`] = ` +exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: objectivec: linux jenkinsfile 1`] = ` "node { stage('SCM') { checkout scm } + stage('Download Build Wrapper') { + sh "mkdir -p .sonar" + sh "curl -sSLo build-wrapper-linux-x86.zip http://localhost:9000/static/cpp/build-wrapper-linux-x86.zip" + sh "unzip -o build-wrapper-linux-x86.zip -d .sonar" + } + stage('Build') { + sh ".sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output <your clean build command>" + } stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner'; withSonarQubeEnv() { - sh "./gradlew sonar" + sh "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json" } } }" `; -exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: jenkins url 1`] = `"***JENKINS_SERVER_URL***/bitbucket-scmsource-hook/notify?server_url=***BITBUCKET_URL***"`; - -exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: linux dotnet core jenkinsfile 1`] = ` +exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: objectivec: macos jenkinsfile 1`] = ` "node { stage('SCM') { checkout scm } + stage('Download Build Wrapper') { + sh ''' + mkdir -p .sonar + curl -sSLo build-wrapper-macosx-x86.zip http://localhost:9000/static/cpp/build-wrapper-macosx-x86.zip + unzip -o build-wrapper-macosx-x86.zip -d .sonar + ''' + } + stage('Build') { + sh ''' + .sonar/build-wrapper-macosx-x86/build-wrapper-macosx-x86 --out-dir bw-output <your clean build command> + ''' + } stage('SonarQube Analysis') { - def scannerHome = tool 'SonarScanner for .NET' + def scannerHome = tool 'SonarScanner'; withSonarQubeEnv() { - sh "dotnet \${scannerHome}/SonarScanner.MSBuild.dll begin /k:\\"my-project\\"" - sh "dotnet build" - sh "dotnet \${scannerHome}/SonarScanner.MSBuild.dll end" + sh "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json" } } -} -" +}" `; -exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: maven jenkinsfile 1`] = ` +exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: objectivec: windows jenkinsfile 1`] = ` "node { stage('SCM') { checkout scm } + stage('Download Build Wrapper') { + powershell ''' + $path = "$HOME/.sonar/build-wrapper-win-x86.zip" + rm build-wrapper-win-x86 -Recurse -Force -ErrorAction SilentlyContinue + rm $path -Force -ErrorAction SilentlyContinue + mkdir $HOME/.sonar + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + (New-Object System.Net.WebClient).DownloadFile(http://localhost:9000/static/cpp/build-wrapper-win-x86.zip", $path) + Add-Type -AssemblyName System.IO.Compression.FileSystem + [System.IO.Compression.ZipFile]::ExtractToDirectory($path, "$HOME/.sonar") + ''' + } + stage('Build') { + powershell ''' + $env:Path += ";$HOME/.sonar/build-wrapper-win-x86" + build-wrapper-win-x86-64 --out-dir bw-output <your clean build command> + ''' + } stage('SonarQube Analysis') { - def mvn = tool 'Default Maven'; + def scannerHome = tool 'SonarScanner'; withSonarQubeEnv() { - sh "\${mvn}/bin/mvn clean verify sonar:sonar -Dsonar.projectKey=my-project -Dsonar.projectName='MyProject'" + powershell "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json" } } }" @@ -363,18 +407,18 @@ exports[`bitbucketcloud: can select devops platform and complete all the steps w exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: c++ (automatic and other): build tools sonar-project.properties code 2`] = `"sonar.projectKey=my-project"`; -exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: c++ (manual) and objectivec: linux jenkinsfile 1`] = ` +exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: c++ (manual) and objectivec: linux arm64 jenkinsfile 1`] = ` "node { stage('SCM') { checkout scm } stage('Download Build Wrapper') { sh "mkdir -p .sonar" - sh "curl -sSLo build-wrapper-linux-x86.zip http://localhost:9000/static/cpp/build-wrapper-linux-x86.zip" - sh "unzip -o build-wrapper-linux-x86.zip -d .sonar" + sh "curl -sSLo build-wrapper-linux-aarch64.zip http://localhost:9000/static/cpp/build-wrapper-linux-aarch64.zip" + sh "unzip -o build-wrapper-linux-aarch64.zip -d .sonar" } stage('Build') { - sh ".sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output <your clean build command>" + sh ".sonar/build-wrapper-linux-aarch64/build-wrapper-linux-aarch64 --out-dir bw-output <your clean build command>" } stage('SonarQube Analysis') { def scannerHome = tool 'SonarScanner'; @@ -385,7 +429,7 @@ exports[`bitbucketcloud: can select devops platform and complete all the steps w }" `; -exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: c++ (manual) and objectivec: linux jenkinsfile 2`] = ` +exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: c++ (manual) and objectivec: linux jenkinsfile 1`] = ` "node { stage('SCM') { checkout scm @@ -433,32 +477,6 @@ exports[`bitbucketcloud: can select devops platform and complete all the steps w }" `; -exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: c++ (manual) and objectivec: macos jenkinsfile 2`] = ` -"node { - stage('SCM') { - checkout scm - } - stage('Download Build Wrapper') { - sh ''' - mkdir -p .sonar - curl -sSLo build-wrapper-macosx-x86.zip http://localhost:9000/static/cpp/build-wrapper-macosx-x86.zip - unzip -o build-wrapper-macosx-x86.zip -d .sonar - ''' - } - stage('Build') { - sh ''' - .sonar/build-wrapper-macosx-x86/build-wrapper-macosx-x86 --out-dir bw-output <your clean build command> - ''' - } - stage('SonarQube Analysis') { - def scannerHome = tool 'SonarScanner'; - withSonarQubeEnv() { - sh "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json" - } - } -}" -`; - exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: c++ (manual) and objectivec: windows jenkinsfile 1`] = ` "node { stage('SCM') { @@ -491,79 +509,149 @@ exports[`bitbucketcloud: can select devops platform and complete all the steps w }" `; -exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: c++ (manual) and objectivec: windows jenkinsfile 2`] = ` +exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: gradle jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + withSonarQubeEnv() { + sh "./gradlew sonar" + } + } +}" +`; + +exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: jenkins url 1`] = `"***JENKINS_SERVER_URL***/bitbucket-scmsource-hook/notify"`; + +exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: linux dotnet core jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner for .NET' + withSonarQubeEnv() { + sh "dotnet \${scannerHome}/SonarScanner.MSBuild.dll begin /k:\\"my-project\\"" + sh "dotnet build" + sh "dotnet \${scannerHome}/SonarScanner.MSBuild.dll end" + } + } +} +" +`; + +exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: maven jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def mvn = tool 'Default Maven'; + withSonarQubeEnv() { + sh "\${mvn}/bin/mvn clean verify sonar:sonar -Dsonar.projectKey=my-project -Dsonar.projectName='MyProject'" + } + } +}" +`; + +exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: objectivec: linux arm64 jenkinsfile 1`] = ` "node { stage('SCM') { checkout scm } stage('Download Build Wrapper') { - powershell ''' - $path = "$HOME/.sonar/build-wrapper-win-x86.zip" - rm build-wrapper-win-x86 -Recurse -Force -ErrorAction SilentlyContinue - rm $path -Force -ErrorAction SilentlyContinue - mkdir $HOME/.sonar - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - (New-Object System.Net.WebClient).DownloadFile(http://localhost:9000/static/cpp/build-wrapper-win-x86.zip", $path) - Add-Type -AssemblyName System.IO.Compression.FileSystem - [System.IO.Compression.ZipFile]::ExtractToDirectory($path, "$HOME/.sonar") - ''' + sh "mkdir -p .sonar" + sh "curl -sSLo build-wrapper-linux-aarch64.zip http://localhost:9000/static/cpp/build-wrapper-linux-aarch64.zip" + sh "unzip -o build-wrapper-linux-aarch64.zip -d .sonar" } stage('Build') { - powershell ''' - $env:Path += ";$HOME/.sonar/build-wrapper-win-x86" - build-wrapper-win-x86-64 --out-dir bw-output <your clean build command> - ''' + sh ".sonar/build-wrapper-linux-aarch64/build-wrapper-linux-aarch64 --out-dir bw-output <your clean build command>" } stage('SonarQube Analysis') { def scannerHome = tool 'SonarScanner'; withSonarQubeEnv() { - powershell "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json" + sh "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json" } } }" `; -exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: gradle jenkinsfile 1`] = ` +exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: objectivec: linux jenkinsfile 1`] = ` "node { stage('SCM') { checkout scm } + stage('Download Build Wrapper') { + sh "mkdir -p .sonar" + sh "curl -sSLo build-wrapper-linux-x86.zip http://localhost:9000/static/cpp/build-wrapper-linux-x86.zip" + sh "unzip -o build-wrapper-linux-x86.zip -d .sonar" + } + stage('Build') { + sh ".sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output <your clean build command>" + } stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner'; withSonarQubeEnv() { - sh "./gradlew sonar" + sh "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json" } } }" `; -exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: jenkins url 1`] = `"***JENKINS_SERVER_URL***/bitbucket-scmsource-hook/notify"`; - -exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: linux dotnet core jenkinsfile 1`] = ` +exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: objectivec: macos jenkinsfile 1`] = ` "node { stage('SCM') { checkout scm } + stage('Download Build Wrapper') { + sh ''' + mkdir -p .sonar + curl -sSLo build-wrapper-macosx-x86.zip http://localhost:9000/static/cpp/build-wrapper-macosx-x86.zip + unzip -o build-wrapper-macosx-x86.zip -d .sonar + ''' + } + stage('Build') { + sh ''' + .sonar/build-wrapper-macosx-x86/build-wrapper-macosx-x86 --out-dir bw-output <your clean build command> + ''' + } stage('SonarQube Analysis') { - def scannerHome = tool 'SonarScanner for .NET' + def scannerHome = tool 'SonarScanner'; withSonarQubeEnv() { - sh "dotnet \${scannerHome}/SonarScanner.MSBuild.dll begin /k:\\"my-project\\"" - sh "dotnet build" - sh "dotnet \${scannerHome}/SonarScanner.MSBuild.dll end" + sh "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json" } } -} -" +}" `; -exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: maven jenkinsfile 1`] = ` +exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: objectivec: windows jenkinsfile 1`] = ` "node { stage('SCM') { checkout scm } + stage('Download Build Wrapper') { + powershell ''' + $path = "$HOME/.sonar/build-wrapper-win-x86.zip" + rm build-wrapper-win-x86 -Recurse -Force -ErrorAction SilentlyContinue + rm $path -Force -ErrorAction SilentlyContinue + mkdir $HOME/.sonar + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + (New-Object System.Net.WebClient).DownloadFile(http://localhost:9000/static/cpp/build-wrapper-win-x86.zip", $path) + Add-Type -AssemblyName System.IO.Compression.FileSystem + [System.IO.Compression.ZipFile]::ExtractToDirectory($path, "$HOME/.sonar") + ''' + } + stage('Build') { + powershell ''' + $env:Path += ";$HOME/.sonar/build-wrapper-win-x86" + build-wrapper-win-x86-64 --out-dir bw-output <your clean build command> + ''' + } stage('SonarQube Analysis') { - def mvn = tool 'Default Maven'; + def scannerHome = tool 'SonarScanner'; withSonarQubeEnv() { - sh "\${mvn}/bin/mvn clean verify sonar:sonar -Dsonar.projectKey=my-project -Dsonar.projectName='MyProject'" + powershell "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json" } } }" @@ -668,18 +756,18 @@ exports[`github: can select devops platform and complete all the steps with copy exports[`github: can select devops platform and complete all the steps with copying code snippets: c++ (automatic and other): build tools sonar-project.properties code 2`] = `"sonar.projectKey=my-project"`; -exports[`github: can select devops platform and complete all the steps with copying code snippets: c++ (manual) and objectivec: linux jenkinsfile 1`] = ` +exports[`github: can select devops platform and complete all the steps with copying code snippets: c++ (manual) and objectivec: linux arm64 jenkinsfile 1`] = ` "node { stage('SCM') { checkout scm } stage('Download Build Wrapper') { sh "mkdir -p .sonar" - sh "curl -sSLo build-wrapper-linux-x86.zip http://localhost:9000/static/cpp/build-wrapper-linux-x86.zip" - sh "unzip -o build-wrapper-linux-x86.zip -d .sonar" + sh "curl -sSLo build-wrapper-linux-aarch64.zip http://localhost:9000/static/cpp/build-wrapper-linux-aarch64.zip" + sh "unzip -o build-wrapper-linux-aarch64.zip -d .sonar" } stage('Build') { - sh ".sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output <your clean build command>" + sh ".sonar/build-wrapper-linux-aarch64/build-wrapper-linux-aarch64 --out-dir bw-output <your clean build command>" } stage('SonarQube Analysis') { def scannerHome = tool 'SonarScanner'; @@ -690,7 +778,7 @@ exports[`github: can select devops platform and complete all the steps with copy }" `; -exports[`github: can select devops platform and complete all the steps with copying code snippets: c++ (manual) and objectivec: linux jenkinsfile 2`] = ` +exports[`github: can select devops platform and complete all the steps with copying code snippets: c++ (manual) and objectivec: linux jenkinsfile 1`] = ` "node { stage('SCM') { checkout scm @@ -738,32 +826,6 @@ exports[`github: can select devops platform and complete all the steps with copy }" `; -exports[`github: can select devops platform and complete all the steps with copying code snippets: c++ (manual) and objectivec: macos jenkinsfile 2`] = ` -"node { - stage('SCM') { - checkout scm - } - stage('Download Build Wrapper') { - sh ''' - mkdir -p .sonar - curl -sSLo build-wrapper-macosx-x86.zip http://localhost:9000/static/cpp/build-wrapper-macosx-x86.zip - unzip -o build-wrapper-macosx-x86.zip -d .sonar - ''' - } - stage('Build') { - sh ''' - .sonar/build-wrapper-macosx-x86/build-wrapper-macosx-x86 --out-dir bw-output <your clean build command> - ''' - } - stage('SonarQube Analysis') { - def scannerHome = tool 'SonarScanner'; - withSonarQubeEnv() { - sh "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json" - } - } -}" -`; - exports[`github: can select devops platform and complete all the steps with copying code snippets: c++ (manual) and objectivec: windows jenkinsfile 1`] = ` "node { stage('SCM') { @@ -796,79 +858,149 @@ exports[`github: can select devops platform and complete all the steps with copy }" `; -exports[`github: can select devops platform and complete all the steps with copying code snippets: c++ (manual) and objectivec: windows jenkinsfile 2`] = ` +exports[`github: can select devops platform and complete all the steps with copying code snippets: gradle jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + withSonarQubeEnv() { + sh "./gradlew sonar" + } + } +}" +`; + +exports[`github: can select devops platform and complete all the steps with copying code snippets: jenkins url 1`] = `"***JENKINS_SERVER_URL***/github-webhook/"`; + +exports[`github: can select devops platform and complete all the steps with copying code snippets: linux dotnet core jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner for .NET' + withSonarQubeEnv() { + sh "dotnet \${scannerHome}/SonarScanner.MSBuild.dll begin /k:\\"my-project\\"" + sh "dotnet build" + sh "dotnet \${scannerHome}/SonarScanner.MSBuild.dll end" + } + } +} +" +`; + +exports[`github: can select devops platform and complete all the steps with copying code snippets: maven jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def mvn = tool 'Default Maven'; + withSonarQubeEnv() { + sh "\${mvn}/bin/mvn clean verify sonar:sonar -Dsonar.projectKey=my-project -Dsonar.projectName='MyProject'" + } + } +}" +`; + +exports[`github: can select devops platform and complete all the steps with copying code snippets: objectivec: linux arm64 jenkinsfile 1`] = ` "node { stage('SCM') { checkout scm } stage('Download Build Wrapper') { - powershell ''' - $path = "$HOME/.sonar/build-wrapper-win-x86.zip" - rm build-wrapper-win-x86 -Recurse -Force -ErrorAction SilentlyContinue - rm $path -Force -ErrorAction SilentlyContinue - mkdir $HOME/.sonar - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - (New-Object System.Net.WebClient).DownloadFile(http://localhost:9000/static/cpp/build-wrapper-win-x86.zip", $path) - Add-Type -AssemblyName System.IO.Compression.FileSystem - [System.IO.Compression.ZipFile]::ExtractToDirectory($path, "$HOME/.sonar") - ''' + sh "mkdir -p .sonar" + sh "curl -sSLo build-wrapper-linux-aarch64.zip http://localhost:9000/static/cpp/build-wrapper-linux-aarch64.zip" + sh "unzip -o build-wrapper-linux-aarch64.zip -d .sonar" } stage('Build') { - powershell ''' - $env:Path += ";$HOME/.sonar/build-wrapper-win-x86" - build-wrapper-win-x86-64 --out-dir bw-output <your clean build command> - ''' + sh ".sonar/build-wrapper-linux-aarch64/build-wrapper-linux-aarch64 --out-dir bw-output <your clean build command>" } stage('SonarQube Analysis') { def scannerHome = tool 'SonarScanner'; withSonarQubeEnv() { - powershell "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json" + sh "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json" } } }" `; -exports[`github: can select devops platform and complete all the steps with copying code snippets: gradle jenkinsfile 1`] = ` +exports[`github: can select devops platform and complete all the steps with copying code snippets: objectivec: linux jenkinsfile 1`] = ` "node { stage('SCM') { checkout scm } + stage('Download Build Wrapper') { + sh "mkdir -p .sonar" + sh "curl -sSLo build-wrapper-linux-x86.zip http://localhost:9000/static/cpp/build-wrapper-linux-x86.zip" + sh "unzip -o build-wrapper-linux-x86.zip -d .sonar" + } + stage('Build') { + sh ".sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output <your clean build command>" + } stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner'; withSonarQubeEnv() { - sh "./gradlew sonar" + sh "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json" } } }" `; -exports[`github: can select devops platform and complete all the steps with copying code snippets: jenkins url 1`] = `"***JENKINS_SERVER_URL***/github-webhook/"`; - -exports[`github: can select devops platform and complete all the steps with copying code snippets: linux dotnet core jenkinsfile 1`] = ` +exports[`github: can select devops platform and complete all the steps with copying code snippets: objectivec: macos jenkinsfile 1`] = ` "node { stage('SCM') { checkout scm } + stage('Download Build Wrapper') { + sh ''' + mkdir -p .sonar + curl -sSLo build-wrapper-macosx-x86.zip http://localhost:9000/static/cpp/build-wrapper-macosx-x86.zip + unzip -o build-wrapper-macosx-x86.zip -d .sonar + ''' + } + stage('Build') { + sh ''' + .sonar/build-wrapper-macosx-x86/build-wrapper-macosx-x86 --out-dir bw-output <your clean build command> + ''' + } stage('SonarQube Analysis') { - def scannerHome = tool 'SonarScanner for .NET' + def scannerHome = tool 'SonarScanner'; withSonarQubeEnv() { - sh "dotnet \${scannerHome}/SonarScanner.MSBuild.dll begin /k:\\"my-project\\"" - sh "dotnet build" - sh "dotnet \${scannerHome}/SonarScanner.MSBuild.dll end" + sh "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json" } } -} -" +}" `; -exports[`github: can select devops platform and complete all the steps with copying code snippets: maven jenkinsfile 1`] = ` +exports[`github: can select devops platform and complete all the steps with copying code snippets: objectivec: windows jenkinsfile 1`] = ` "node { stage('SCM') { checkout scm } + stage('Download Build Wrapper') { + powershell ''' + $path = "$HOME/.sonar/build-wrapper-win-x86.zip" + rm build-wrapper-win-x86 -Recurse -Force -ErrorAction SilentlyContinue + rm $path -Force -ErrorAction SilentlyContinue + mkdir $HOME/.sonar + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + (New-Object System.Net.WebClient).DownloadFile(http://localhost:9000/static/cpp/build-wrapper-win-x86.zip", $path) + Add-Type -AssemblyName System.IO.Compression.FileSystem + [System.IO.Compression.ZipFile]::ExtractToDirectory($path, "$HOME/.sonar") + ''' + } + stage('Build') { + powershell ''' + $env:Path += ";$HOME/.sonar/build-wrapper-win-x86" + build-wrapper-win-x86-64 --out-dir bw-output <your clean build command> + ''' + } stage('SonarQube Analysis') { - def mvn = tool 'Default Maven'; + def scannerHome = tool 'SonarScanner'; withSonarQubeEnv() { - sh "\${mvn}/bin/mvn clean verify sonar:sonar -Dsonar.projectKey=my-project -Dsonar.projectName='MyProject'" + powershell "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json" } } }" @@ -973,18 +1105,18 @@ exports[`gitlab: can select devops platform and complete all the steps with copy exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: c++ (automatic and other): build tools sonar-project.properties code 2`] = `"sonar.projectKey=my-project"`; -exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: c++ (manual) and objectivec: linux jenkinsfile 1`] = ` +exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: c++ (manual) and objectivec: linux arm64 jenkinsfile 1`] = ` "node { stage('SCM') { checkout scm } stage('Download Build Wrapper') { sh "mkdir -p .sonar" - sh "curl -sSLo build-wrapper-linux-x86.zip http://localhost:9000/static/cpp/build-wrapper-linux-x86.zip" - sh "unzip -o build-wrapper-linux-x86.zip -d .sonar" + sh "curl -sSLo build-wrapper-linux-aarch64.zip http://localhost:9000/static/cpp/build-wrapper-linux-aarch64.zip" + sh "unzip -o build-wrapper-linux-aarch64.zip -d .sonar" } stage('Build') { - sh ".sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output <your clean build command>" + sh ".sonar/build-wrapper-linux-aarch64/build-wrapper-linux-aarch64 --out-dir bw-output <your clean build command>" } stage('SonarQube Analysis') { def scannerHome = tool 'SonarScanner'; @@ -995,7 +1127,7 @@ exports[`gitlab: can select devops platform and complete all the steps with copy }" `; -exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: c++ (manual) and objectivec: linux jenkinsfile 2`] = ` +exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: c++ (manual) and objectivec: linux jenkinsfile 1`] = ` "node { stage('SCM') { checkout scm @@ -1043,32 +1175,6 @@ exports[`gitlab: can select devops platform and complete all the steps with copy }" `; -exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: c++ (manual) and objectivec: macos jenkinsfile 2`] = ` -"node { - stage('SCM') { - checkout scm - } - stage('Download Build Wrapper') { - sh ''' - mkdir -p .sonar - curl -sSLo build-wrapper-macosx-x86.zip http://localhost:9000/static/cpp/build-wrapper-macosx-x86.zip - unzip -o build-wrapper-macosx-x86.zip -d .sonar - ''' - } - stage('Build') { - sh ''' - .sonar/build-wrapper-macosx-x86/build-wrapper-macosx-x86 --out-dir bw-output <your clean build command> - ''' - } - stage('SonarQube Analysis') { - def scannerHome = tool 'SonarScanner'; - withSonarQubeEnv() { - sh "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json" - } - } -}" -`; - exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: c++ (manual) and objectivec: windows jenkinsfile 1`] = ` "node { stage('SCM') { @@ -1101,79 +1207,149 @@ exports[`gitlab: can select devops platform and complete all the steps with copy }" `; -exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: c++ (manual) and objectivec: windows jenkinsfile 2`] = ` +exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: gradle jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + withSonarQubeEnv() { + sh "./gradlew sonar" + } + } +}" +`; + +exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: jenkins url 1`] = `"***JENKINS_SERVER_URL***/gitlab-webhook/post"`; + +exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: linux dotnet core jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner for .NET' + withSonarQubeEnv() { + sh "dotnet \${scannerHome}/SonarScanner.MSBuild.dll begin /k:\\"my-project\\"" + sh "dotnet build" + sh "dotnet \${scannerHome}/SonarScanner.MSBuild.dll end" + } + } +} +" +`; + +exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: maven jenkinsfile 1`] = ` +"node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def mvn = tool 'Default Maven'; + withSonarQubeEnv() { + sh "\${mvn}/bin/mvn clean verify sonar:sonar -Dsonar.projectKey=my-project -Dsonar.projectName='MyProject'" + } + } +}" +`; + +exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: objectivec: linux arm64 jenkinsfile 1`] = ` "node { stage('SCM') { checkout scm } stage('Download Build Wrapper') { - powershell ''' - $path = "$HOME/.sonar/build-wrapper-win-x86.zip" - rm build-wrapper-win-x86 -Recurse -Force -ErrorAction SilentlyContinue - rm $path -Force -ErrorAction SilentlyContinue - mkdir $HOME/.sonar - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - (New-Object System.Net.WebClient).DownloadFile(http://localhost:9000/static/cpp/build-wrapper-win-x86.zip", $path) - Add-Type -AssemblyName System.IO.Compression.FileSystem - [System.IO.Compression.ZipFile]::ExtractToDirectory($path, "$HOME/.sonar") - ''' + sh "mkdir -p .sonar" + sh "curl -sSLo build-wrapper-linux-aarch64.zip http://localhost:9000/static/cpp/build-wrapper-linux-aarch64.zip" + sh "unzip -o build-wrapper-linux-aarch64.zip -d .sonar" } stage('Build') { - powershell ''' - $env:Path += ";$HOME/.sonar/build-wrapper-win-x86" - build-wrapper-win-x86-64 --out-dir bw-output <your clean build command> - ''' + sh ".sonar/build-wrapper-linux-aarch64/build-wrapper-linux-aarch64 --out-dir bw-output <your clean build command>" } stage('SonarQube Analysis') { def scannerHome = tool 'SonarScanner'; withSonarQubeEnv() { - powershell "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json" + sh "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json" } } }" `; -exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: gradle jenkinsfile 1`] = ` +exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: objectivec: linux jenkinsfile 1`] = ` "node { stage('SCM') { checkout scm } + stage('Download Build Wrapper') { + sh "mkdir -p .sonar" + sh "curl -sSLo build-wrapper-linux-x86.zip http://localhost:9000/static/cpp/build-wrapper-linux-x86.zip" + sh "unzip -o build-wrapper-linux-x86.zip -d .sonar" + } + stage('Build') { + sh ".sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output <your clean build command>" + } stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner'; withSonarQubeEnv() { - sh "./gradlew sonar" + sh "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json" } } }" `; -exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: jenkins url 1`] = `"***JENKINS_SERVER_URL***/gitlab-webhook/post"`; - -exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: linux dotnet core jenkinsfile 1`] = ` +exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: objectivec: macos jenkinsfile 1`] = ` "node { stage('SCM') { checkout scm } + stage('Download Build Wrapper') { + sh ''' + mkdir -p .sonar + curl -sSLo build-wrapper-macosx-x86.zip http://localhost:9000/static/cpp/build-wrapper-macosx-x86.zip + unzip -o build-wrapper-macosx-x86.zip -d .sonar + ''' + } + stage('Build') { + sh ''' + .sonar/build-wrapper-macosx-x86/build-wrapper-macosx-x86 --out-dir bw-output <your clean build command> + ''' + } stage('SonarQube Analysis') { - def scannerHome = tool 'SonarScanner for .NET' + def scannerHome = tool 'SonarScanner'; withSonarQubeEnv() { - sh "dotnet \${scannerHome}/SonarScanner.MSBuild.dll begin /k:\\"my-project\\"" - sh "dotnet build" - sh "dotnet \${scannerHome}/SonarScanner.MSBuild.dll end" + sh "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json" } } -} -" +}" `; -exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: maven jenkinsfile 1`] = ` +exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: objectivec: windows jenkinsfile 1`] = ` "node { stage('SCM') { checkout scm } + stage('Download Build Wrapper') { + powershell ''' + $path = "$HOME/.sonar/build-wrapper-win-x86.zip" + rm build-wrapper-win-x86 -Recurse -Force -ErrorAction SilentlyContinue + rm $path -Force -ErrorAction SilentlyContinue + mkdir $HOME/.sonar + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + (New-Object System.Net.WebClient).DownloadFile(http://localhost:9000/static/cpp/build-wrapper-win-x86.zip", $path) + Add-Type -AssemblyName System.IO.Compression.FileSystem + [System.IO.Compression.ZipFile]::ExtractToDirectory($path, "$HOME/.sonar") + ''' + } + stage('Build') { + powershell ''' + $env:Path += ";$HOME/.sonar/build-wrapper-win-x86" + build-wrapper-win-x86-64 --out-dir bw-output <your clean build command> + ''' + } stage('SonarQube Analysis') { - def mvn = tool 'Default Maven'; + def scannerHome = tool 'SonarScanner'; withSonarQubeEnv() { - sh "\${mvn}/bin/mvn clean verify sonar:sonar -Dsonar.projectKey=my-project -Dsonar.projectName='MyProject'" + powershell "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json" } } }" diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/CFamily.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/CFamily.tsx index cef2de8da04..bdefe1c1706 100644 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/CFamily.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/CFamily.tsx @@ -25,23 +25,27 @@ import { CompilationInfo } from '../../components/CompilationInfo'; import DefaultProjectKey from '../../components/DefaultProjectKey'; import GithubCFamilyExampleRepositories from '../../components/GithubCFamilyExampleRepositories'; import RenderOptions from '../../components/RenderOptions'; -import { AutoConfig, BuildTools, OSs, TutorialModes } from '../../types'; +import { Arch, AutoConfig, BuildTools, OSs, TutorialModes } from '../../types'; +import { getBuildWrapperExecutableLinux, getBuildWrapperFolderLinux } from '../../utils'; import { LanguageProps } from '../JenkinsStep'; import CreateJenkinsfileBulletPoint from './CreateJenkinsfileBulletPoint'; import Other from './Other'; -const YAML_MAP: Record<OSs, (baseUrl: string) => string> = { - [OSs.Linux]: (baseUrl) => `node { +const YAML_MAP: Record<OSs, (baseUrl: string, arch: Arch) => string> = { + [OSs.Linux]: (baseUrl, arch) => { + const buildWrapperFolder = getBuildWrapperFolderLinux(arch); + const buildWrapperExecutable = getBuildWrapperExecutableLinux(arch); + return `node { stage('SCM') { checkout scm } stage('Download Build Wrapper') { sh "mkdir -p .sonar" - sh "curl -sSLo build-wrapper-linux-x86.zip ${baseUrl}/static/cpp/build-wrapper-linux-x86.zip" - sh "unzip -o build-wrapper-linux-x86.zip -d .sonar" + sh "curl -sSLo ${buildWrapperFolder}.zip ${baseUrl}/static/cpp/${buildWrapperFolder}.zip" + sh "unzip -o ${buildWrapperFolder}.zip -d .sonar" } stage('Build') { - sh ".sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output <your clean build command>" + sh ".sonar/${buildWrapperFolder}/${buildWrapperExecutable} --out-dir bw-output <your clean build command>" } stage('SonarQube Analysis') { def scannerHome = tool 'SonarScanner'; @@ -49,8 +53,9 @@ const YAML_MAP: Record<OSs, (baseUrl: string) => string> = { sh "\${scannerHome}/bin/sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json" } } -}`, - [OSs.MacOS]: (baseUrl) => `node { +}`; + }, + [OSs.MacOS]: (baseUrl, _) => `node { stage('SCM') { checkout scm } @@ -73,7 +78,7 @@ const YAML_MAP: Record<OSs, (baseUrl: string) => string> = { } } }`, - [OSs.Windows]: (baseUrl) => `node { + [OSs.Windows]: (baseUrl, _) => `node { stage('SCM') { checkout scm } @@ -107,6 +112,7 @@ const YAML_MAP: Record<OSs, (baseUrl: string) => string> = { export default function CFamily(props: Readonly<LanguageProps>) { const { baseUrl, config, component } = props; const [os, setOs] = React.useState<OSs>(OSs.Linux); + const [arch, setArch] = React.useState<Arch>(Arch.X86_64); if (config.buildTool === BuildTools.Cpp && config.autoConfig === AutoConfig.Automatic) { return <Other {...props} />; @@ -131,11 +137,25 @@ export default function CFamily(props: Readonly<LanguageProps>) { className="sw-my-4 sw-w-abs-600" /> } + {os === OSs.Linux && ( + <> + <div className="sw-mt-4"> + {translate('onboarding.tutorial.with.azure_pipelines.architecture')} + </div> + <RenderOptions + label={translate('onboarding.tutorial.with.azure_pipelines.architecture')} + checked={arch} + onCheck={(value: Arch) => setArch(value)} + optionLabelKey="onboarding.build.other.architecture" + options={[Arch.X86_64, Arch.Arm64]} + /> + </> + )} </NumberedListItem> { <CreateJenkinsfileBulletPoint alertTranslationKeyPart="onboarding.tutorial.with.jenkins.jenkinsfile.other.step3" - snippet={YAML_MAP[os](baseUrl)} + snippet={YAML_MAP[os](baseUrl, arch)} > <CompilationInfo /> </CreateJenkinsfileBulletPoint> diff --git a/server/sonar-web/src/main/js/components/tutorials/other/BuildToolForm.tsx b/server/sonar-web/src/main/js/components/tutorials/other/BuildToolForm.tsx index f4bc5dab064..e5a51052430 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/BuildToolForm.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/other/BuildToolForm.tsx @@ -23,19 +23,21 @@ import { withCLanguageFeature } from '../../hoc/withCLanguageFeature'; import BuildConfigSelection from '../components/BuildConfigSelection'; import GithubCFamilyExampleRepositories from '../components/GithubCFamilyExampleRepositories'; import RenderOptions from '../components/RenderOptions'; -import { BuildTools, OSs, TutorialConfig, TutorialModes } from '../types'; -import { shouldShowGithubCFamilyExampleRepositories } from '../utils'; +import { Arch, BuildTools, OSs, TutorialConfig, TutorialModes } from '../types'; +import { shouldShowArchSelector, shouldShowGithubCFamilyExampleRepositories } from '../utils'; interface Props { + arch?: Arch; config: TutorialConfig; hasCLanguageFeature: boolean; os?: OSs; + setArch: (arch: Arch) => void; setConfig: (config: TutorialConfig) => void; setOs: (os: OSs) => void; } export function BuildToolForm(props: Readonly<Props>) { - const { config, setConfig, os, setOs, hasCLanguageFeature } = props; + const { config, setConfig, os, setOs, arch, setArch, hasCLanguageFeature } = props; function handleConfigChange(newConfig: TutorialConfig) { const selectOsByDefault = (newConfig.buildTool === BuildTools.Cpp || @@ -73,6 +75,16 @@ export function BuildToolForm(props: Readonly<Props>) { titleLabelKey="onboarding.build.other.os" /> )} + {shouldShowArchSelector(os, config) && ( + <RenderOptions + label={translate('onboarding.build.other.architecture')} + checked={arch} + onCheck={(value: Arch) => setArch(value)} + optionLabelKey="onboarding.build.other.architecture" + options={[Arch.X86_64, Arch.Arm64]} + titleLabelKey="onboarding.build.other.architecture" + /> + )} {shouldShowGithubCFamilyExampleRepositories(config) && ( <GithubCFamilyExampleRepositories ci={TutorialModes.OtherCI} diff --git a/server/sonar-web/src/main/js/components/tutorials/other/ProjectAnalysisStep.tsx b/server/sonar-web/src/main/js/components/tutorials/other/ProjectAnalysisStep.tsx index 9d5e24d711a..e40181969a7 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/ProjectAnalysisStep.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/other/ProjectAnalysisStep.tsx @@ -22,7 +22,7 @@ import * as React from 'react'; import { translate } from '../../../helpers/l10n'; import { Component } from '../../../types/types'; import Step from '../components/Step'; -import { OSs, TutorialConfig } from '../types'; +import { Arch, OSs, TutorialConfig } from '../types'; import BuildToolForm from './BuildToolForm'; import AnalysisCommand from './commands/AnalysisCommand'; @@ -40,17 +40,26 @@ export default function ProjectAnalysisStep(props: Readonly<Props>) { const [config, setConfig] = React.useState<TutorialConfig>({}); const [os, setOs] = React.useState<OSs>(OSs.Linux); + const [arch, setArch] = React.useState<Arch>(Arch.X86_64); function renderForm() { return ( <div className="sw-pb-4"> - <BuildToolForm config={config} setConfig={setConfig} os={os} setOs={setOs} /> + <BuildToolForm + config={config} + setConfig={setConfig} + os={os} + setOs={setOs} + arch={arch} + setArch={setArch} + /> {config && ( <div className="sw-mt-4"> <AnalysisCommand config={config} os={os} + arch={arch} component={component} baseUrl={baseUrl} isLocal={isLocal} diff --git a/server/sonar-web/src/main/js/components/tutorials/other/__tests__/OtherTutorial-it.tsx b/server/sonar-web/src/main/js/components/tutorials/other/__tests__/OtherTutorial-it.tsx index f366797deac..00616b9b63d 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/__tests__/OtherTutorial-it.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/other/__tests__/OtherTutorial-it.tsx @@ -136,29 +136,116 @@ it('can choose build tools and copy provided settings', async () => { 'c++ (automatic) and other macos: execute scanner', ); - // C++ - Linux + // C++ - Linux (x86_64) await user.click(ui.autoConfigManual.get()); await user.click(ui.linuxButton.get()); expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot( + 'c++ (manual) linux: download build wrapper', + ); + expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot( + 'c++ (manual) linux: download scanner', + ); + expect(getCopyToClipboardValue(2, 'Copy')).toMatchSnapshot( 'c++ (manual) linux: execute build wrapper', ); - expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot('c++ (manual) linux: execute scanner'); + expect(getCopyToClipboardValue(3, 'Copy')).toMatchSnapshot('c++ (manual) linux: execute scanner'); + + // C++ - Linux (ARM64) + await user.click(ui.arm64Button.get()); + expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot( + 'c++ (manual) linux arm64: download build wrapper', + ); + expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot( + 'c++ (manual) linux arm64: download scanner', + ); + expect(getCopyToClipboardValue(2, 'Copy')).toMatchSnapshot( + 'c++ (manual) linux arm64: execute build wrapper', + ); + expect(getCopyToClipboardValue(3, 'Copy')).toMatchSnapshot( + 'c++ (manual) linux arm64: execute scanner', + ); // C++ - Windows await user.click(ui.windowsButton.get()); expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot( - 'c++ (manual) windows: execute build wrapper', + 'c++ (manual) windows: download build wrapper', ); expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot( + 'c++ (manual) windows: download scanner', + ); + expect(getCopyToClipboardValue(2, 'Copy')).toMatchSnapshot( + 'c++ (manual) windows: execute build wrapper', + ); + expect(getCopyToClipboardValue(3, 'Copy')).toMatchSnapshot( 'c++ (manual) windows: execute scanner', ); // C++ - MacOS await user.click(ui.macosButton.get()); expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot( + 'c++ (manual) macos: download build wrapper', + ); + expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot( + 'c++ (manual) macos: download scanner', + ); + expect(getCopyToClipboardValue(2, 'Copy')).toMatchSnapshot( 'c++ (manual) macos: execute build wrapper', ); - expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot('c++ (manual) macos: execute scanner'); + expect(getCopyToClipboardValue(3, 'Copy')).toMatchSnapshot('c++ (manual) macos: execute scanner'); + + // Objective-C - Linux (x86_64) + await user.click(ui.objCBuildButton.get()); + await user.click(ui.linuxButton.get()); + await user.click(ui.x86_64Button.get()); + expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot( + 'objective-c linux: download build wrapper', + ); + expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot('objective-c linux: download scanner'); + expect(getCopyToClipboardValue(2, 'Copy')).toMatchSnapshot( + 'objective-c linux: execute build wrapper', + ); + expect(getCopyToClipboardValue(3, 'Copy')).toMatchSnapshot('objective-c linux: execute scanner'); + + // Objective-C - Linux (ARM64) + await user.click(ui.arm64Button.get()); + expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot( + 'objective-c linux arm64: download build wrapper', + ); + expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot( + 'objective-c linux arm64: download scanner', + ); + expect(getCopyToClipboardValue(2, 'Copy')).toMatchSnapshot( + 'objective-c linux arm64: execute build wrapper', + ); + expect(getCopyToClipboardValue(3, 'Copy')).toMatchSnapshot( + 'objective-c linux arm64: execute scanner', + ); + + // Objective-C - Windows + await user.click(ui.windowsButton.get()); + expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot( + 'objective-c windows: download build wrapper', + ); + expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot( + 'objective-c windows: download scanner', + ); + expect(getCopyToClipboardValue(2, 'Copy')).toMatchSnapshot( + 'objective-c windows: execute build wrapper', + ); + expect(getCopyToClipboardValue(3, 'Copy')).toMatchSnapshot( + 'objective-c windows: execute scanner', + ); + + // Objective-C - MacOS + await user.click(ui.macosButton.get()); + expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot( + 'objective-c macos: download build wrapper', + ); + expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot('objective-c macos: download scanner'); + expect(getCopyToClipboardValue(2, 'Copy')).toMatchSnapshot( + 'objective-c macos: execute build wrapper', + ); + expect(getCopyToClipboardValue(3, 'Copy')).toMatchSnapshot('objective-c macos: execute scanner'); // Other - Linux await user.click(ui.otherBuildButton.get()); diff --git a/server/sonar-web/src/main/js/components/tutorials/other/__tests__/__snapshots__/OtherTutorial-it.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/other/__tests__/__snapshots__/OtherTutorial-it.tsx.snap index a5e42283955..b38254c0548 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/__tests__/__snapshots__/OtherTutorial-it.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/other/__tests__/__snapshots__/OtherTutorial-it.tsx.snap @@ -51,14 +51,41 @@ $env:SONAR_SCANNER_OPTS="-server" " `; -exports[`can choose build tools and copy provided settings: c++ (manual) linux: execute build wrapper 1`] = ` +exports[`can choose build tools and copy provided settings: c++ (manual) linux arm64: download build wrapper 1`] = ` +"curl --create-dirs -sSLo $HOME/.sonar/build-wrapper-linux-aarch64.zip http://localhost:9000/static/cpp/build-wrapper-linux-aarch64.zip +unzip -o $HOME/.sonar/build-wrapper-linux-aarch64.zip -d $HOME/.sonar/ +export PATH=$HOME/.sonar/build-wrapper-linux-aarch64:$PATH +" +`; + +exports[`can choose build tools and copy provided settings: c++ (manual) linux arm64: download scanner 1`] = ` +"export SONAR_SCANNER_VERSION=5.0.1.3006 +export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux +curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip +unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ +export PATH=$SONAR_SCANNER_HOME/bin:$PATH +export SONAR_SCANNER_OPTS="-server" +" +`; + +exports[`can choose build tools and copy provided settings: c++ (manual) linux arm64: execute build wrapper 1`] = `"build-wrapper-linux-aarch64 --out-dir bw-output onboarding.analysis.build_wrapper.execute_build_command"`; + +exports[`can choose build tools and copy provided settings: c++ (manual) linux arm64: execute scanner 1`] = ` +"sonar-scanner \\ + -Dsonar.projectKey=my-project \\ + -Dsonar.sources=. \\ + -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json \\ + -Dsonar.host.url=http://localhost:9000" +`; + +exports[`can choose build tools and copy provided settings: c++ (manual) linux: download build wrapper 1`] = ` "curl --create-dirs -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip http://localhost:9000/static/cpp/build-wrapper-linux-x86.zip unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/ export PATH=$HOME/.sonar/build-wrapper-linux-x86:$PATH " `; -exports[`can choose build tools and copy provided settings: c++ (manual) linux: execute scanner 1`] = ` +exports[`can choose build tools and copy provided settings: c++ (manual) linux: download scanner 1`] = ` "export SONAR_SCANNER_VERSION=5.0.1.3006 export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip @@ -68,14 +95,24 @@ export SONAR_SCANNER_OPTS="-server" " `; -exports[`can choose build tools and copy provided settings: c++ (manual) macos: execute build wrapper 1`] = ` +exports[`can choose build tools and copy provided settings: c++ (manual) linux: execute build wrapper 1`] = `"build-wrapper-linux-x86-64 --out-dir bw-output onboarding.analysis.build_wrapper.execute_build_command"`; + +exports[`can choose build tools and copy provided settings: c++ (manual) linux: execute scanner 1`] = ` +"sonar-scanner \\ + -Dsonar.projectKey=my-project \\ + -Dsonar.sources=. \\ + -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json \\ + -Dsonar.host.url=http://localhost:9000" +`; + +exports[`can choose build tools and copy provided settings: c++ (manual) macos: download build wrapper 1`] = ` "curl --create-dirs -sSLo $HOME/.sonar/build-wrapper-macosx-x86.zip http://localhost:9000/static/cpp/build-wrapper-macosx-x86.zip unzip -o $HOME/.sonar/build-wrapper-macosx-x86.zip -d $HOME/.sonar/ export PATH=$HOME/.sonar/build-wrapper-macosx-x86:$PATH " `; -exports[`can choose build tools and copy provided settings: c++ (manual) macos: execute scanner 1`] = ` +exports[`can choose build tools and copy provided settings: c++ (manual) macos: download scanner 1`] = ` "export SONAR_SCANNER_VERSION=5.0.1.3006 export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-macosx curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-macosx.zip @@ -85,7 +122,17 @@ export SONAR_SCANNER_OPTS="-server" " `; -exports[`can choose build tools and copy provided settings: c++ (manual) windows: execute build wrapper 1`] = ` +exports[`can choose build tools and copy provided settings: c++ (manual) macos: execute build wrapper 1`] = `"build-wrapper-macosx-x86 --out-dir bw-output onboarding.analysis.build_wrapper.execute_build_command"`; + +exports[`can choose build tools and copy provided settings: c++ (manual) macos: execute scanner 1`] = ` +"sonar-scanner \\ + -Dsonar.projectKey=my-project \\ + -Dsonar.sources=. \\ + -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json \\ + -Dsonar.host.url=http://localhost:9000" +`; + +exports[`can choose build tools and copy provided settings: c++ (manual) windows: download build wrapper 1`] = ` "$env:SONAR_DIRECTORY = [System.IO.Path]::Combine($(get-location).Path,".sonar") rm "$env:SONAR_DIRECTORY/build-wrapper-win-x86" -Force -Recurse -ErrorAction SilentlyContinue New-Item -path $env:SONAR_DIRECTORY/build-wrapper-win-x86 -type directory @@ -96,7 +143,7 @@ $env:Path += ";$env:SONAR_DIRECTORY/build-wrapper-win-x86" " `; -exports[`can choose build tools and copy provided settings: c++ (manual) windows: execute scanner 1`] = ` +exports[`can choose build tools and copy provided settings: c++ (manual) windows: download scanner 1`] = ` "$env:SONAR_SCANNER_VERSION = "5.0.1.3006" $env:SONAR_DIRECTORY = [System.IO.Path]::Combine($(get-location).Path,".sonar") $env:SONAR_SCANNER_HOME = "$env:SONAR_DIRECTORY/sonar-scanner-$env:SONAR_SCANNER_VERSION-windows" @@ -111,6 +158,10 @@ $env:SONAR_SCANNER_OPTS="-server" " `; +exports[`can choose build tools and copy provided settings: c++ (manual) windows: execute build wrapper 1`] = `"build-wrapper-win-x86-64.exe --out-dir bw-output onboarding.analysis.build_wrapper.execute_build_command"`; + +exports[`can choose build tools and copy provided settings: c++ (manual) windows: execute scanner 1`] = `"sonar-scanner.bat -D"sonar.projectKey=my-project" -D"sonar.sources=." -D"sonar.cfamily.compile-commands=bw-output/compile_commands.json" -D"sonar.host.url=http://localhost:9000""`; + exports[`can choose build tools and copy provided settings: dotnet core: execute command 1 1`] = `"dotnet sonarscanner begin /k:"my-project" /d:sonar.host.url="http://localhost:9000" /d:sonar.token="generatedtoken2""`; exports[`can choose build tools and copy provided settings: dotnet core: execute command 2 1`] = `"dotnet build"`; @@ -146,3 +197,114 @@ exports[`can choose build tools and copy provided settings: maven: execute scann -Dsonar.host.url=http://localhost:9000 \\ -Dsonar.token=generatedtoken2" `; + +exports[`can choose build tools and copy provided settings: objective-c linux arm64: download build wrapper 1`] = ` +"curl --create-dirs -sSLo $HOME/.sonar/build-wrapper-linux-aarch64.zip http://localhost:9000/static/cpp/build-wrapper-linux-aarch64.zip +unzip -o $HOME/.sonar/build-wrapper-linux-aarch64.zip -d $HOME/.sonar/ +export PATH=$HOME/.sonar/build-wrapper-linux-aarch64:$PATH +" +`; + +exports[`can choose build tools and copy provided settings: objective-c linux arm64: download scanner 1`] = ` +"export SONAR_SCANNER_VERSION=5.0.1.3006 +export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux +curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip +unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ +export PATH=$SONAR_SCANNER_HOME/bin:$PATH +export SONAR_SCANNER_OPTS="-server" +" +`; + +exports[`can choose build tools and copy provided settings: objective-c linux arm64: execute build wrapper 1`] = `"build-wrapper-linux-aarch64 --out-dir bw-output onboarding.analysis.build_wrapper.execute_build_command"`; + +exports[`can choose build tools and copy provided settings: objective-c linux arm64: execute scanner 1`] = ` +"sonar-scanner \\ + -Dsonar.projectKey=my-project \\ + -Dsonar.sources=. \\ + -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json \\ + -Dsonar.host.url=http://localhost:9000" +`; + +exports[`can choose build tools and copy provided settings: objective-c linux: download build wrapper 1`] = ` +"curl --create-dirs -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip http://localhost:9000/static/cpp/build-wrapper-linux-x86.zip +unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/ +export PATH=$HOME/.sonar/build-wrapper-linux-x86:$PATH +" +`; + +exports[`can choose build tools and copy provided settings: objective-c linux: download scanner 1`] = ` +"export SONAR_SCANNER_VERSION=5.0.1.3006 +export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux +curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip +unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ +export PATH=$SONAR_SCANNER_HOME/bin:$PATH +export SONAR_SCANNER_OPTS="-server" +" +`; + +exports[`can choose build tools and copy provided settings: objective-c linux: execute build wrapper 1`] = `"build-wrapper-linux-x86-64 --out-dir bw-output onboarding.analysis.build_wrapper.execute_build_command"`; + +exports[`can choose build tools and copy provided settings: objective-c linux: execute scanner 1`] = ` +"sonar-scanner \\ + -Dsonar.projectKey=my-project \\ + -Dsonar.sources=. \\ + -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json \\ + -Dsonar.host.url=http://localhost:9000" +`; + +exports[`can choose build tools and copy provided settings: objective-c macos: download build wrapper 1`] = ` +"curl --create-dirs -sSLo $HOME/.sonar/build-wrapper-macosx-x86.zip http://localhost:9000/static/cpp/build-wrapper-macosx-x86.zip +unzip -o $HOME/.sonar/build-wrapper-macosx-x86.zip -d $HOME/.sonar/ +export PATH=$HOME/.sonar/build-wrapper-macosx-x86:$PATH +" +`; + +exports[`can choose build tools and copy provided settings: objective-c macos: download scanner 1`] = ` +"export SONAR_SCANNER_VERSION=5.0.1.3006 +export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-macosx +curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-macosx.zip +unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ +export PATH=$SONAR_SCANNER_HOME/bin:$PATH +export SONAR_SCANNER_OPTS="-server" +" +`; + +exports[`can choose build tools and copy provided settings: objective-c macos: execute build wrapper 1`] = `"build-wrapper-macosx-x86 --out-dir bw-output onboarding.analysis.build_wrapper.execute_build_command"`; + +exports[`can choose build tools and copy provided settings: objective-c macos: execute scanner 1`] = ` +"sonar-scanner \\ + -Dsonar.projectKey=my-project \\ + -Dsonar.sources=. \\ + -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json \\ + -Dsonar.host.url=http://localhost:9000" +`; + +exports[`can choose build tools and copy provided settings: objective-c windows: download build wrapper 1`] = ` +"$env:SONAR_DIRECTORY = [System.IO.Path]::Combine($(get-location).Path,".sonar") +rm "$env:SONAR_DIRECTORY/build-wrapper-win-x86" -Force -Recurse -ErrorAction SilentlyContinue +New-Item -path $env:SONAR_DIRECTORY/build-wrapper-win-x86 -type directory +(New-Object System.Net.WebClient).DownloadFile("http://localhost:9000/static/cpp/build-wrapper-win-x86.zip", "$env:SONAR_DIRECTORY/build-wrapper-win-x86.zip") +Add-Type -AssemblyName System.IO.Compression.FileSystem +[System.IO.Compression.ZipFile]::ExtractToDirectory("$env:SONAR_DIRECTORY/build-wrapper-win-x86.zip", "$env:SONAR_DIRECTORY") +$env:Path += ";$env:SONAR_DIRECTORY/build-wrapper-win-x86" +" +`; + +exports[`can choose build tools and copy provided settings: objective-c windows: download scanner 1`] = ` +"$env:SONAR_SCANNER_VERSION = "5.0.1.3006" +$env:SONAR_DIRECTORY = [System.IO.Path]::Combine($(get-location).Path,".sonar") +$env:SONAR_SCANNER_HOME = "$env:SONAR_DIRECTORY/sonar-scanner-$env:SONAR_SCANNER_VERSION-windows" +rm $env:SONAR_SCANNER_HOME -Force -Recurse -ErrorAction SilentlyContinue +New-Item -path $env:SONAR_SCANNER_HOME -type directory +(New-Object System.Net.WebClient).DownloadFile("https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$env:SONAR_SCANNER_VERSION-windows.zip", "$env:SONAR_DIRECTORY/sonar-scanner.zip") +Add-Type -AssemblyName System.IO.Compression.FileSystem +[System.IO.Compression.ZipFile]::ExtractToDirectory("$env:SONAR_DIRECTORY/sonar-scanner.zip", "$env:SONAR_DIRECTORY") +rm ./.sonar/sonar-scanner.zip -Force -ErrorAction SilentlyContinue +$env:Path += ";$env:SONAR_SCANNER_HOME/bin" +$env:SONAR_SCANNER_OPTS="-server" +" +`; + +exports[`can choose build tools and copy provided settings: objective-c windows: execute build wrapper 1`] = `"build-wrapper-win-x86-64.exe --out-dir bw-output onboarding.analysis.build_wrapper.execute_build_command"`; + +exports[`can choose build tools and copy provided settings: objective-c windows: execute scanner 1`] = `"sonar-scanner.bat -D"sonar.projectKey=my-project" -D"sonar.sources=." -D"sonar.cfamily.compile-commands=bw-output/compile_commands.json" -D"sonar.host.url=http://localhost:9000""`; diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/AnalysisCommand.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/AnalysisCommand.tsx index f8fb5b2f954..7105aeafa15 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/AnalysisCommand.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/other/commands/AnalysisCommand.tsx @@ -19,7 +19,7 @@ */ import * as React from 'react'; import { Component } from '../../../../types/types'; -import { AutoConfig, BuildTools, OSs, TutorialConfig } from '../../types'; +import { Arch, AutoConfig, BuildTools, OSs, TutorialConfig } from '../../types'; import ClangGCCCustom from './ClangGCCCommand'; import DotNet from './DotNet'; import JavaGradle from './JavaGradle'; @@ -27,6 +27,7 @@ import JavaMaven from './JavaMaven'; import Other from './Other'; export interface AnalysisCommandProps { + arch: Arch; baseUrl: string; component: Component; config: TutorialConfig; @@ -35,8 +36,8 @@ export interface AnalysisCommandProps { token?: string; } -export default function AnalysisCommand(props: AnalysisCommandProps) { - const { config, os, component, baseUrl, isLocal, token } = props; +export default function AnalysisCommand(props: Readonly<AnalysisCommandProps>) { + const { config, os, arch, component, baseUrl, isLocal, token } = props; if (typeof token === 'undefined') { return null; @@ -67,6 +68,7 @@ export default function AnalysisCommand(props: AnalysisCommandProps) { return ( <ClangGCCCustom os={os} + arch={arch} baseUrl={baseUrl} component={component} isLocal={isLocal} diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/ClangGCCCommand.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/ClangGCCCommand.tsx index 5e785c9ab0f..90dfda610b3 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/ClangGCCCommand.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/other/commands/ClangGCCCommand.tsx @@ -20,13 +20,14 @@ import * as React from 'react'; import { Component } from '../../../../types/types'; import { CompilationInfo } from '../../components/CompilationInfo'; -import { OSs } from '../../types'; +import { Arch, OSs } from '../../types'; import DownloadBuildWrapper from './DownloadBuildWrapper'; import DownloadScanner from './DownloadScanner'; import ExecBuildWrapper from './ExecBuildWrapper'; import ExecScanner from './ExecScanner'; export interface ClangGCCCustomProps { + arch: Arch; baseUrl: string; component: Component; isLocal: boolean; @@ -35,13 +36,13 @@ export interface ClangGCCCustomProps { } export default function ClangGCCCustom(props: ClangGCCCustomProps) { - const { os, baseUrl, component, isLocal, token } = props; + const { os, arch, baseUrl, component, isLocal, token } = props; return ( <div> - <DownloadBuildWrapper isLocal={isLocal} baseUrl={baseUrl} os={os} /> + <DownloadBuildWrapper isLocal={isLocal} baseUrl={baseUrl} os={os} arch={arch} /> <DownloadScanner isLocal={isLocal} os={os} token={token} /> - <ExecBuildWrapper os={os} /> + <ExecBuildWrapper os={os} arch={arch} /> <CompilationInfo /> <ExecScanner baseUrl={baseUrl} diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/DownloadBuildWrapper.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/DownloadBuildWrapper.tsx index 4aef7392bc3..d0af71072b8 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/DownloadBuildWrapper.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/other/commands/DownloadBuildWrapper.tsx @@ -23,22 +23,18 @@ import { FormattedMessage } from 'react-intl'; import { translate } from '../../../../helpers/l10n'; import { getBaseUrl } from '../../../../helpers/system'; import { InlineSnippet } from '../../components/InlineSnippet'; -import { OSs } from '../../types'; +import { Arch, OSs } from '../../types'; +import { getBuildWrapperFolder } from '../../utils'; export interface DownloadBuildWrapperProps { + arch: Arch; baseUrl: string; isLocal: boolean; os: OSs; } -const FILENAMES: { [x in OSs]: string } = { - win: 'build-wrapper-win-x86', - linux: 'build-wrapper-linux-x86', - mac: 'build-wrapper-macosx-x86', -}; - -export default function DownloadBuildWrapper(props: DownloadBuildWrapperProps) { - const { os, isLocal, baseUrl } = props; +export default function DownloadBuildWrapper(props: Readonly<DownloadBuildWrapperProps>) { + const { os, arch, isLocal, baseUrl } = props; return ( <div className="sw-mb-4"> <SubHeading className="sw-mb-2"> @@ -57,8 +53,8 @@ export default function DownloadBuildWrapper(props: DownloadBuildWrapperProps) { </p> <p className="sw-mb-2"> <DownloadButton - download={`${FILENAMES[os]}.zip`} - href={`${getBaseUrl()}/static/cpp/${FILENAMES[os]}.zip`} + download={`${getBuildWrapperFolder(os, arch)}.zip`} + href={`${getBaseUrl()}/static/cpp/${getBuildWrapperFolder(os, arch)}.zip`} rel="noopener noreferrer" target="_blank" > @@ -70,14 +66,14 @@ export default function DownloadBuildWrapper(props: DownloadBuildWrapperProps) { <CodeSnippet className="sw-p-4" language={os === OSs.Windows ? 'powershell' : 'bash'} - snippet={getRemoteDownloadSnippet(os, baseUrl)} + snippet={getRemoteDownloadSnippet(os, arch, baseUrl)} /> )} </div> ); } -function getRemoteDownloadSnippet(os: OSs, baseUrl: string) { +function getRemoteDownloadSnippet(os: OSs, arch: Arch, baseUrl: string) { if (os === OSs.Windows) { return `$env:SONAR_DIRECTORY = [System.IO.Path]::Combine($(get-location).Path,".sonar") rm "$env:SONAR_DIRECTORY/build-wrapper-win-x86" -Force -Recurse -ErrorAction SilentlyContinue @@ -88,8 +84,9 @@ Add-Type -AssemblyName System.IO.Compression.FileSystem $env:Path += ";$env:SONAR_DIRECTORY/build-wrapper-win-x86" `; } - return `curl --create-dirs -sSLo $HOME/.sonar/${FILENAMES[os]}.zip ${baseUrl}/static/cpp/${FILENAMES[os]}.zip -unzip -o $HOME/.sonar/${FILENAMES[os]}.zip -d $HOME/.sonar/ -export PATH=$HOME/.sonar/${FILENAMES[os]}:$PATH + const folder = getBuildWrapperFolder(os, arch); + return `curl --create-dirs -sSLo $HOME/.sonar/${folder}.zip ${baseUrl}/static/cpp/${folder}.zip +unzip -o $HOME/.sonar/${folder}.zip -d $HOME/.sonar/ +export PATH=$HOME/.sonar/${folder}:$PATH `; } diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/ExecBuildWrapper.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/ExecBuildWrapper.tsx index 46e23428d55..a18b91f2e91 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/ExecBuildWrapper.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/other/commands/ExecBuildWrapper.tsx @@ -24,20 +24,16 @@ import { FormattedMessage } from 'react-intl'; import { DocLink } from '../../../../helpers/doc-links'; import { useDocUrl } from '../../../../helpers/docs'; import { translate } from '../../../../helpers/l10n'; -import { OSs } from '../../types'; +import { Arch, OSs } from '../../types'; +import { getBuildWrapperExecutable } from '../../utils'; export interface ExecBuildWrapperProps { + arch: Arch; os: OSs; } -const executables: { [x in OSs]: string } = { - linux: 'build-wrapper-linux-x86-64', - win: 'build-wrapper-win-x86-64.exe', - mac: 'build-wrapper-macosx-x86', -}; - export default function ExecBuildWrapper(props: ExecBuildWrapperProps) { - const { os } = props; + const { os, arch } = props; const docUrl = useDocUrl(DocLink.CFamilyBuildWrapper); @@ -50,7 +46,7 @@ export default function ExecBuildWrapper(props: ExecBuildWrapperProps) { <CodeSnippet className="sw-px-4" isOneLine - snippet={`${executables[os]} --out-dir bw-output ${translate( + snippet={`${getBuildWrapperExecutable(os, arch)} --out-dir bw-output ${translate( 'onboarding.analysis.build_wrapper.execute_build_command', )}`} /> diff --git a/server/sonar-web/src/main/js/components/tutorials/test-utils.ts b/server/sonar-web/src/main/js/components/tutorials/test-utils.ts index 44f9de38066..c972a28c578 100644 --- a/server/sonar-web/src/main/js/components/tutorials/test-utils.ts +++ b/server/sonar-web/src/main/js/components/tutorials/test-utils.ts @@ -93,6 +93,8 @@ export function getTutorialBuildButtons() { linuxButton: byRole('radio', { name: `onboarding.build.other.os.${OSs.Linux}` }), windowsButton: byRole('radio', { name: `onboarding.build.other.os.${OSs.Windows}` }), macosButton: byRole('radio', { name: `onboarding.build.other.os.${OSs.MacOS}` }), + arm64Button: byRole('radio', { name: `onboarding.build.other.architecture.arm64` }), + x86_64Button: byRole('radio', { name: `onboarding.build.other.architecture.x86_64` }), autoConfigAutomatic: byRole('radio', { name: 'onboarding.build.cpp.autoconfig.automatic' }), autoConfigManual: byRole('radio', { name: 'onboarding.build.cpp.autoconfig.manual' }), }; diff --git a/server/sonar-web/src/main/js/components/tutorials/types.ts b/server/sonar-web/src/main/js/components/tutorials/types.ts index afb938c12b9..06783c05fbd 100644 --- a/server/sonar-web/src/main/js/components/tutorials/types.ts +++ b/server/sonar-web/src/main/js/components/tutorials/types.ts @@ -47,6 +47,11 @@ export enum OSs { MacOS = 'mac', } +export enum Arch { + X86_64 = 'x86_64', + Arm64 = 'arm64', +} + export enum AutoConfig { Automatic = 'automatic', Manual = 'manual', diff --git a/server/sonar-web/src/main/js/components/tutorials/utils.ts b/server/sonar-web/src/main/js/components/tutorials/utils.ts index 8231484984e..f5b1aa95345 100644 --- a/server/sonar-web/src/main/js/components/tutorials/utils.ts +++ b/server/sonar-web/src/main/js/components/tutorials/utils.ts @@ -21,7 +21,7 @@ import { GRADLE_SCANNER_VERSION } from '../../helpers/constants'; import { convertGithubApiUrlToLink, stripTrailingSlash } from '../../helpers/urls'; import { AlmSettingsInstance, ProjectAlmBindingResponse } from '../../types/alm-settings'; import { UserToken } from '../../types/token'; -import { AutoConfig, BuildTools, GradleBuildDSL, TutorialConfig } from './types'; +import { Arch, AutoConfig, BuildTools, GradleBuildDSL, OSs, TutorialConfig } from './types'; export function quote(os: string): (s: string) => string { return os === 'win' ? (s: string) => `"${s}"` : (s: string) => s; @@ -119,3 +119,46 @@ export function shouldShowGithubCFamilyExampleRepositories(config: TutorialConfi } return false; } + +export function shouldShowArchSelector(os: OSs | undefined, config: TutorialConfig) { + if (os !== OSs.Linux) { + return false; + } + if (!isCFamily(config.buildTool)) { + return false; + } + if (config.buildTool === BuildTools.Cpp && config.autoConfig === AutoConfig.Automatic) { + return false; + } + return true; +} + +export function getBuildWrapperFolder(os: OSs, arch?: Arch) { + if (os === OSs.Linux) { + return arch === Arch.X86_64 ? 'build-wrapper-linux-x86' : 'build-wrapper-linux-aarch64'; + } + if (os === OSs.MacOS) { + return 'build-wrapper-macosx-x86'; + } + if (os === OSs.Windows) { + return 'build-wrapper-win-x86'; + } + throw new Error(`Unsupported OS: ${os}`); +} + +export function getBuildWrapperExecutable(os: OSs, arch?: Arch) { + if (os === OSs.Linux) { + return arch === Arch.X86_64 ? 'build-wrapper-linux-x86-64' : 'build-wrapper-linux-aarch64'; + } + if (os === OSs.MacOS) { + return 'build-wrapper-macosx-x86'; + } + if (os === OSs.Windows) { + return 'build-wrapper-win-x86-64.exe'; + } + throw new Error(`Unsupported OS: ${os}`); +} + +export const getBuildWrapperFolderLinux = (arch?: Arch) => getBuildWrapperFolder(OSs.Linux, arch); +export const getBuildWrapperExecutableLinux = (arch?: Arch) => + getBuildWrapperExecutable(OSs.Linux, arch); |