Skip to content

Commit 5213724

Browse files
committed
WIP
1 parent a664ad4 commit 5213724

File tree

2 files changed

+275
-0
lines changed

2 files changed

+275
-0
lines changed

.github/workflows/library-js-staging.yml

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,188 @@ on:
44
workflow_call:
55

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

.github/workflows/library-js-tag.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,93 @@ on:
44
workflow_call:
55

66
jobs:
7+
# Build the distribution - JS is platform-agnostic
8+
build-dist:
9+
name: "Build / Dist"
10+
runs-on: ubuntu-latest
11+
container:
12+
image: ghcr.io/matrixai/github-runner
13+
permissions:
14+
packages: read
15+
contents: read
16+
actions: write
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Run build
20+
run: |
21+
nix develop .#ci --command bash -c $'
22+
npm run build --verbose
23+
'
24+
- name: Upload Build
25+
uses: actions/upload-artifact@v4
26+
with:
27+
name: dist
28+
path: ./dist
29+
30+
# Publish the prerelease
31+
prerelease-publish:
32+
name: "Pre-release / Publish"
33+
runs-on: ubuntu-latest
34+
container:
35+
image: ghcr.io/matrixai/github-runner
36+
concurrency:
37+
group: build-prerelease
38+
cancel-in-progress: false
39+
needs:
40+
- build-dist
41+
permissions:
42+
packages: read
43+
contents: read
44+
if: startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '-')
45+
steps:
46+
- uses: actions/checkout@v4
47+
- uses: actions/download-artifact@v4
48+
with:
49+
name: dist
50+
path: ./dist
51+
- name: Publishing library prerelease
52+
env:
53+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
54+
run: |
55+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
56+
nix develop .#ci --command bash -c $'
57+
npm publish --tag prerelease --access public
58+
'
59+
- name: Remove `.npmrc`
60+
if: success() || failure()
61+
run: |
62+
rm -f ./.npmrc
63+
64+
# Publish the release
65+
release-publish:
66+
name: "Release / Publish"
67+
runs-on: ubuntu-latest
68+
container:
69+
image: ghcr.io/matrixai/github-runner
70+
concurrency:
71+
group: release-distribution
72+
cancel-in-progress: false
73+
needs:
74+
- build-dist
75+
permissions:
76+
packages: read
77+
contents: read
78+
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-')
79+
steps:
80+
- uses: actions/checkout@v4
81+
- uses: actions/download-artifact@v4
82+
with:
83+
name: dist
84+
path: ./dist
85+
- name: Publishing library release
86+
env:
87+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
88+
run: |
89+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
90+
nix develop .#ci --command bash -c $'
91+
npm publish --access public
92+
'
93+
- name: Remove `.npmrc`
94+
if: success() || failure()
95+
run: |
96+
rm -f ./.npmrc

0 commit comments

Comments
 (0)