|
| 1 | +parameters: |
| 2 | + - name: "poolType" |
| 3 | + type: string |
| 4 | + default: "linux" |
| 5 | + values: |
| 6 | + - "linux" |
| 7 | + - "windows" |
| 8 | + - name: "sourceBranch" |
| 9 | + type: string |
| 10 | + - name: "npmInstallTimeout" |
| 11 | + type: number |
| 12 | + default: 15 |
| 13 | + - name: "debug" |
| 14 | + type: boolean |
| 15 | + default: false |
| 16 | + - name: "samples" |
| 17 | + type: object |
| 18 | + default: |
| 19 | + - "react-router-sample" |
| 20 | + - "typescript-sample" |
| 21 | + - "b2c-sample" |
| 22 | + |
| 23 | +jobs: |
| 24 | + - ${{ each sample in parameters.samples }}: |
| 25 | + - job: validate_msal_react_r18_${{ replace(sample, '-', '_') }} |
| 26 | + displayName: "[msal-react] - ${{ sample }} - React 18 - Node v22" |
| 27 | + |
| 28 | + pool: |
| 29 | + type: ${{ parameters.poolType }} |
| 30 | + isCustom: true |
| 31 | + name: "Azure Pipelines" |
| 32 | + ${{ if eq(parameters.poolType, 'linux') }}: |
| 33 | + vmImage: "ubuntu-latest" |
| 34 | + ${{ elseif eq(parameters.poolType, 'windows') }}: |
| 35 | + vmImage: "windows-latest" |
| 36 | + |
| 37 | + variables: |
| 38 | + - template: .pipelines/templates/variables.yml@1P |
| 39 | + - name: "npm_config_cache" |
| 40 | + value: "$(Pipeline.Workspace)/.npm" |
| 41 | + - name: "samplePath" |
| 42 | + ${{ if eq(parameters.poolType, 'windows') }}: |
| 43 | + value: "samples/msal-react-samples/${{ sample }}" |
| 44 | + ${{ else }}: |
| 45 | + value: "samples/msal-react-samples/${{ sample }}" |
| 46 | + |
| 47 | + steps: |
| 48 | + - template: .pipelines/templates/build-var-dump.yml@1P |
| 49 | + parameters: |
| 50 | + debug: ${{ parameters.debug }} |
| 51 | + |
| 52 | + - checkout: self |
| 53 | + |
| 54 | + - task: CmdLine@2 |
| 55 | + displayName: "Checkout ${{ variables.sourceBranch }} branch" |
| 56 | + inputs: |
| 57 | + script: git switch $(sourceBranch) || git switch -c $(sourceBranch) origin/$(sourceBranch) || git switch -c $(sourceBranch) origin/dev |
| 58 | + |
| 59 | + - template: .pipelines/templates/node-install-wrapper.yml@1P |
| 60 | + parameters: |
| 61 | + nodeVersion: "22" |
| 62 | + |
| 63 | + - task: npmAuthenticate@0 |
| 64 | + displayName: "Authenticate to npm package registry" |
| 65 | + inputs: |
| 66 | + workingFile: ./.npmrc |
| 67 | + |
| 68 | + - template: .pipelines/templates/npm-install.yml@1P |
| 69 | + parameters: |
| 70 | + clean: true |
| 71 | + name: "msal-react" |
| 72 | + workspace: "samples/msal-react-samples/${{ sample }}" |
| 73 | + workingDir: "./" |
| 74 | + useInternalFeed: false |
| 75 | + timeout: ${{ parameters.npmInstallTimeout }} |
| 76 | + |
| 77 | + - task: CmdLine@2 |
| 78 | + displayName: "Override sample to React 18 via npm overrides" |
| 79 | + inputs: |
| 80 | + targetType: inline |
| 81 | + script: | |
| 82 | + npm pkg set "overrides.react=^18" "overrides.react-dom=^18" "overrides.@types/react=^18" "overrides.@types/react-dom=^18" |
| 83 | + npm install |
| 84 | + workingDirectory: "./" |
| 85 | + |
| 86 | + - ${{ if eq(parameters.poolType, 'linux') }}: |
| 87 | + - template: .pipelines/templates/npm-install.yml@1P |
| 88 | + parameters: |
| 89 | + name: "rollup linux platform deps" |
| 90 | + workingDir: "./" |
| 91 | + paramList: "--no-save" |
| 92 | + packageList: "@rollup/rollup-linux-x64-gnu" |
| 93 | + useInternalFeed: false |
| 94 | + timeout: ${{ parameters.npmInstallTimeout }} |
| 95 | + |
| 96 | + - task: Npm@1 |
| 97 | + displayName: "Build msal-react" |
| 98 | + inputs: |
| 99 | + command: "custom" |
| 100 | + customCommand: "run build:all" |
| 101 | + workingDir: "lib/msal-react" |
| 102 | + |
| 103 | + - task: Npm@1 |
| 104 | + displayName: "Build msal-node" |
| 105 | + inputs: |
| 106 | + command: "custom" |
| 107 | + customCommand: "run build:all" |
| 108 | + workingDir: "lib/msal-node" |
| 109 | + |
| 110 | + - task: Npm@1 |
| 111 | + displayName: "Build ${{ sample }}" |
| 112 | + inputs: |
| 113 | + command: "custom" |
| 114 | + customCommand: "run build" |
| 115 | + workingDir: "$(samplePath)" |
| 116 | + |
| 117 | + - task: Npm@1 |
| 118 | + displayName: "Generate certificates" |
| 119 | + inputs: |
| 120 | + command: "custom" |
| 121 | + customCommand: "run generate:certs --if-present" |
| 122 | + workingDir: "$(samplePath)" |
| 123 | + |
| 124 | + - template: .pipelines/templates/install-keyvault-secrets.yml@1P |
| 125 | + parameters: |
| 126 | + keyVaultName: "msidlabs" |
| 127 | + secretsFilter: "LabVaultAccessCert" |
| 128 | + secretName: "LabVaultAccessCert" |
| 129 | + pfxPath: "$(Build.SourcesDirectory)/LabCert.pfx" |
| 130 | + pemPath: "$(Build.SourcesDirectory)/LabCert.pem" |
| 131 | + |
| 132 | + - task: CmdLine@2 |
| 133 | + displayName: "Create screenshot folder" |
| 134 | + inputs: |
| 135 | + script: mkdir -p ${{ replace(variables.samplePath, '/', '\') }}\test\screenshots\react18 |
| 136 | + |
| 137 | + - task: Npm@1 |
| 138 | + displayName: "Test ${{ sample }}" |
| 139 | + timeoutInMinutes: 30 |
| 140 | + retryCountOnTaskFailure: 3 |
| 141 | + inputs: |
| 142 | + command: "custom" |
| 143 | + customCommand: "run test:e2e -- --sample=${{ sample }} --detectOpenHandles --forceExit --reporters=default --reporters=jest-junit" |
| 144 | + workingDir: "$(samplePath)" |
| 145 | + env: |
| 146 | + AZURE_CLIENT_CERTIFICATE_PATH: $(Build.SourcesDirectory)/LabCert.pem |
| 147 | + AZURE_CLIENT_ID: $(AZURE_CLIENT_ID) |
| 148 | + AZURE_CLIENT_SEND_CERTIFICATE_CHAIN: "true" |
| 149 | + AZURE_TENANT_ID: $(AZURE_TENANT_ID) |
| 150 | + JEST_JUNIT_OUTPUT_NAME: "${{ sample }}.xml" |
| 151 | + SESSION_SECRET: $(EXPRESS_SESSION_SECRET) |
| 152 | + |
| 153 | + - task: PublishTestResults@2 |
| 154 | + displayName: "Publish Test Results" |
| 155 | + condition: succeededOrFailed() |
| 156 | + inputs: |
| 157 | + testResultsFiles: "$(samplePath)/${{ sample }}.xml" |
| 158 | + testRunTitle: "${{ sample }}-react18" |
| 159 | + |
| 160 | + - task: CopyFiles@2 |
| 161 | + condition: failed() |
| 162 | + inputs: |
| 163 | + SourceFolder: "${{ variables.samplePath }}/test/screenshots/react18" |
| 164 | + Contents: "**" |
| 165 | + TargetFolder: $(Build.ArtifactStagingDirectory) |
| 166 | + |
| 167 | + - task: PublishPipelineArtifact@1 |
| 168 | + displayName: "Upload screenshots to artifacts" |
| 169 | + condition: succeededOrFailed() |
| 170 | + inputs: |
| 171 | + targetPath: $(Build.ArtifactStagingDirectory) |
| 172 | + artifact: "drop_e2e_test_validate_msal_react_r18_${{ replace(sample, '-', '_') }}" |
| 173 | + publishLocation: "pipeline" |
| 174 | + |
| 175 | + - template: .pipelines/templates/remove-keyvault-secrets.yml@1P |
0 commit comments