Skip to content

replace existing reusable test workflow #23

replace existing reusable test workflow

replace existing reusable test workflow #23

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:
fail-fast: false
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 and jest cache
uses: actions/cache@v3
with:
path: |
.turbo
.jest-cache
key: ${{ runner.os }}-turbo-and-jest-cache-${{ matrix.package }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-and-jest-cache-${{ matrix.package }}-
- name: Get number of CPU cores
id: cpu-cores
uses: SimenB/github-actions-cpu-cores@v1
- name: Test ${{ matrix.package }}
run: yarn turbo test:coverage --filter="${{ matrix.package }}" --cache-dir=.turbo --only --no-deps -- --maxWorkers=${{ steps.cpu-cores.outputs.count }} --ci
- name: move coverage
shell: bash
run: |
PACKAGE_NAME="$(echo ${{ matrix.package }} | cut -c 11-)"
## get package directory
mkdir -p coverage
yarn workspace ${{ matrix.package }} exec mv coverage/coverage-final.json ../../coverage/$PACKAGE_NAME.json
- uses: actions/upload-artifact@v3
with:
name: coverage-artifacts
path: coverage/
report-coverage:
runs-on: ubuntu-latest
needs: [test-turbo]
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: coverage-artifacts
path: coverage
- name: Merge Code Coverage
run: npx nyc merge coverage/ merged-output/merged-coverage.json
- uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
directory: merged-output
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}