-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathazure-pipelines.yml
More file actions
155 lines (133 loc) · 4.26 KB
/
azure-pipelines.yml
File metadata and controls
155 lines (133 loc) · 4.26 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# Node.js with Angular - staged pipeline (best-practice: npm ci per stage + npm cache)
trigger:
- main
pr:
branches:
include:
- main
variables:
nodeVersion: '20.x'
npm_config_cache: $(Pipeline.Workspace)/.npm
stages:
- stage: Init
displayName: 'Init'
jobs:
- job: connectivity
displayName: 'Check Connectivity'
pool:
vmImage: ubuntu-latest
steps:
- task: NodeTool@0
inputs:
versionSpec: '$(nodeVersion)'
displayName: 'Use Node.js $(nodeVersion)'
- script: |
# Check GitHub connectivity
echo "Checking GitHub connectivity..."
curl -s -o /dev/null -w "GitHub Status: %{http_code}\n" https://api.github.com/
# Check npm registry
echo "Checking npm registry..."
npm ping
# Show npm config
echo "npm configuration:"
npm config list
# Verify git remote
echo "Git remote info:"
git remote -v
displayName: 'Check GitHub and npm connectivity'
- stage: Lint
displayName: 'Lint'
dependsOn: Init
condition: succeeded()
jobs:
- job: lint
displayName: 'Run lint'
pool:
vmImage: ubuntu-latest
steps:
- task: NodeTool@0
inputs:
versionSpec: '$(nodeVersion)'
displayName: 'Use Node.js $(nodeVersion)'
- task: Cache@2
inputs:
key: 'npm | "$(Agent.OS)" | package-lock.json'
path: $(npm_config_cache)
restoreKeys: |
npm | "$(Agent.OS)"
displayName: 'Cache npm'
- script: npm ci
displayName: 'Install dependencies (npm ci)'
- script: |
npx -y @angular/cli@$(nodeVersion) version || true
npm run lint
displayName: 'Run lint'
- stage: Test
displayName: 'Test'
dependsOn: Init
condition: succeeded()
jobs:
- job: test
displayName: 'Unit tests'
pool:
vmImage: ubuntu-latest
steps:
- task: NodeTool@0
inputs:
versionSpec: '$(nodeVersion)'
- task: Cache@2
inputs:
key: 'npm | "$(Agent.OS)" | package-lock.json'
path: $(npm_config_cache)
restoreKeys: |
npm | "$(Agent.OS)"
displayName: 'Cache npm'
- script: npm ci
displayName: 'Install dependencies (npm ci)'
- script: |
# Run unit tests in headless Chrome and produce coverage
npm run test:headless
displayName: 'Run unit tests (headless)'
- script: |
# Run e2e tests in headless Chrome
npm run e2e:headless
displayName: 'Run e2e tests (headless)'
- stage: Build
displayName: 'Build'
dependsOn:
- Lint
- Test
condition: succeeded()
jobs:
- job: build
displayName: 'Build and publish'
pool:
vmImage: ubuntu-latest
steps:
- task: NodeTool@0
inputs:
versionSpec: '$(nodeVersion)'
- task: Cache@2
inputs:
key: 'npm | "$(Agent.OS)" | package-lock.json'
path: $(npm_config_cache)
restoreKeys: |
npm | "$(Agent.OS)"
displayName: 'Cache npm'
- script: npm ci
displayName: 'Install dependencies (npm ci)'
- script: npm run build -- --configuration production
displayName: 'Build (production)'
- script: |
mkdir -p "$(Build.ArtifactStagingDirectory)/dist"
if [ -d dist/text-compare-angular ]; then
cp -r dist/text-compare-angular/* "$(Build.ArtifactStagingDirectory)/dist/"
else
cp -r dist/* "$(Build.ArtifactStagingDirectory)/dist/"
fi
displayName: 'Stage build artifacts'
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)/dist'
artifact: 'app-dist'
displayName: 'Publish pipeline artifact'