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