@@ -5,27 +5,35 @@ workflow:
55 when : never
66 - when : always
77
8- default :
9- interruptible : true
10-
118variables :
9+ GIT_SUBMODULE_STRATEGY : recursive
1210 GH_PROJECT_PATH : " MatrixAI/${CI_PROJECT_NAME}"
1311 GH_PROJECT_URL : " https://${GITHUB_TOKEN}@github.com/${GH_PROJECT_PATH}.git"
14- GIT_SUBMODULE_STRATEGY : recursive
1512 # Cache .npm
1613 NPM_CONFIG_CACHE : " ${CI_PROJECT_DIR}/tmp/npm"
1714 # Prefer offline node module installation
1815 NPM_CONFIG_PREFER_OFFLINE : " true"
1916 # Homebrew cache only used by macos runner
2017 HOMEBREW_CACHE : " ${CI_PROJECT_DIR}/tmp/Homebrew"
2118
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+
2226# Cached directories shared between jobs & pipelines per-branch per-runner
2327cache :
2428 key : $CI_COMMIT_REF_SLUG
29+ # Preserve cache even if job fails
30+ when : ' always'
2531 paths :
2632 - ./tmp/npm/
2733 # Homebrew cache is only used by the macos runner
2834 - ./tmp/Homebrew
35+ # Chocolatey cache is only used by the windows runner
36+ - ./tmp/chocolatey/
2937 # `jest` cache is configured in jest.config.js
3038 - ./tmp/jest/
3139
@@ -42,9 +50,10 @@ check:lint:
4250 needs : []
4351 script :
4452 - >
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+ '
4857 rules :
4958 # Runs on feature and staging commits and ignores version commits
5059 - if : $CI_COMMIT_BRANCH =~ /^(?:feature.*|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
@@ -59,10 +68,9 @@ check:test:
5968 needs : []
6069 script :
6170 - >
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+ '
6674 artifacts :
6775 when : always
6876 reports :
@@ -87,20 +95,20 @@ build:merge:
8795 # Required for `gh pr create`
8896 - git remote add upstream "$GH_PROJECT_URL"
8997 - >
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+ '
104112 rules :
105113 # Runs on staging commits and ignores version commits
106114 - if : $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
@@ -112,10 +120,10 @@ build:linux:
112120 needs : []
113121 script :
114122 - >
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+ '
119127 artifacts :
120128 when : always
121129 reports :
@@ -140,10 +148,10 @@ build:windows:
140148 tags :
141149 - windows
142150 before_script :
143- - choco install nodejs --version=16.14.2 -y
144- - refreshenv
151+ - mkdir -Force "$CI_PROJECT_DIR/tmp"
145152 script :
146- - npm config set msvs_version 2019
153+ - .\scripts\choco-install.ps1
154+ - refreshenv
147155 - npm install --ignore-scripts
148156 - $env:Path = "$(npm bin);" + $env:Path
149157 - npm run build --verbose
@@ -165,15 +173,10 @@ build:macos:
165173 tags :
166174 - shared-macos-amd64
167175 image : macos-11-xcode-12
168- variables :
169- HOMEBREW_NO_INSTALL_UPGRADE : " true"
170- HOMEBREW_NO_INSTALL_CLEANUP : " true"
171- before_script :
176+ script :
172177 - eval "$(brew shellenv)"
173- - brew install node@16
174- - brew link --overwrite node@16
178+ - ./scripts/brew-install.sh
175179 - hash -r
176- script :
177180 - npm install --ignore-scripts
178181 - export PATH="$(npm bin):$PATH"
179182 - npm run build --verbose
@@ -197,14 +200,13 @@ build:prerelease:
197200 - build:macos
198201 # Don't interrupt publishing job
199202 interruptible : false
200- before_script :
201- - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
202203 script :
204+ - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
203205 - echo 'Publishing library prerelease'
204206 - >
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+ '
208210 after_script :
209211 - rm -f ./.npmrc
210212 rules :
@@ -234,12 +236,12 @@ integration:merge:
234236 GIT_DEPTH : 0
235237 script :
236238 - >
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+ '
243245 - git remote add upstream "$GH_PROJECT_URL"
244246 - git checkout origin/master
245247 # Merge up to the current commit (not the latest commit)
@@ -260,14 +262,13 @@ release:distribution:
260262 - integration:merge
261263 # Don't interrupt publishing job
262264 interruptible : false
263- before_script :
264- - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
265265 script :
266+ - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
266267 - echo 'Publishing library'
267268 - >
268- nix-shell --run '
269- npm publish --access public;
270- '
269+ nix-shell --arg ci true --run '
270+ npm publish --access public;
271+ '
271272 after_script :
272273 - rm -f ./.npmrc
273274 rules :
0 commit comments