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 b22157d
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/scripts/manage-workflows/create-test-matrix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// 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 --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 and escape the quotes and escape newlines (replace \n with %0A)
console.log(
`${JSON.stringify({ include: taskList })
.replace(/"/g, '\\"')
.replace(/\n/g, '%0A')}`,
);
36 changes: 36 additions & 0 deletions .github/workflows/on-push-branch-turbo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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.packages }}
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=$( echo "$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: Test ${{ matrix.package }}
run: |
echo ${{ matrix.package }}

0 comments on commit b22157d

Please sign in to comment.