Skip to content

Commit

Permalink
add on push branch workflow for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
peterstarling committed Feb 1, 2024
1 parent 304ec82 commit 64b760c
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/scripts/manage-workflows/create-test-matrix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// import execSync
const { execSync } = require('child_process');

// run turborepo dry run to get the list of tasks
const { tasks } = JSON.parse(
execSync(
'yarn turbo test --only --filter="!@asap-hub/contentful-app-*" --dry-run=json',
).toString(),
);

// create a matrix of tasks
const taskList = tasks
.filter((task) => task.command !== '<NONEXISTENT>')
.map(({ package }) => ({ package }));

// print the matrix, stringify the json
console.log(`${JSON.stringify({ include: taskList })}`);
41 changes: 41 additions & 0 deletions .github/workflows/on-push-branch-turbo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Pipeline branch - test turborepo

on:
push:
branches:
- feat/asap-285-use-turbo-for-tests

jobs:
setup-turbo:
runs-on: ubuntu-latest
environment: Branch
outputs:
matrix: ${{ steps.setup.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Re-Build
uses: ./.github/actions/build-rebuild
- name: Setup turborepo test pipeline
id: setup
run: |
MATRIX=$(yarn node ./.github/scripts/manage-workflows/create-test-matrix.js)
echo $MATRIX
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
test-turbo:
needs: setup-turbo
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.setup-turbo.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Re-Build
uses: ./.github/actions/build-rebuild
- name: Cache .turbo
uses: actions/cache@v3
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ matrix.package }}
- name: Test ${{ matrix.package }}
run: yarn turbo test --filter="${{ matrix.package }}" --cache-dir=.turbo --only

0 comments on commit 64b760c

Please sign in to comment.