Skip to content

Commit 90bb8ce

Browse files
refactor(ci): convert to orchestrator pattern with reusable workflows
Replace inline test job with package-test.yaml workflow_call and add release orchestration jobs. Key changes: - Add dynamic package discovery in set-variables job using just - Replace hardcoded test matrix with fromJson(packages) output - Add test-release-packages job (PR dry-run validation) - Add release-packages job (main/beta actual releases) - Update deploy job to depend on release-packages Preserves all existing conditional logic, concurrency controls, and workflow_dispatch job selection. Matrix now dynamically discovers packages instead of hardcoded list.
1 parent d46d705 commit 90bb8ce

File tree

1 file changed

+78
-44
lines changed

1 file changed

+78
-44
lines changed

.github/workflows/ci.yaml

Lines changed: 78 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ jobs:
8787
deploy_environment: ${{ steps.set-variables.outputs.deploy_environment }}
8888
checkout_ref: ${{ steps.set-variables.outputs.checkout_ref }}
8989
checkout_rev: ${{ steps.set-variables.outputs.checkout_rev }}
90+
packages: ${{ steps.discover-packages.outputs.packages }}
9091

9192
steps:
9293
- name: Set action variables
@@ -140,6 +141,23 @@ jobs:
140141
echo "CHECKOUT_REF=$CHECKOUT_REF" >> $GITHUB_OUTPUT
141142
echo "CHECKOUT_REV=$CHECKOUT_REV" >> $GITHUB_OUTPUT
142143
144+
- name: Checkout for package discovery
145+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/checkout@v4
146+
with:
147+
sparse-checkout: |
148+
packages
149+
justfile
150+
sparse-checkout-cone-mode: false
151+
152+
- name: Discover packages
153+
id: discover-packages
154+
run: |
155+
# Install just for package discovery
156+
curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /usr/local/bin
157+
PACKAGES=$(just list-packages-json)
158+
echo "packages=$PACKAGES" >> $GITHUB_OUTPUT
159+
echo "Discovered packages: $PACKAGES"
160+
143161
nix:
144162
runs-on: ${{ matrix.os }}
145163
strategy:
@@ -189,57 +207,73 @@ jobs:
189207
(github.event_name != 'workflow_dispatch' ||
190208
inputs.job == '' ||
191209
inputs.job == 'test')
192-
runs-on: ubuntu-latest
193210
strategy:
194211
matrix:
195-
package:
196-
- name: docs
197-
path: packages/docs
212+
package: ${{ fromJson(needs.set-variables.outputs.packages) }}
198213
concurrency:
199214
group: test-${{ matrix.package.name }}-${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.ref_name }}
200215
cancel-in-progress: true
201-
steps:
202-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/checkout@v4
203-
- name: Setup Nix
204-
uses: ./.github/actions/setup-nix
205-
env:
206-
SOPS_AGE_KEY: ${{ secrets.SOPS_AGE_KEY }}
207-
with:
208-
installer: ${{ inputs.nix_installer || 'quick' }}
209-
system: x86_64-linux
210-
setup-cachix: true
211-
- name: Install dependencies
212-
run: nix develop -c just install
213-
- name: Run unit tests with coverage
214-
run: nix develop -c just test-coverage
215-
- name: Build for E2E tests
216-
run: nix develop -c just build
217-
- name: Run E2E tests
218-
run: nix develop -c just test-e2e
219-
- name: Upload build artifacts
220-
uses: actions/upload-artifact@v4
221-
with:
222-
name: dist-${{ matrix.package.name }}
223-
path: ${{ matrix.package.path }}/dist/
224-
retention-days: 7
225-
include-hidden-files: true
226-
- name: Upload test results
227-
if: always()
228-
uses: actions/upload-artifact@v4
229-
with:
230-
name: playwright-report-${{ matrix.package.name }}
231-
path: ${{ matrix.package.path }}/playwright-report/
232-
retention-days: 7
233-
- name: Upload coverage
234-
if: always()
235-
uses: actions/upload-artifact@v4
236-
with:
237-
name: coverage-${{ matrix.package.name }}
238-
path: ${{ matrix.package.path }}/coverage/
239-
retention-days: 7
216+
uses: ./.github/workflows/package-test.yaml
217+
with:
218+
package-name: ${{ matrix.package.name }}
219+
package-path: ${{ matrix.package.path }}
220+
debug-enabled: ${{ needs.set-variables.outputs.debug }}
221+
nix-installer: ${{ inputs.nix_installer || 'quick' }}
222+
secrets:
223+
SOPS_AGE_KEY: ${{ secrets.SOPS_AGE_KEY }}
224+
225+
test-release-packages:
226+
needs: [set-variables, test]
227+
if: ${{ github.event_name == 'pull_request' && needs.set-variables.outputs.skip_ci != 'true' }}
228+
strategy:
229+
fail-fast: false
230+
matrix:
231+
package: ${{ fromJson(needs.set-variables.outputs.packages) }}
232+
concurrency:
233+
group: test-release-${{ matrix.package.name }}-${{ github.workflow }}-${{ github.event.pull_request.number }}
234+
cancel-in-progress: true
235+
permissions:
236+
contents: write
237+
id-token: write
238+
uses: ./.github/workflows/package-release.yaml
239+
with:
240+
package-path: ${{ matrix.package.path }}
241+
package-name: ${{ matrix.package.name }}
242+
release-dry-run: true
243+
debug-enabled: ${{ needs.set-variables.outputs.debug == 'true' }}
244+
checkout-ref: ${{ needs.set-variables.outputs.checkout_ref }}
245+
secrets:
246+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
247+
248+
release-packages:
249+
needs: [set-variables, test, nix]
250+
if: |
251+
github.repository_owner == 'sciexp' &&
252+
(github.event_name == 'push' || github.event_name == 'workflow_dispatch') &&
253+
(github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta') &&
254+
needs.set-variables.outputs.skip_ci != 'true'
255+
strategy:
256+
fail-fast: false
257+
matrix:
258+
package: ${{ fromJson(needs.set-variables.outputs.packages) }}
259+
concurrency:
260+
group: release-${{ matrix.package.name }}-${{ github.workflow }}-${{ github.ref_name }}
261+
cancel-in-progress: true
262+
permissions:
263+
contents: write
264+
id-token: write
265+
uses: ./.github/workflows/package-release.yaml
266+
with:
267+
package-path: ${{ matrix.package.path }}
268+
package-name: ${{ matrix.package.name }}
269+
release-dry-run: false
270+
debug-enabled: ${{ needs.set-variables.outputs.debug == 'true' }}
271+
checkout-ref: ${{ needs.set-variables.outputs.checkout_ref }}
272+
secrets:
273+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
240274

241275
deploy:
242-
needs: [set-variables, nix, test]
276+
needs: [set-variables, nix, test, release-packages]
243277
if: |
244278
!cancelled() &&
245279
needs.set-variables.outputs.skip_ci != 'true' &&

0 commit comments

Comments
 (0)