]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-14968 Enable Azure- pipeline for project bind to GitHub
authorMathieu Suen <mathieu.suen@sonarsource.com>
Mon, 14 Jun 2021 08:40:01 +0000 (10:40 +0200)
committersonartech <sonartech@sonarsource.com>
Mon, 14 Jun 2021 20:03:29 +0000 (20:03 +0000)
server/sonar-web/src/main/js/components/tutorials/TutorialSelectionRenderer.tsx
server/sonar-web/src/main/js/components/tutorials/__tests__/TutorialSelectionRenderer-test.tsx
server/sonar-web/src/main/js/components/tutorials/__tests__/__snapshots__/TutorialSelectionRenderer-test.tsx.snap
server/sonar-web/src/main/js/components/tutorials/azure-pipelines/AzurePipelinesTutorial.tsx
server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/AzurePipelinesTutorial-test.tsx
server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/__snapshots__/AzurePipelinesTutorial-test.tsx.snap
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index b724e53b3b638b274a1e3616f0e4df9e6b285174..f9f1f51941165bccaed243048951666a06d83151 100644 (file)
@@ -55,6 +55,9 @@ export default function TutorialSelectionRenderer(props: TutorialSelectionRender
     return <i className="spinner" />;
   }
 
+  const isAzureAvailable =
+    projectBinding && [AlmKeys.Azure, AlmKeys.GitHub].includes(projectBinding.alm);
+
   const jenkinsAvailable =
     projectBinding &&
     [AlmKeys.BitbucketCloud, AlmKeys.BitbucketServer, AlmKeys.GitHub, AlmKeys.GitLab].includes(
@@ -105,7 +108,7 @@ export default function TutorialSelectionRenderer(props: TutorialSelectionRender
               </button>
             )}
 
