-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathazure-pipelines.yml
110 lines (93 loc) · 3.86 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
trigger: none
# For code on Github this must always be a Microsoft-hosted agent running outside our network
pool:
vmImage: 'windows-2019'
resources:
repositories:
- repository: hooks
type: git
name: TPR/Tools-TPRGitHooks
ref: develop
variables:
- name: YARN_CACHE_FOLDER
value: $(Pipeline.Workspace)/.yarn
- group: DEV-COMMON-SECRETS
jobs:
- job: Build_and_test
displayName: Build and test
steps:
- checkout: self
- checkout: hooks
- template: git-secrets.steps.yml@hooks
parameters:
repoPath: $(Build.SourcesDirectory)\react-components
# Node.js tool installer
# Finds or downloads and caches the specified version spec of Node.js and adds it to the PATH
- task: NodeTool@0
inputs:
versionSpec: '14.18.1'
displayName: Set Node version
# Be specific about which version of npm we build with
# npm 7 or above fails with "Cannot read properties of null (reading 'matches')". Two changes separately triggered this error:
# - removal of the "downshift" package,
# - adding the "@tpr/govuk-react-jsx" package
- script: npm install -g [email protected]
displayName: Set npm version
- task: Cache@2
inputs:
key: 'yarn | "$(Agent.OS)" | $(Build.SourcesDirectory)/react-components/**/yarn.lock'
restoreKeys: |
yarn | "$(Agent.OS)"
path: $(YARN_CACHE_FOLDER)
displayName: Cache Yarn packages
- task: Yarn@3
inputs:
projectDirectory: '$(Build.SourcesDirectory)\react-components'
arguments: 'audit --level moderate --groups dependencies'
displayName: yarn audit
- task: Yarn@3
inputs:
projectDirectory: '$(Build.SourcesDirectory)\react-components'
arguments: '--frozen-lockfile'
displayName: yarn install
- task: Yarn@3
inputs:
projectDirectory: '$(Build.SourcesDirectory)\react-components'
arguments: 'build'
displayName: yarn build
- task: Yarn@3
inputs:
projectDirectory: '$(Build.SourcesDirectory)\react-components'
arguments: test --ci --watchAll=false --reporters=jest-junit --reporters=default --coverage --coverageReporters=cobertura --testMatch "**\*.spec.[t]s?(x)"
displayName: Run tests
continueOnError: false # Test failures should fail the build
- task: PublishTestResults@2
displayName: 'Publish unit test results'
inputs:
testResultsFiles: junit.xml
searchFolder: $(Build.SourcesDirectory)\react-components
mergeTestResults: true
testRunTitle: 'Jest Unit Tests'
failTaskOnFailedTests: true
condition: always()
- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage from Jest tests'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: $(Build.SourcesDirectory)\react-components\coverage\cobertura-coverage.xml
failIfCoverageEmpty: true
- ${{ if eq(variables['Build.SourceBranch'], 'refs/heads/develop') }}:
- script: git reset --hard HEAD
displayName: Reset file changes made by tests that would prevent deployment
- task: Yarn@3
inputs:
projectDirectory: '$(Build.SourcesDirectory)\react-components'
arguments: 'postinstall'
displayName: yarn postinstall
- script: echo "//registry.npmjs.org/:_authToken=$(NPM-Access-Token)" > $(Build.SourcesDirectory)\react-components\.npmrc
displayName: Authenticate with NPM registry
- task: Yarn@3
inputs:
projectDirectory: '$(Build.SourcesDirectory)\react-components'
arguments: deploy --canary --yes --preid next --dist-tag next
displayName: Publish packages to NPM