Skip to content

Commit 7a75eca

Browse files
committed
feat: added library js workflows
1 parent 222203c commit 7a75eca

File tree

4 files changed

+491
-1
lines changed

4 files changed

+491
-1
lines changed
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: "CI / Library JS Feature"
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
# Lint the code
8+
feature-lint:
9+
name: "Feature / Lint"
10+
runs-on: ubuntu-latest
11+
container:
12+
image: ghcr.io/matrixai/github-runner
13+
permissions:
14+
packages: read
15+
contents: read
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Run linting
19+
run: |
20+
nix develop .#ci --command bash -c $'
21+
npm run lint
22+
'
23+
24+
# Build the dist
25+
feature-build:
26+
name: "Feature / Build"
27+
runs-on: ubuntu-latest
28+
container:
29+
image: ghcr.io/matrixai/github-runner
30+
permissions:
31+
packages: read
32+
contents: read
33+
actions: write
34+
steps:
35+
- uses: actions/checkout@v4
36+
- name: Run build
37+
run: |
38+
nix develop .#ci --command bash -c $'
39+
npm run build --verbose
40+
'
41+
- name: Upload Build
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: dist
45+
path: ./dist
46+
47+
# Test the dist
48+
feature-test:
49+
name: "Feature / Test"
50+
runs-on: ubuntu-latest
51+
container:
52+
image: ghcr.io/matrixai/github-runner
53+
permissions:
54+
packages: read
55+
contents: read
56+
actions: write
57+
checks: write
58+
steps:
59+
- uses: actions/checkout@v4
60+
- name: Run tests
61+
run: |
62+
nix develop .#ci --command bash -c $'
63+
npm run test -- --ci --coverage
64+
'
65+
- name: Upload JUnit report
66+
if: success() || failure()
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: junit-report
70+
path: tmp/junit/junit.xml
71+
- name: Publish JUnit Report
72+
uses: mikepenz/action-junit-report@v5
73+
with:
74+
report_paths: tmp/junit/junit.xml
75+
- name: Upload Cobertura report
76+
if: success() || failure()
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: coverage-report
80+
path: tmp/coverage/cobertura-coverage.xml
81+
82+
# Bench the dist
83+
feature-bench:
84+
name: "Feature / Bench"
85+
runs-on: ubuntu-latest
86+
container:
87+
image: ghcr.io/matrixai/github-runner
88+
permissions:
89+
packages: read
90+
contents: read
91+
actions: write
92+
steps:
93+
- uses: actions/checkout@v4
94+
- name: Run bench
95+
run: |
96+
nix develop .#ci --command bash -c $'
97+
npm run bench --if-present
98+
'
99+
- name: Upload Bench
100+
uses: actions/upload-artifact@v4
101+
with:
102+
name: metrics-report
103+
path: ./benches/results/metrics.txt
104+
if-no-files-found: ignore
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
name: "CI / Library JS Staging"
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
GH_TOKEN:
7+
required: true
8+
GIT_AUTHOR_EMAIL:
9+
required: true
10+
GIT_AUTHOR_NAME:
11+
required: true
12+
GIT_COMMITTER_EMAIL:
13+
required: true
14+
GIT_COMMITTER_NAME:
15+
required: true
16+
17+
jobs:
18+
# Lint the code
19+
staging-lint:
20+
name: "Staging / Lint"
21+
runs-on: ubuntu-latest
22+
container:
23+
image: ghcr.io/matrixai/github-runner
24+
permissions:
25+
packages: read
26+
contents: read
27+
steps:
28+
- uses: actions/checkout@v4
29+
- name: Run linting
30+
run: |
31+
nix develop .#ci --command bash -c $'
32+
npm run lint
33+
'
34+
35+
# Create the merge PR
36+
staging-merge-begin:
37+
name: "Staging / Merge Begin"
38+
runs-on: ubuntu-latest
39+
permissions:
40+
packages: read
41+
contents: read
42+
pull-requests: write
43+
steps:
44+
- uses: actions/checkout@v4
45+
- name: Create Pull Request from Staging to Master
46+
env:
47+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
48+
run: |
49+
gh pr create \
50+
--head staging \
51+
--base master \
52+
--title "ci: merge staging to master" \
53+
--body "This is an automatic PR generated by the CI/CD pipeline. This will be automatically fast-forward merged if successful." \
54+
--assignee "@me" \
55+
--no-maintainer-edit || true
56+
printf "Pipeline Attempt on $GITHUB_RUN_ID for $GITHUB_SHA\n\n$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" \
57+
| gh pr comment staging \
58+
--body-file - \
59+
--repo "$GITHUB_REPOSITORY"
60+
61+
# Build the distribution - JS is platform-agnostic
62+
staging-build:
63+
name: "Staging / Build"
64+
runs-on: ubuntu-latest
65+
container:
66+
image: ghcr.io/matrixai/github-runner
67+
permissions:
68+
packages: read
69+
contents: read
70+
actions: write
71+
steps:
72+
- uses: actions/checkout@v4
73+
- name: Run build
74+
run: |
75+
nix develop .#ci --command bash -c $'
76+
npm run build --verbose
77+
'
78+
- name: Upload Build
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: dist
82+
path: ./dist
83+
84+
# Build on every platform
85+
# This re-uses the built `./dist`, and run tests and benches
86+
staging-platforms:
87+
name: "Staging / Platforms"
88+
needs:
89+
- staging-build
90+
runs-on: ${{ matrix.os }}
91+
container:
92+
image: ${{ matrix.platform == 'linux' && 'ghcr.io/matrixai/github-runner' || null }}
93+
permissions:
94+
packages: read
95+
contents: read
96+
actions: write
97+
checks: write
98+
strategy:
99+
fail-fast: true
100+
matrix:
101+
include:
102+
- platform: linux
103+
os: ubuntu-latest
104+
env: {}
105+
script: |
106+
nix develop .#ci --command bash -c $'
107+
npm test -- --ci --coverage
108+
npm run bench --if-present
109+
'
110+
- platform: windows
111+
os: windows-latest
112+
env: {}
113+
script: |
114+
mkdir -Force "$CI_PROJECT_DIR/tmp"
115+
Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
116+
./scripts/choco-install.ps1
117+
refreshenv
118+
npm install --ignore-scripts
119+
$env:Path = "$(npm root)\.bin;" + $env:Path
120+
npm test -- --ci --coverage
121+
npm run bench --if-present
122+
- platform: macos
123+
os: macos-latest
124+
env: {}
125+
script: |
126+
mkdir -p "$CI_PROJECT_DIR/tmp"
127+
eval "$(brew shellenv)"
128+
./scripts/brew-install.sh
129+
hash -r
130+
npm install --ignore-scripts
131+
export PATH="$(npm root)/.bin:$PATH"
132+
npm test -- --ci --coverage
133+
npm run bench --if-present
134+
steps:
135+
- uses: actions/checkout@v4
136+
- uses: actions/download-artifact@v4
137+
with:
138+
name: dist
139+
path: ./dist
140+
- name: Build
141+
env: ${{ matrix.env }}
142+
run: ${{ matrix.script }}
143+
- name: Upload JUnit Report
144+
if: success() || failure()
145+
uses: actions/upload-artifact@v4
146+
with:
147+
name: junit-report-${{ matrix.platform }}
148+
path: ./tmp/junit/junit.xml
149+
- name: Publish JUnit Report
150+
uses: mikepenz/action-junit-report@v5
151+
with:
152+
check_name: JUnit Test Report - ${{matrix.platform}}
153+
report_paths: ./tmp/junit/junit.xml
154+
- name: Upload Cobertura report
155+
if: success() || failure()
156+
uses: actions/upload-artifact@v4
157+
with:
158+
name: coverage-report-${{ matrix.platform }}
159+
path: ./tmp/coverage/cobertura-coverage.xml
160+
- name: Upload Metrics Report
161+
if: success() || failure()
162+
uses: actions/upload-artifact@v4
163+
with:
164+
name: metrics-report-${{ matrix.platform }}
165+
path: ./benches/results/metrics.txt
166+
if-no-files-found: ignore
167+
168+
staging-merge-finish:
169+
name: "Staging / Merge Finish"
170+
needs:
171+
- staging-lint
172+
- staging-merge-begin
173+
- staging-build
174+
- staging-platforms
175+
runs-on: ubuntu-latest
176+
concurrency:
177+
group: integration-merge
178+
cancel-in-progress: true
179+
permissions:
180+
packages: read
181+
contents: write
182+
pull-requests: write
183+
steps:
184+
- uses: actions/checkout@v4
185+
with:
186+
fetch-depth: 0
187+
token: ${{ secrets.GH_TOKEN }}
188+
- name: Merge Pull Request from Staging to Master
189+
env:
190+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
191+
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
192+
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
193+
GIT_COMMITTER_EMAIL: ${{ secrets.GIT_COMMITTER_EMAIL }}
194+
GIT_COMMITTER_NAME: ${{ secrets.GIT_COMMITTER_NAME }}
195+
run: |
196+
printf "Pipeline Succeeded on $GITHUB_RUN_ID for $GITHUB_SHA\n\n$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" \
197+
| gh pr comment staging \
198+
--body-file - \
199+
--repo "$GITHUB_REPOSITORY"
200+
git checkout master
201+
git merge --ff-only "$GITHUB_SHA"
202+
git push origin master

0 commit comments

Comments
 (0)