diff --git a/.github/scripts/manage-workflows/create-test-matrix.js b/.github/scripts/manage-workflows/create-test-matrix.js new file mode 100644 index 00000000000..aa226d88445 --- /dev/null +++ b/.github/scripts/manage-workflows/create-test-matrix.js @@ -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 !== '') + .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')}`, +); diff --git a/.github/workflows/on-push-branch-turbo.yml b/.github/workflows/on-push-branch-turbo.yml new file mode 100644 index 00000000000..8825abf06cb --- /dev/null +++ b/.github/workflows/on-push-branch-turbo.yml @@ -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 }} +