aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web
diff options
context:
space:
mode:
authorEvgeny Mandrikov <138671+Godin@users.noreply.github.com>2024-09-25 21:34:08 +0200
committersonartech <sonartech@sonarsource.com>2024-09-25 20:02:55 +0000
commit8a2e844d04163b8b26cd114d353a38fb8cf9ceee (patch)
tree2836b79c68c42bc3f37cf5cdcf986b596ca03e3a /server/sonar-web
parent593b32b58586102d636c8b1b27eb256dd83582b1 (diff)
downloadsonarqube-8a2e844d04163b8b26cd114d353a38fb8cf9ceee.tar.gz
sonarqube-8a2e844d04163b8b26cd114d353a38fb8cf9ceee.zip
SONAR-23112 Add tutorials for Dart
Diffstat (limited to 'server/sonar-web')
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/AzurePipelinesTutorial-it.tsx4
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/AnalysisCommand.tsx1
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/AnalysisCommand.tsx2
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/PreambuleYaml.tsx1
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/BitbucketPipelinesTutorial-it.tsx5
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/BitbucketPipelinesTutorial-it.tsx.snap33
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Dart.ts60
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/github-action/AnalysisCommand.tsx10
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/GithubActionTutorial-it.tsx4
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/__snapshots__/GithubActionTutorial-it.tsx.snap30
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/github-action/commands/Dart.tsx92
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/gitlabci/YmlFileStep.tsx3
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/GitLabCITutorial-it.tsx5
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/GitLabCITutorial-it.tsx.snap68
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/gitlabci/commands/PipeCommand.tsx8
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/jenkins/JenkinsStep.tsx1
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/JenkinsTutorial-it.tsx5
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/JenkinsTutorial-it.tsx.snap64
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/other/BuildToolForm.tsx2
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/other/__tests__/OtherTutorial-it.tsx16
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/other/__tests__/__snapshots__/OtherTutorial-it.tsx.snap51
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/other/commands/AnalysisCommand.tsx1
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/test-utils.ts1
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/types.ts1
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/utils.ts2
25 files changed, 469 insertions, 1 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 bdb521f43ec..13b851236a7 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
@@ -117,6 +117,10 @@ it('should render correctly and allow token generation', async () => {
await user.click(getTutorialBuildButtons().macosButton.get());
assertObjCStepIsCorrectlyRendered(OSs.MacOS);
+ // Analysis step: Dart
+ await user.click(getTutorialBuildButtons().dartBuildButton.get());
+ assertOtherStepIsCorrectlyRendered();
+
// Analysis step: Other
await user.click(getTutorialBuildButtons().otherBuildButton.get());
assertOtherStepIsCorrectlyRendered();
diff --git a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/AnalysisCommand.tsx b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/AnalysisCommand.tsx
index 32d77e59a03..b28e92c5cc0 100644
--- a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/AnalysisCommand.tsx
+++ b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/AnalysisCommand.tsx
@@ -53,6 +53,7 @@ export default function AnalysisCommand(props: AnalysisCommandProps) {
case BuildTools.ObjectiveC:
return <ClangGCC config={config} projectKey={projectKey} />;
+ case BuildTools.Dart:
case BuildTools.Other:
return <Other projectKey={projectKey} />;
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 fa956930e0b..bc0bfade9c9 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
@@ -30,6 +30,7 @@ import { Arch, BuildTools, TutorialConfig } from '../types';
import { isCFamily } from '../utils';
import { PreambuleYaml } from './PreambuleYaml';
import cFamilyExample from './commands/CFamily';
+import dartExample from './commands/Dart';
import dotNetExample from './commands/DotNet';
import gradleExample from './commands/Gradle';
import mavenExample from './commands/Maven';
@@ -57,6 +58,7 @@ const YamlTemplate: Dictionary<BuildToolExampleBuilder> = {
[BuildTools.DotNet]: dotNetExample,
[BuildTools.Cpp]: cFamilyExample,
[BuildTools.ObjectiveC]: cFamilyExample,
+ [BuildTools.Dart]: dartExample,
[BuildTools.Other]: othersExample,
};
diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/PreambuleYaml.tsx b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/PreambuleYaml.tsx
index 83222ccbe61..c8d40198f57 100644
--- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/PreambuleYaml.tsx
+++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/PreambuleYaml.tsx
@@ -35,6 +35,7 @@ export function PreambuleYaml(props: PreambuleYamlProps) {
return <GradleBuild component={component} />;
case BuildTools.Cpp:
case BuildTools.ObjectiveC:
+ case BuildTools.Dart:
case BuildTools.Other:
return <DefaultProjectKey component={component} />;
default:
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 5efadd4646c..54ecf78154a 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
@@ -128,6 +128,11 @@ it('should follow and complete all steps', async () => {
'C++ (manual arm64) and Objective-C: sonar-project.properties',
);
+ // Dart
+ await user.click(ui.dartBuildButton.get());
+ expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot('Dart: sonar-project.properties');
+ expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot('Dart: bitbucket-pipelines.yml');
+
// Other
await user.click(ui.otherBuildButton.get());
expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot(
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 8652ad9cb41..47fabb0cee7 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
@@ -1,5 +1,38 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
+exports[`should follow and complete all steps: Dart: sonar-project.properties 1`] = `"sonar.projectKey=my-project"`;
+
+exports[`should follow and complete all steps: Dart: bitbucket-pipelines.yml 1`] = `
+"image: ghcr.io/cirruslabs/flutter:stable
+
+definitions:
+ steps:
+ - step: &build-step
+ name: Build the project, and run the SonarQube analysis
+ script:
+ - <commands to build your project>
+ - export SONAR_SCANNER_VERSION=6.1.0.4477
+ - mkdir $HOME/.sonar
+ - curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-\${SONAR_SCANNER_VERSION}-linux-x64.zip
+ - unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
+ - export PATH="$PATH:$HOME/.sonar/sonar-scanner-\${SONAR_SCANNER_VERSION}-linux-x64/bin"
+ - sonar-scanner
+ caches:
+ sonar: ~/.sonar
+
+clone:
+ depth: full
+
+pipelines:
+ branches:
+ '{main}':
+ - step: *build-step
+
+ pull-requests:
+ '**':
+ - step: *build-step"
+`;
+
exports[`should follow and complete all steps: .NET: bitbucket-pipelines.yml 1`] = `
"image: mcr.microsoft.com/dotnet/sdk:7.0
diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Dart.ts b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Dart.ts
new file mode 100644
index 00000000000..3bb69f1b23f
--- /dev/null
+++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Dart.ts
@@ -0,0 +1,60 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2024 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import { Arch, OSs } from '../../types';
+import { SONAR_SCANNER_CLI_LATEST_VERSION, getScannerUrlSuffix } from '../../utils';
+import { BuildToolExampleBuilder } from '../AnalysisCommand';
+
+const dartExample: BuildToolExampleBuilder = ({ branchesEnabled, mainBranchName }) => {
+ const scannerSuffix = getScannerUrlSuffix(OSs.Linux, Arch.X86_64);
+ return `image: ghcr.io/cirruslabs/flutter:stable
+
+definitions:
+ steps:
+ - step: &build-step
+ name: Build the project, and run the SonarQube analysis
+ script:
+ - <commands to build your project>
+ - export SONAR_SCANNER_VERSION=${SONAR_SCANNER_CLI_LATEST_VERSION}
+ - mkdir $HOME/.sonar
+ - curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-\${SONAR_SCANNER_VERSION}${scannerSuffix}.zip
+ - unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
+ - export PATH="$PATH:$HOME/.sonar/sonar-scanner-\${SONAR_SCANNER_VERSION}${scannerSuffix}/bin"
+ - sonar-scanner
+ caches:
+ sonar: ~/.sonar
+
+clone:
+ depth: full
+
+pipelines:
+ branches:
+ '{${mainBranchName}}':
+ - step: *build-step
+${
+ branchesEnabled
+ ? `
+ pull-requests:
+ '**':
+ - step: *build-step`
+ : ''
+}`;
+};
+
+export default dartExample;
diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/AnalysisCommand.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/AnalysisCommand.tsx
index f58f9d0bae9..ddcfe597564 100644
--- a/server/sonar-web/src/main/js/components/tutorials/github-action/AnalysisCommand.tsx
+++ b/server/sonar-web/src/main/js/components/tutorials/github-action/AnalysisCommand.tsx
@@ -25,6 +25,7 @@ import { Feature } from '../../../types/features';
import { Component } from '../../../types/types';
import { BuildTools, TutorialConfig } from '../types';
import CFamily from './commands/CFamily';
+import Dart from './commands/Dart';
import DotNet from './commands/DotNet';
import Gradle from './commands/Gradle';
import JavaMaven from './commands/JavaMaven';
@@ -80,6 +81,15 @@ export function AnalysisCommand(props: Readonly<AnalysisCommandProps>) {
component={component}
/>
);
+ case BuildTools.Dart:
+ return (
+ <Dart
+ branchesEnabled={branchSupportEnabled}
+ mainBranchName={mainBranchName}
+ monorepo={monorepo}
+ component={component}
+ />
+ );
case BuildTools.Other:
return (
<Others
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 e6553192e9f..562ef915d5e 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
@@ -136,6 +136,10 @@ it('should follow and complete all steps', async () => {
'Objective-C MacOS: .github/workflows/build.yml',
);
+ // Dart
+ await user.click(ui.dartBuildButton.get());
+ expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot('Dart: .github/workflows/build.yml');
+
// Other
await user.click(ui.otherBuildButton.get());
expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot(
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 98d789f4c4a..90daec9363a 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
@@ -1,5 +1,35 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
+exports[`should follow and complete all steps: Dart: .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
+ steps:
+ - <commands to build your project>
+ - name: Download sonar-scanner
+ run: |
+ curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.1.0.4477-linux-x64.zip
+ unzip $HOME/.sonar/sonar-scanner.zip -o -d $HOME/.sonar/
+ - name: Run sonar-scanner
+ env:
+ SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }}
+ SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }}
+ run: |
+ sonar-scanner-6.1.0.4477-linux-x64/bin/sonar-scanner \\
+ -Dsonar.projectKey=my-project"
+`;
+
exports[`should follow and complete all steps: .NET: .github/workflows/build.yml 1`] = `
"name: Build
diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Dart.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Dart.tsx
new file mode 100644
index 00000000000..44c989c4e6d
--- /dev/null
+++ b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Dart.tsx
@@ -0,0 +1,92 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2024 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import { CodeSnippet, Link, NumberedListItem } from 'design-system';
+import * as React from 'react';
+import { FormattedMessage } from 'react-intl';
+import { DocLink } from '../../../../helpers/doc-links';
+import { useDocUrl } from '../../../../helpers/docs';
+import { translate } from '../../../../helpers/l10n';
+import { Component } from '../../../../types/types';
+import MonorepoDocLinkFallback from './MonorepoDocLinkFallback';
+
+export interface DartProps {
+ branchesEnabled?: boolean;
+ component: Component;
+ mainBranchName: string;
+ monorepo?: boolean;
+}
+
+export default function Dart(props: Readonly<DartProps>) {
+ const { component, branchesEnabled, mainBranchName, monorepo } = props;
+ const docUrl = useDocUrl(DocLink.SonarScanner);
+
+ if (monorepo) {
+ return <MonorepoDocLinkFallback />;
+ }
+
+ return (
+ <NumberedListItem>
+ <FormattedMessage
+ defaultMessage={translate('onboarding.tutorial.with.github_action.dart')}
+ id="onboarding.tutorial.with.github_action.dart"
+ />
+ <CodeSnippet
+ className="sw-p-6 sw-overflow-auto"
+ snippet={`
+name: Build
+
+on:
+ push:
+ branches:
+ - ${mainBranchName}
+${branchesEnabled ? ' pull_request:\n types: [opened, synchronize, reopened]' : ''}
+
+jobs:
+ build:
+ name: Build and analyze
+ runs-on: ubuntu-latest
+ steps:
+ - <commands to build your project>
+ - name: Download sonar-scanner
+ run: |
+ curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.1.0.4477-linux-x64.zip
+ unzip $HOME/.sonar/sonar-scanner.zip -o -d $HOME/.sonar/
+ - name: Run sonar-scanner
+ env:
+ SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }}
+ SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }}
+ run: |
+ sonar-scanner-6.1.0.4477-linux-x64/bin/sonar-scanner \\
+ -Dsonar.projectKey=${component.key}`}
+ language="yml"
+ />
+
+ <p className="sw-mt-4">
+ <FormattedMessage
+ defaultMessage={translate('onboarding.analysis.sq_scanner.docs')}
+ id="onboarding.analysis.sq_scanner.docs"
+ values={{
+ link: <Link to={docUrl}>{translate('onboarding.analysis.sq_scanner.docs_link')}</Link>,
+ }}
+ />
+ </p>
+ </NumberedListItem>
+ );
+}
diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/YmlFileStep.tsx b/server/sonar-web/src/main/js/components/tutorials/gitlabci/YmlFileStep.tsx
index 992c09c3ca7..6ca29e6a793 100644
--- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/YmlFileStep.tsx
+++ b/server/sonar-web/src/main/js/components/tutorials/gitlabci/YmlFileStep.tsx
@@ -92,6 +92,7 @@ const snippetForBuildTool = {
[BuildTools.ObjectiveC]: otherSnippet,
[BuildTools.Gradle]: gradleSnippet,
[BuildTools.Maven]: mavenSnippet,
+ [BuildTools.Dart]: otherSnippet,
[BuildTools.Other]: otherSnippet,
};
@@ -100,6 +101,7 @@ const filenameForBuildTool = {
[BuildTools.ObjectiveC]: 'sonar-project.properties',
[BuildTools.Gradle]: GradleBuildDSL.Groovy,
[BuildTools.Maven]: 'pom.xml',
+ [BuildTools.Dart]: 'sonar-project.properties',
[BuildTools.Other]: 'sonar-project.properties',
};
@@ -108,6 +110,7 @@ const snippetLanguageForBuildTool = {
[BuildTools.ObjectiveC]: undefined,
[BuildTools.Gradle]: undefined,
[BuildTools.Maven]: 'xml',
+ [BuildTools.Dart]: undefined,
[BuildTools.Other]: undefined,
};
diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/GitLabCITutorial-it.tsx b/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/GitLabCITutorial-it.tsx
index 6ac323f6d0c..26fec42cb08 100644
--- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/GitLabCITutorial-it.tsx
+++ b/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/GitLabCITutorial-it.tsx
@@ -88,6 +88,11 @@ it('should follow and complete all steps', async () => {
await user.click(ui.autoConfigManual.get());
expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot('CPP - manual: gitlab-ci.yml');
+ // Dart
+ await user.click(ui.dartBuildButton.get());
+ expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot('Dart: sonar-project.properties');
+ expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot('Dart: gitlab-ci.yml');
+
// Other
await user.click(ui.otherBuildButton.get());
expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot('Other: sonar-project.properties');
diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/GitLabCITutorial-it.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/GitLabCITutorial-it.tsx.snap
index c2e41a10cbc..0dcb01b15f3 100644
--- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/GitLabCITutorial-it.tsx.snap
+++ b/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/GitLabCITutorial-it.tsx.snap
@@ -186,6 +186,74 @@ sonar.qualitygate.wait=true
"
`;
+exports[`should follow and complete all steps: Dart: gitlab-ci.yml 1`] = `
+"image: ghcr.io/cirruslabs/flutter:stable
+
+variables:
+ SONAR_USER_HOME: "\${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
+ GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
+
+stages:
+ - get-binaries
+ - sonarqube-check
+ - sonarqube-vulnerability-report
+
+get-binaries:
+ stage: get-binaries
+ cache:
+ policy: push
+ key: "\${CI_COMMIT_SHORT_SHA}"
+ paths:
+ - sonar-scanner/
+
+ script:
+ # Download sonar-scanner
+ - curl -sSLo ./sonar-scanner.zip 'https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.1.0.4477-linux-x64.zip'
+ - unzip -o sonar-scanner.zip
+ - mv sonar-scanner-6.1.0.4477-linux-x64 sonar-scanner
+
+ rules:
+ - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
+ - if: $CI_COMMIT_BRANCH == 'master'
+ - if: $CI_COMMIT_BRANCH == 'main'
+ - if: $CI_COMMIT_BRANCH == 'develop'
+
+sonarqube-check:
+ stage: sonarqube-check
+
+ script:
+ - <commands to build your project>
+ - sonar-scanner/bin/sonar-scanner --define sonar.host.url="\${SONAR_HOST_URL}"
+ allow_failure: true
+ rules:
+ - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
+ - if: $CI_COMMIT_BRANCH == 'master'
+ - if: $CI_COMMIT_BRANCH == 'main'
+ - if: $CI_COMMIT_BRANCH == 'develop'
+
+sonarqube-vulnerability-report:
+ stage: sonarqube-vulnerability-report
+ script:
+ - 'curl -u "\${SONAR_TOKEN}:" "\${SONAR_HOST_URL}/api/issues/gitlab_sast_export?projectKey=my-project&branch=\${CI_COMMIT_BRANCH}&pullRequest=\${CI_MERGE_REQUEST_IID}" -o gl-sast-sonar-report.json'
+ allow_failure: true
+ rules:
+ - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
+ - if: $CI_COMMIT_BRANCH == 'master'
+ - if: $CI_COMMIT_BRANCH == 'main'
+ - if: $CI_COMMIT_BRANCH == 'develop'
+ artifacts:
+ expire_in: 1 day
+ reports:
+ sast: gl-sast-sonar-report.json
+"
+`;
+
+exports[`should follow and complete all steps: Dart: sonar-project.properties 1`] = `
+"sonar.projectKey=my-project
+sonar.qualitygate.wait=true
+"
+`;
+
exports[`should follow and complete all steps: Gradle: gitlab-ci.yml 1`] = `
"image: gradle:8.2.0-jdk17-jammy
diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/commands/PipeCommand.tsx b/server/sonar-web/src/main/js/components/tutorials/gitlabci/commands/PipeCommand.tsx
index 0e819d263f7..2276988966c 100644
--- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/commands/PipeCommand.tsx
+++ b/server/sonar-web/src/main/js/components/tutorials/gitlabci/commands/PipeCommand.tsx
@@ -79,6 +79,12 @@ const BUILD_TOOL_SPECIFIC: {
`sonar-scanner/bin/sonar-scanner --define sonar.host.url="\${SONAR_HOST_URL}" ` +
`--define sonar.cfamily.compile-commands="\${BUILD_WRAPPER_OUT_DIR}/compile_commands.json"`,
},
+ [BuildTools.Dart]: {
+ image: 'ghcr.io/cirruslabs/flutter:stable',
+ script: () => `
+ - <commands to build your project>
+ - sonar-scanner/bin/sonar-scanner --define sonar.host.url="\${SONAR_HOST_URL}"`,
+ },
[BuildTools.Other]: {
image: `
name: sonarsource/sonar-scanner-cli:latest
@@ -187,7 +193,7 @@ export default function PipeCommand(props: Readonly<PipeCommandProps>) {
stageDeclaration = ['sonarqube-check', ...stageDeclaration];
}
- if (isCFamily(buildTool)) {
+ if (isCFamily(buildTool) || buildTool === BuildTools.Dart) {
stages = [getBinaries, ...stages];
stageDeclaration = ['get-binaries', ...stageDeclaration];
}
diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/JenkinsStep.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/JenkinsStep.tsx
index 87ca0994688..079af4ae849 100644
--- a/server/sonar-web/src/main/js/components/tutorials/jenkins/JenkinsStep.tsx
+++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/JenkinsStep.tsx
@@ -38,6 +38,7 @@ const BUILDTOOL_COMPONENT_MAP: {
[BuildTools.DotNet]: DotNet,
[BuildTools.Cpp]: CFamily,
[BuildTools.ObjectiveC]: CFamily,
+ [BuildTools.Dart]: Other,
[BuildTools.Other]: Other,
};
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 98dcb166e66..61ccedae4bd 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
@@ -183,6 +183,11 @@ it.each([AlmKeys.BitbucketCloud, AlmKeys.BitbucketServer, AlmKeys.GitHub, AlmKey
await user.click(ui.macosButton.get());
expect(getCopyToClipboardValue(3, 'Copy')).toMatchSnapshot(`objectivec: macos jenkinsfile`);
+ // Dart
+ await user.click(ui.dartBuildButton.get());
+ expect(getCopyToClipboardValue(2, 'Copy')).toMatchSnapshot(`Dart: sonar-project.properties`);
+ expect(getCopyToClipboardValue(3, 'Copy')).toMatchSnapshot(`Dart: jenkinsfile`);
+
// Other
await user.click(ui.otherBuildButton.get());
expect(getCopyToClipboardValue(2, 'Copy')).toMatchSnapshot(
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 cb6312f809a..a0688444fe3 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
@@ -1,5 +1,21 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
+exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: Dart: jenkinsfile 1`] = `
+"node {
+ stage('SCM') {
+ checkout scm
+ }
+ stage('SonarQube Analysis') {
+ def scannerHome = tool 'SonarScanner';
+ withSonarQubeEnv() {
+ sh "\${scannerHome}/bin/sonar-scanner"
+ }
+ }
+}"
+`;
+
+exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: Dart: sonar-project.properties 1`] = `"sonar.projectKey=my-project"`;
+
exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: Groovy: build.gradle file 1`] = `
"plugins {
id "org.sonarqube" version "5.0.0.4638"
@@ -349,6 +365,22 @@ exports[`bitbucket: can select devops platform and complete all the steps with c
"
`;
+exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: Dart: jenkinsfile 1`] = `
+"node {
+ stage('SCM') {
+ checkout scm
+ }
+ stage('SonarQube Analysis') {
+ def scannerHome = tool 'SonarScanner';
+ withSonarQubeEnv() {
+ sh "\${scannerHome}/bin/sonar-scanner"
+ }
+ }
+}"
+`;
+
+exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: Dart: sonar-project.properties 1`] = `"sonar.projectKey=my-project"`;
+
exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: Groovy: build.gradle file 1`] = `
"plugins {
id "org.sonarqube" version "5.0.0.4638"
@@ -698,6 +730,22 @@ exports[`bitbucketcloud: can select devops platform and complete all the steps w
"
`;
+exports[`github: can select devops platform and complete all the steps with copying code snippets: Dart: jenkinsfile 1`] = `
+"node {
+ stage('SCM') {
+ checkout scm
+ }
+ stage('SonarQube Analysis') {
+ def scannerHome = tool 'SonarScanner';
+ withSonarQubeEnv() {
+ sh "\${scannerHome}/bin/sonar-scanner"
+ }
+ }
+}"
+`;
+
+exports[`github: can select devops platform and complete all the steps with copying code snippets: Dart: sonar-project.properties 1`] = `"sonar.projectKey=my-project"`;
+
exports[`github: can select devops platform and complete all the steps with copying code snippets: Groovy: build.gradle file 1`] = `
"plugins {
id "org.sonarqube" version "5.0.0.4638"
@@ -1047,6 +1095,22 @@ exports[`github: 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: Dart: jenkinsfile 1`] = `
+"node {
+ stage('SCM') {
+ checkout scm
+ }
+ stage('SonarQube Analysis') {
+ def scannerHome = tool 'SonarScanner';
+ withSonarQubeEnv() {
+ sh "\${scannerHome}/bin/sonar-scanner"
+ }
+ }
+}"
+`;
+
+exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: Dart: sonar-project.properties 1`] = `"sonar.projectKey=my-project"`;
+
exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: Groovy: build.gradle file 1`] = `
"plugins {
id "org.sonarqube" version "5.0.0.4638"
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 78d5bbf5531..3cc9278e818 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
@@ -43,6 +43,7 @@ export function BuildToolForm(props: Readonly<Props>) {
function handleConfigChange(newConfig: TutorialConfig) {
const selectOsByDefault = (newConfig.buildTool === BuildTools.Cpp ||
newConfig.buildTool === BuildTools.ObjectiveC ||
+ newConfig.buildTool === BuildTools.Dart ||
newConfig.buildTool === BuildTools.Other) && {
os: OSs.Linux,
};
@@ -65,6 +66,7 @@ export function BuildToolForm(props: Readonly<Props>) {
/>
)}
{(config.buildTool === BuildTools.Other ||
+ config.buildTool === BuildTools.Dart ||
config.buildTool === BuildTools.Cpp ||
config.buildTool === BuildTools.ObjectiveC) && (
<RenderOptions
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 f99d456c3c8..905eb73b915 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
@@ -259,6 +259,22 @@ it('can choose build tools and copy provided settings', async () => {
);
expect(getCopyToClipboardValue(3, 'Copy')).toMatchSnapshot('objective-c macos: execute scanner');
+ // Dart - Linux
+ await user.click(ui.dartBuildButton.get());
+ await user.click(ui.linuxButton.get());
+ expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot('Dart linux: download scanner');
+ expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot('Dart linux: execute scanner');
+
+ // Dart - Windows
+ await user.click(ui.windowsButton.get());
+ expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot('Dart windows: download scanner');
+ expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot('Dart windows: execute scanner');
+
+ // Dart - MacOS
+ await user.click(ui.macosButton.get());
+ expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot('Dart macos: download scanner');
+ expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot('Dart macos: execute scanner');
+
// Other - Linux
await user.click(ui.otherBuildButton.get());
await user.click(ui.linuxButton.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 fce78d03bc7..c82a688c22c 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
@@ -1,5 +1,56 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
+exports[`can choose build tools and copy provided settings: Dart linux: download scanner 1`] = `
+"export SONAR_SCANNER_VERSION=6.1.0.4477
+export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux-x64
+curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux-x64.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: Dart linux: execute scanner 1`] = `
+"sonar-scanner \\
+ -Dsonar.projectKey=my-project \\
+ -Dsonar.sources=. \\
+ -Dsonar.host.url=http://localhost:9000"
+`;
+
+exports[`can choose build tools and copy provided settings: Dart windows: download scanner 1`] = `
+"$env:SONAR_SCANNER_VERSION = "6.1.0.4477"
+$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-x64"
+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-x64.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: Dart windows: execute scanner 1`] = `"sonar-scanner.bat -D"sonar.projectKey=my-project" -D"sonar.sources=." -D"sonar.host.url=http://localhost:9000""`;
+
+exports[`can choose build tools and copy provided settings: Dart macos: download scanner 1`] = `
+"export SONAR_SCANNER_VERSION=6.1.0.4477
+export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-macosx-x64
+curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-macosx-x64.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: Dart macos: execute scanner 1`] = `
+"sonar-scanner \\
+ -Dsonar.projectKey=my-project \\
+ -Dsonar.sources=. \\
+ -Dsonar.host.url=http://localhost:9000"
+`;
+
exports[`can choose build tools and copy provided settings: c++ (automatic) and other linux arm64: download scanner 1`] = `
"export SONAR_SCANNER_VERSION=6.1.0.4477
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux-aarch64
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 846fdb0f14c..2ad95448d8f 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
@@ -53,6 +53,7 @@ export default function AnalysisCommand(props: Readonly<AnalysisCommandProps>) {
case BuildTools.DotNet:
return <DotNet baseUrl={baseUrl} component={component} token={token} />;
+ case BuildTools.Dart:
case BuildTools.Other:
return (
<Other
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 c972a28c578..47069819ca8 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
@@ -74,6 +74,7 @@ export function getTutorialBuildButtons() {
dotnetBuildButton: byRole('radio', { name: `onboarding.build.${BuildTools.DotNet}` }),
cppBuildButton: byRole('radio', { name: `onboarding.build.${BuildTools.Cpp}` }),
objCBuildButton: byRole('radio', { name: `onboarding.build.${BuildTools.ObjectiveC}` }),
+ dartBuildButton: byRole('radio', { name: `onboarding.build.${BuildTools.Dart}` }),
otherBuildButton: byRole('radio', { name: `onboarding.build.${BuildTools.Other}` }),
windowsDotnetCoreButton: byRole('radio', {
name: `onboarding.build.${BuildTools.DotNet}.win_core`,
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 06783c05fbd..13f22602cc5 100644
--- a/server/sonar-web/src/main/js/components/tutorials/types.ts
+++ b/server/sonar-web/src/main/js/components/tutorials/types.ts
@@ -33,6 +33,7 @@ export enum BuildTools {
Cpp = 'cpp',
ObjectiveC = 'objectivec',
DotNet = 'dotnet',
+ Dart = 'dart',
Other = 'other',
}
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 fa62732d252..58c66594bc4 100644
--- a/server/sonar-web/src/main/js/components/tutorials/utils.ts
+++ b/server/sonar-web/src/main/js/components/tutorials/utils.ts
@@ -103,6 +103,8 @@ export function getBuildToolOptions(supportCFamily: boolean) {
if (supportCFamily) {
list.push(BuildTools.Cpp);
list.push(BuildTools.ObjectiveC);
+ // Both Dart and CFamily are available in Developer Edition and above
+ list.push(BuildTools.Dart);
}
list.push(BuildTools.Other);
return list;