-            {projectBinding?.alm === AlmKeys.Azure && (
+            {isAzureAvailable && (
               <button
                 className="button button-huge display-flex-column spacer-left spacer-right azure-pipelines"
                 onClick={() => props.onSelectTutorial(TutorialModes.AzurePipelines)}
index 9004e28527921aa3fa47046e677d2a8d889d0775..74460e6a4a4339c7100ec89d277ea72b29b29ece 100644 (file)
@@ -104,6 +104,9 @@ it('should allow mode selection for Github', () => {
 
   click(wrapper.find('button.tutorial-mode-github'));
   expect(onSelectTutorial).toHaveBeenLastCalledWith(TutorialModes.GitHubActions);
+
+  click(wrapper.find('button.azure-pipelines'));
+  expect(onSelectTutorial).toHaveBeenLastCalledWith(TutorialModes.AzurePipelines);
 });
 
 it('should allow mode selection for GitLab', () => {
index 417a8bc52a7427f28cab96b9658a8d5ec417db13..4a76b4a6316ca0de4a5ef4ba7876f6ca4fd49083 100644 (file)
@@ -142,6 +142,22 @@ exports[`should render correctly for github 1`] = `
           onboarding.tutorial.choose_method.github_action
         </div>
       </button>
+      <button
+        className="button button-huge display-flex-column spacer-left spacer-right azure-pipelines"
+        onClick={[Function]}
+        type="button"
+      >
+        <img
+          alt=""
+          height={80}
+          src="/images/tutorials/azure-pipelines.svg"
+        />
+        <div
+          className="medium big-spacer-top"
+        >
+          onboarding.tutorial.choose_method.azure_pipelines
+        </div>
+      </button>
       <button
         className="button button-huge display-flex-column spacer-left spacer-right tutorial-mode-jenkins"
         onClick={[Function]}
index e7ab59b267d0902a788abd8a07baa35db7b976fb..b26c2ca52b6516e8d817169488fff6f1c746e781 100644 (file)
@@ -23,6 +23,7 @@ import { Alert } from 'sonar-ui-common/components/ui/Alert';
 import { translate } from 'sonar-ui-common/helpers/l10n';
 import {
   isProjectAzureBindingResponse,
+  isProjectGitHubBindingResponse,
   ProjectAlmBindingResponse
 } from '../../../types/alm-settings';
 import Step from '../components/Step';
@@ -58,7 +59,10 @@ export default function AzurePipelinesTutorial(props: AzurePipelinesTutorialProp
   const [isCurrentStepValid, setIsCurrentStepValid] = React.useState(false);
 
   // Failsafe; should never happen.
-  if (!isProjectAzureBindingResponse(projectBinding)) {
+  if (
+    !isProjectAzureBindingResponse(projectBinding) &&
+    !isProjectGitHubBindingResponse(projectBinding)
+  ) {
     return (
       <Alert variant="error">
         {translate('onboarding.tutorial.with.azure_pipelines.unsupported')}
index 1ff63b595697b14c56e1163fb0ef7da41db18894..8446de30e380ff983b9036410fda395ce7eab3c6 100644 (file)
@@ -23,7 +23,8 @@ import { Button } from 'sonar-ui-common/components/controls/buttons';
 import { click } from 'sonar-ui-common/helpers/testUtils';
 import {
   mockProjectAzureBindingResponse,
-  mockProjectGithubBindingResponse
+  mockProjectGithubBindingResponse,
+  mockProjectGitLabBindingResponse
 } from '../../../../helpers/mocks/alm-settings';
 import { mockComponent, mockLoggedInUser } from '../../../../helpers/testMocks';
 import Step from '../../components/Step';
@@ -45,6 +46,9 @@ it('should render correctly', () => {
       .dive()
   ).toMatchSnapshot('last-step-wrapper');
   expect(shallowRender({ projectBinding: mockProjectGithubBindingResponse() })).toMatchSnapshot(
+    'for github'
+  );
+  expect(shallowRender({ projectBinding: mockProjectGitLabBindingResponse() })).toMatchSnapshot(
     'wrong alm'
   );
 });
index 84e32877db7adff9c87a676f99f6a4f0ca29fc21..a239f3584c8f455ad465df1ee1eac33a70cd9f97 100644 (file)
@@ -86,6 +86,56 @@ exports[`should render correctly: first-step-wrapper 1`] = `
 </div>
 `;
 
+exports[`should render correctly: for github 1`] = `
+<Fragment>
+  <div
+    className="page-header big-spacer-bottom"
+  >
+    <h1
+      className="page-title"
+    >
+      onboarding.tutorial.with.azure_pipelines.title
+    </h1>
+  </div>
+  <Step
+    finished={false}
+    key="0"
+    onOpen={[Function]}
+    open={true}
+    renderForm={[Function]}
+    stepNumber={1}
+    stepTitle="onboarding.tutorial.with.azure_pipelines.ExtensionInstallation.title"
+  />
+  <Step
+    finished={false}
+    key="1"
+    onOpen={[Function]}
+    open={false}
+    renderForm={[Function]}
+    stepNumber={2}
+    stepTitle="onboarding.tutorial.with.azure_pipelines.ServiceEndpoint.title"
+  />
+  <Step
+    finished={false}
+    key="2"
+    onOpen={[Function]}
+    open={false}
+    renderForm={[Function]}
+    stepNumber={3}
+    stepTitle="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.title"
+  />
+  <Step
+    finished={false}
+    key="3"
+    onOpen={[Function]}
+    open={false}
+    renderForm={[Function]}
+    stepNumber={4}
+    stepTitle="onboarding.tutorial.with.azure_pipelines.SaveAndRun.title"
+  />
+</Fragment>
+`;
+
 exports[`should render correctly: last-step-wrapper 1`] = `
 <div
   className="boxed-group onboarding-step"
index 5b17e930f42f59d59055ba0757811fce7e0aee6d..26ba84a1c1e0472f1ee43d2e6f52a48082c590f4 100644 (file)
@@ -3742,7 +3742,7 @@ onboarding.tutorial.with.jenkins.jenkinsfile.other.step3.help2.sentence.name=Nam
 
 onboarding.tutorial.with.azure_pipelines.os=What is your agent host?
 onboarding.tutorial.with.azure_pipelines.title=Analyze your project with Azure DevOps Pipelines
-onboarding.tutorial.with.azure_pipelines.unsupported=This tutorial is only available for projects bound to Azure DevOps.
+onboarding.tutorial.with.azure_pipelines.unsupported=This tutorial is only available for projects bound to Azure DevOps or GitHub.
 onboarding.tutorial.with.azure_pipelines.ExtensionInstallation.title=Install SonarQube extension for Azure DevOps
 onboarding.tutorial.with.azure_pipelines.ExtensionInstallation.sentence=From your Azure DevOps instance, navigate to the Visual Studio Marketplace and install the {link} by clicking the {button} button.
 onboarding.tutorial.with.azure_pipelines.ExtensionInstallation.sentence.link=SonarQube extension