|
| 1 | +name: Test |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + |
| 11 | +jobs: |
| 12 | + |
| 13 | + list: |
| 14 | + name: List |
| 15 | + runs-on: ubuntu-latest |
| 16 | + outputs: |
| 17 | + package: ${{ steps.turbo-ls.outputs.package }} |
| 18 | + steps: |
| 19 | + - name: Checkout Repo |
| 20 | + uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Setup Node.js 22.x |
| 23 | + uses: actions/setup-node@v4 |
| 24 | + with: |
| 25 | + node-version: 22.x |
| 26 | + |
| 27 | + - name: Run turbo ls |
| 28 | + id: turbo-ls |
| 29 | + run: | |
| 30 | + ls_output=$(npx turbo ls --output=json) |
| 31 | + ls_json=$(echo "$ls_output" | jq -c '.packages.items') |
| 32 | + echo "package=$ls_json" >> $GITHUB_OUTPUT |
| 33 | +
|
| 34 | + test: |
| 35 | + needs: list |
| 36 | + name: Test |
| 37 | + runs-on: ubuntu-latest |
| 38 | + strategy: |
| 39 | + matrix: |
| 40 | + include: ${{ fromJSON(needs.list.outputs.package) }} |
| 41 | + steps: |
| 42 | + - name: Checkout Repo |
| 43 | + uses: actions/checkout@v4 |
| 44 | + |
| 45 | + - name: Cache turbo build setup |
| 46 | + uses: actions/cache@v4 |
| 47 | + with: |
| 48 | + path: .turbo |
| 49 | + key: ${{ runner.os }}-turbo-${{ github.sha }} |
| 50 | + restore-keys: | |
| 51 | + ${{ runner.os }}-turbo- |
| 52 | +
|
| 53 | + - name: Setup Node.js 22.x |
| 54 | + uses: actions/setup-node@v4 |
| 55 | + with: |
| 56 | + node-version: 22.x |
| 57 | + |
| 58 | + - name: Setup pnpm |
| 59 | + uses: pnpm/action-setup@v4 |
| 60 | + |
| 61 | + - name: Install Dependencies |
| 62 | + run: pnpm i |
| 63 | + |
| 64 | + - name: Run Test Parallel |
| 65 | + run: pnpm run test --filter=${{ matrix.name }}... |
| 66 | + |
| 67 | + - name: Codecov Parallel |
| 68 | + uses: codecov/codecov-action@v5 |
| 69 | + with: |
| 70 | + fail_ci_if_error: true |
| 71 | + flags: ${{ matrix.name }} |
| 72 | + directory: ${{ matrix.path }} |
| 73 | + handle_no_reports_found: true |
| 74 | + env: |
| 75 | + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
| 76 | + |
| 77 | + results: |
| 78 | + needs: test |
| 79 | + name: Final Results |
| 80 | + runs-on: ubuntu-latest |
| 81 | + if: ${{ always() }} |
| 82 | + steps: |
| 83 | + - run: | |
| 84 | + result="${{ needs.test.result }}" |
| 85 | + if [[ $result == "success" || $result == "skipped" ]]; then |
| 86 | + exit 0 |
| 87 | + else |
| 88 | + exit 1 |
| 89 | + fi |
| 90 | +
|
0 commit comments