@@ -5,27 +5,35 @@ workflow:
5
5
when : never
6
6
- when : always
7
7
8
- default :
9
- interruptible : true
10
-
11
8
variables :
9
+ GIT_SUBMODULE_STRATEGY : recursive
12
10
GH_PROJECT_PATH : " MatrixAI/${CI_PROJECT_NAME}"
13
11
GH_PROJECT_URL : " https://${GITHUB_TOKEN}@github.com/${GH_PROJECT_PATH}.git"
14
- GIT_SUBMODULE_STRATEGY : recursive
15
12
# Cache .npm
16
13
NPM_CONFIG_CACHE : " ${CI_PROJECT_DIR}/tmp/npm"
17
14
# Prefer offline node module installation
18
15
NPM_CONFIG_PREFER_OFFLINE : " true"
19
16
# Homebrew cache only used by macos runner
20
17
HOMEBREW_CACHE : " ${CI_PROJECT_DIR}/tmp/Homebrew"
21
18
19
+ default :
20
+ interruptible : true
21
+ before_script :
22
+ # Replace this in windows runners that use powershell
23
+ # with `mkdir -Force "$CI_PROJECT_DIR/tmp"`
24
+ - mkdir -p "$CI_PROJECT_DIR/tmp"
25
+
22
26
# Cached directories shared between jobs & pipelines per-branch per-runner
23
27
cache :
24
28
key : $CI_COMMIT_REF_SLUG
29
+ # Preserve cache even if job fails
30
+ when : ' always'
25
31
paths :
26
32
- ./tmp/npm/
27
33
# Homebrew cache is only used by the macos runner
28
34
- ./tmp/Homebrew
35
+ # Chocolatey cache is only used by the windows runner
36
+ - ./tmp/chocolatey/
29
37
# `jest` cache is configured in jest.config.js
30
38
- ./tmp/jest/
31
39
@@ -42,9 +50,10 @@ check:lint:
42
50
needs : []
43
51
script :
44
52
- >
45
- nix-shell --run '
46
- npm run lint;
47
- '
53
+ nix-shell --arg ci true --run '
54
+ npm run lint;
55
+ npm run lint-shell;
56
+ '
48
57
rules :
49
58
# Runs on feature and staging commits and ignores version commits
50
59
- if : $CI_COMMIT_BRANCH =~ /^(?:feature.*|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
@@ -59,10 +68,9 @@ check:test:
59
68
needs : []
60
69
script :
61
70
- >
62
- nix-shell --run '
63
- npm run build --verbose;
64
- npm test -- --ci --coverage;
65
- '
71
+ nix-shell --arg ci true --run '
72
+ npm test -- --ci --coverage;
73
+ '
66
74
artifacts :
67
75
when : always
68
76
reports :
@@ -87,20 +95,20 @@ build:merge:
87
95
# Required for `gh pr create`
88
96
- git remote add upstream "$GH_PROJECT_URL"
89
97
- >
90
- nix-shell -I nixpkgs=./pkgs.nix --packages gitAndTools.gh --run '
91
- gh pr create \
92
- --head staging \
93
- --base master \
94
- --title "ci: merge staging to master" \
95
- --body "This is an automatic PR generated by the pipeline CI/CD. This will be automatically fast-forward merged if successful." \
96
- --assignee "@me" \
97
- --no-maintainer-edit \
98
- --repo "$GH_PROJECT_PATH" || true;
99
- printf "Pipeline Attempt on ${CI_PIPELINE_ID} for ${CI_COMMIT_SHA}\n\n${CI_PIPELINE_URL}" \
100
- | gh pr comment staging \
101
- --body-file - \
102
- --repo "$GH_PROJECT_PATH";
103
- '
98
+ nix-shell --arg ci true --run '
99
+ gh pr create \
100
+ --head staging \
101
+ --base master \
102
+ --title "ci: merge staging to master" \
103
+ --body "This is an automatic PR generated by the pipeline CI/CD. This will be automatically fast-forward merged if successful." \
104
+ --assignee "@me" \
105
+ --no-maintainer-edit \
106
+ --repo "$GH_PROJECT_PATH" || true;
107
+ printf "Pipeline Attempt on ${CI_PIPELINE_ID} for ${CI_COMMIT_SHA}\n\n${CI_PIPELINE_URL}" \
108
+ | gh pr comment staging \
109
+ --body-file - \
110
+ --repo "$GH_PROJECT_PATH";
111
+ '
104
112
rules :
105
113
# Runs on staging commits and ignores version commits
106
114
- if : $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
@@ -112,10 +120,10 @@ build:linux:
112
120
needs : []
113
121
script :
114
122
- >
115
- nix-shell --run '
116
- npm run build --verbose;
117
- npm test -- --ci --coverage;
118
- '
123
+ nix-shell --arg ci true --run '
124
+ npm run build --verbose;
125
+ npm test -- --ci --coverage;
126
+ '
119
127
artifacts :
120
128
when : always
121
129
reports :
@@ -140,10 +148,10 @@ build:windows:
140
148
tags :
141
149
- windows
142
150
before_script :
143
- - choco install nodejs --version=16.14.2 -y
144
- - refreshenv
151
+ - mkdir -Force "$CI_PROJECT_DIR/tmp"
145
152
script :
146
- - npm config set msvs_version 2019
153
+ - .\scripts\choco-install.ps1
154
+ - refreshenv
147
155
- npm install --ignore-scripts
148
156
- $env:Path = "$(npm bin);" + $env:Path
149
157
- npm run build --verbose
@@ -165,15 +173,10 @@ build:macos:
165
173
tags :
166
174
- shared-macos-amd64
167
175
image : macos-11-xcode-12
168
- variables :
169
- HOMEBREW_NO_INSTALL_UPGRADE : " true"
170
- HOMEBREW_NO_INSTALL_CLEANUP : " true"
171
- before_script :
176
+ script :
172
177
- eval "$(brew shellenv)"
173
- - brew install node@16
174
- - brew link --overwrite node@16
178
+ - ./scripts/brew-install.sh
175
179
- hash -r
176
- script :
177
180
- npm install --ignore-scripts
178
181
- export PATH="$(npm bin):$PATH"
179
182
- npm run build --verbose
@@ -197,14 +200,13 @@ build:prerelease:
197
200
- build:macos
198
201
# Don't interrupt publishing job
199
202
interruptible : false
200
- before_script :
201
- - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
202
203
script :
204
+ - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
203
205
- echo 'Publishing library prerelease'
204
206
- >
205
- nix-shell --run '
206
- npm publish --tag prerelease --access public;
207
- '
207
+ nix-shell --arg ci true --run '
208
+ npm publish --tag prerelease --access public;
209
+ '
208
210
after_script :
209
211
- rm -f ./.npmrc
210
212
rules :
@@ -234,12 +236,12 @@ integration:merge:
234
236
GIT_DEPTH : 0
235
237
script :
236
238
- >
237
- nix-shell -I nixpkgs=./pkgs.nix --packages gitAndTools.gh --run '
238
- printf "Pipeline Succeeded on ${CI_PIPELINE_ID} for ${CI_COMMIT_SHA}\n\n${CI_PIPELINE_URL}" \
239
- | gh pr comment staging \
240
- --body-file - \
241
- --repo "$GH_PROJECT_PATH";
242
- '
239
+ nix-shell --arg ci true --run '
240
+ printf "Pipeline Succeeded on ${CI_PIPELINE_ID} for ${CI_COMMIT_SHA}\n\n${CI_PIPELINE_URL}" \
241
+ | gh pr comment staging \
242
+ --body-file - \
243
+ --repo "$GH_PROJECT_PATH";
244
+ '
243
245
- git remote add upstream "$GH_PROJECT_URL"
244
246
- git checkout origin/master
245
247
# Merge up to the current commit (not the latest commit)
@@ -260,14 +262,13 @@ release:distribution:
260
262
- integration:merge
261
263
# Don't interrupt publishing job
262
264
interruptible : false
263
- before_script :
264
- - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
265
265
script :
266
+ - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
266
267
- echo 'Publishing library'
267
268
- >
268
- nix-shell --run '
269
- npm publish --access public;
270
- '
269
+ nix-shell --arg ci true --run '
270
+ npm publish --access public;
271
+ '
271
272
after_script :
272
273
- rm -f ./.npmrc
273
274
rules :
0 commit comments