Skip to content

Commit 1dad4d5

Browse files
authored
Merge pull request #107 from MatrixAI/feature-ci
CI Integration
2 parents 0d7bc46 + 2ba5259 commit 1dad4d5

File tree

7 files changed

+506
-449
lines changed

7 files changed

+506
-449
lines changed

.github/workflows/ci.yml

Lines changed: 279 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,279 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- staging
7+
- feature*
8+
9+
jobs:
10+
check-lint:
11+
name: "Check / Lint"
12+
runs-on: ubuntu-latest
13+
container:
14+
image: ghcr.io/matrixai/github-runner
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Run linting
18+
run: |
19+
nix develop --command bash -c $'
20+
npm run lint
21+
npm run lint-shell
22+
'
23+
24+
check-test:
25+
name: "Check / Test"
26+
runs-on: ubuntu-latest
27+
container:
28+
image: ghcr.io/matrixai/github-runner
29+
steps:
30+
- uses: actions/checkout@v4
31+
- name: Run tests
32+
run: |
33+
nix develop .#ci --command bash -c $'
34+
npm run prebuild --verbose
35+
npm test -- --ci --coverage
36+
'
37+
- uses: actions/upload-artifact@v4
38+
with:
39+
name: coverage-report
40+
path: tmp/coverage/cobertura-coverage.xml
41+
42+
build-pull:
43+
name: "Build / Pull Request"
44+
runs-on: ubuntu-latest
45+
needs: [check-lint, check-test]
46+
if: github.ref == 'refs/heads/staging'
47+
steps:
48+
- uses: actions/checkout@v4
49+
- name: Create pull request
50+
env:
51+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
52+
run: |
53+
gh pr create \
54+
--head staging \
55+
--base master \
56+
--title "ci: merge staging to master" \
57+
--body "This is an automatic PR generated by the CI/CD pipeline. This will be automatically fast-forward merged if successful." \
58+
--assignee "@me" \
59+
--no-maintainer-edit || true
60+
printf "Pipeline Attempt on $GITHUB_RUN_ID for $GITHUB_SHA\n\n$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" \
61+
| gh pr comment staging \
62+
--body-file - \
63+
--repo "$GITHUB_REPOSITORY"
64+
65+
build-dist:
66+
name: "Build / Dist"
67+
runs-on: ubuntu-latest
68+
container:
69+
image: ghcr.io/matrixai/github-runner
70+
needs: [check-lint, check-test]
71+
if: github.ref == 'refs/heads/staging'
72+
steps:
73+
- uses: actions/checkout@v4
74+
- run: |
75+
nix develop .#ci --command bash -c $'
76+
npm run build --ignore-scripts --verbose
77+
'
78+
- uses: actions/upload-artifact@v4
79+
with:
80+
name: dist
81+
path: ./dist
82+
83+
build-platforms:
84+
name: "Build / Platforms"
85+
runs-on: ${{ matrix.os }}
86+
container:
87+
image: ${{ matrix.platform == 'linux' && 'ghcr.io/matrixai/github-runner' || null }}
88+
needs: build-dist
89+
if: github.ref == 'refs/heads/staging'
90+
strategy:
91+
fail-fast: false
92+
matrix:
93+
include:
94+
- platform: linux
95+
os: ubuntu-latest
96+
env:
97+
npm_config_arch: "x64"
98+
RUST_BACKTRACE: "1"
99+
script: |
100+
nix develop .#ci --command bash -c $'
101+
npm run prebuild --verbose -- --production
102+
npm test -- --ci --coverage
103+
npm run bench
104+
'
105+
- platform: windows
106+
os: windows-latest
107+
env:
108+
npm_config_arch: "x64"
109+
RUST_BACKTRACE: "1"
110+
LIBCLANG_PATH: "C:\\Program Files\\LLVM\\bin"
111+
script: |
112+
mkdir -Force "$CI_PROJECT_DIR/tmp"
113+
Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
114+
./scripts/choco-install.ps1
115+
refreshenv
116+
npm install --ignore-scripts
117+
$env:Path = "$(npm root)\.bin;" + $env:Path
118+
npm run prebuild --verbose -- --production
119+
npm test -- --ci --coverage
120+
npm run bench
121+
- platform: macos
122+
os: macos-latest
123+
env:
124+
RUST_BACKTRACE: "1"
125+
script: |
126+
eval "$(brew shellenv)"
127+
./scripts/brew-install.sh
128+
hash -r
129+
npm install --ignore-scripts
130+
export PATH="$(npm root)/.bin:$PATH"
131+
export PATH="$HOME/.cargo/bin:$PATH"
132+
npm run prebuild --verbose -- --arch x64 --production
133+
npm run prebuild --verbose -- --arch arm64 --production
134+
lipo -create -output prebuild/quic-darwin-x64+arm64.node prebuild/quic-darwin-arm64.node prebuild/quic-darwin-x64.node
135+
rm -rf node_modules/@matrixai/quic-*
136+
npm test -- --ci --coverage
137+
npm run bench
138+
steps:
139+
- uses: actions/checkout@v4
140+
- uses: actions/setup-node@v4
141+
with:
142+
node-version: '20'
143+
- uses: actions/download-artifact@v4
144+
with:
145+
name: dist
146+
path: ./dist
147+
- name: Build
148+
env: ${{ matrix.env }}
149+
run: ${{ matrix.script }}
150+
- uses: actions/upload-artifact@v4
151+
with:
152+
name: builds-${{ matrix.platform }}
153+
path: ./builds
154+
- run: rm -f ./.npmrc
155+
156+
build-prerelease:
157+
name: "Build / Pre-release"
158+
runs-on: ubuntu-latest
159+
container:
160+
image: ghcr.io/matrixai/github-runner
161+
concurrency:
162+
group: build-prerelease
163+
cancel-in-progress: false
164+
needs: [check-lint, check-test]
165+
if: >
166+
github.ref == 'refs/heads/staging' &&
167+
startsWith(github.ref, 'refs/tags/v') &&
168+
contains(github.ref, '-')
169+
steps:
170+
- uses: actions/checkout@v4
171+
- uses: actions/download-artifact@v4
172+
with:
173+
pattern: builds*
174+
path: builds
175+
merge-multiple: true
176+
- name: Run pre-release
177+
env:
178+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
179+
run: |
180+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
181+
echo 'Publishing library prerelease'
182+
nix develop .#ci --command bash -c $'
183+
npm publish --tag prerelease --access public
184+
'
185+
for d in prebuild/*; do
186+
tar \
187+
--create \
188+
--verbose \
189+
--file="prebuild/$(basename $d).tar" \
190+
--directory=prebuild \
191+
"$(basename $d)"
192+
done
193+
nix develop .#ci --command bash -c $'
194+
gh release \
195+
create "$GITHUB_REF_NAME" \
196+
prebuild/*.tar \
197+
--title "$GITHUB_REF_NAME-$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
198+
--notes "" \
199+
--prerelease \
200+
--target staging \
201+
--repo "$GITHUB_REPOSITORY"
202+
'
203+
rm -f ./.npmrc
204+
205+
integration-merge:
206+
name: "Integration / Merge"
207+
runs-on: ubuntu-latest
208+
concurrency:
209+
group: integration-merge
210+
cancel-in-progress: true
211+
needs: [build-pull, build-platforms]
212+
if: github.ref == 'refs/heads/staging'
213+
steps:
214+
- uses: actions/checkout@v4
215+
with:
216+
fetch-depth: 0
217+
- name: Merge into master
218+
env:
219+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
220+
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
221+
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
222+
GIT_COMMITTER_EMAIL: ${{ secrets.GIT_COMMITTER_EMAIL }}
223+
GIT_COMMITTER_NAME: ${{ secrets.GIT_COMMITTER_NAME }}
224+
run: |
225+
printf "Pipeline Succeeded on $GITHUB_RUN_ID for $GITHUB_SHA\n\n$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" \
226+
| gh pr comment staging \
227+
--body-file - \
228+
--repo "$GITHUB_REPOSITORY"
229+
git checkout master
230+
git merge --ff-only "$GITHUB_SHA"
231+
git push origin master
232+
233+
release-distribution:
234+
name: "Release / Distribution"
235+
runs-on: ubuntu-latest
236+
container:
237+
image: ghcr.io/matrixai/github-runner
238+
concurrency:
239+
group: release-distribution
240+
cancel-in-progress: false
241+
needs: integration-merge
242+
if: >
243+
github.ref == 'refs/heads/staging' &&
244+
startsWith(github.ref, 'refs/tags/v') &&
245+
!contains(github.ref, '-')
246+
steps:
247+
- uses: actions/checkout@v4
248+
- uses: actions/download-artifact@v4
249+
with:
250+
pattern: builds*
251+
path: builds
252+
merge-multiple: true
253+
- name: Run release
254+
env:
255+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
256+
run: |
257+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
258+
echo 'Publishing library'
259+
nix develop .#ci --command bash -c $'
260+
npm publish --access public
261+
'
262+
for d in prebuild/*; do
263+
tar \
264+
--create \
265+
--verbose \
266+
--file="prebuild/$(basename $d).tar" \
267+
--directory=prebuild \
268+
"$(basename $d)"
269+
done
270+
nix develop .#ci --command bash -c $'
271+
gh release \
272+
create "$GITHUB_REF_NAME" \
273+
prebuild/*.tar \
274+
--title "$GITHUB_REF_NAME-$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
275+
--notes "" \
276+
--target master \
277+
--repo "$GITHUB_REPOSITORY"
278+
'
279+
rm -f ./.npmrc

.github/workflows/codesee-arch-diagram.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)