forked from IDuxFE/idux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
114 lines (95 loc) · 3.33 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
111
112
113
114
# Node.js with Vue
# Build a Node.js project that uses Vue.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
trigger:
- main
- next
- hotfix
pool:
vmImage: 'ubuntu-latest'
variables:
install_packages: 'npm add -g pnpm && pnpm install'
stages:
- stage: env
jobs:
- job: env_nodes
steps:
- checkout: none
- task: NodeTool@0
inputs:
versionSpec: '16.x'
displayName: 'Install Node.js'
- stage: lint
condition: eq(variables['Build.Reason'], 'PullRequest')
dependsOn: env
jobs:
- job: lint_packages
steps:
- script: $(install_packages)
displayName: 'Install packages'
- script: npm run lint
displayName: 'Run lint'
- stage: test
dependsOn: env
jobs:
- job: test_packages
steps:
- script: $(install_packages)
displayName: 'Install packages'
- script: npm run test
displayName: 'Run test'
- script: ./node_modules/.bin/codecov -t $(CODECOV_TOKEN)
condition: succeededOrFailed()
displayName: 'Upload code codecov results'
- task: PublishCodeCoverageResults@1
condition: succeededOrFailed()
displayName: 'Publish code coverage results'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: $(System.DefaultWorkingDirectory)/coverage/cobertura-coverage.xml
reportDirectory: '$(System.DefaultWorkingDirectory)/coverage'
failIfCoverageEmpty: true
- task: PublishTestResults@2
displayName: 'Publish test results'
condition: succeededOrFailed()
inputs:
testResultsFiles: junit.xml
mergeTestResults: true
testRunTitle: 'Vitest Unit Tests'
failTaskOnFailedTests: true
- stage: build
dependsOn: env
jobs:
- job: build_site
condition: eq(variables['Build.Reason'], 'PullRequest')
steps:
- script: $(install_packages)
displayName: 'Install packages'
- script: npm run build
displayName: 'Run build'
- script: |
export DEPLOY_DOMAIN=https://preview-${SYSTEM_PULLREQUEST_PULLREQUESTNUMBER}-idux.surge.sh
npx surge --project ./dist/site --domain $DEPLOY_DOMAIN
env:
SURGE_LOGIN: $(SURGE_LOGIN)
SURGE_TOKEN: $(SURGE_TOKEN)
displayName: 'Deploy build result'
- job: publish_artifacts
condition: ne(variables['Build.Reason'], 'PullRequest')
steps:
- script: $(install_packages)
displayName: 'Install packages'
- script: npm run build
displayName: 'Run build'
- script: tar czvf build.tgz ./dist
displayName: 'Create archives'
- task: CopyFiles@2
inputs:
contents: build.tgz
targetFolder: $(Build.ArtifactStagingDirectory)
displayName: 'Copy archives to artifacts staging directory'
- task: PublishBuildArtifacts@1
inputs:
path: $(Build.ArtifactStagingDirectory)
displayName: 'Upload artifacts'