Skip to content

Add pruning support in the pipeline for CI to aid with speed #391

Add pruning support in the pipeline for CI to aid with speed

Add pruning support in the pipeline for CI to aid with speed #391

Workflow file for this run

name: CI
on:
pull_request:
types: [opened, synchronize]
env:
HUSKY: 0
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
TURBO_TELEMETRY_DISABLED: 1
DO_NOT_TRACK: 1
# Needed for VScode test runner
DISPLAY: ':99.0'
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
changes:
runs-on: ubuntu-latest
env:
TURBO_RUN_FILTER: ${{ github.event_name == 'pull_request' && '...[origin/master]' || '...[HEAD^]' }}
# Required permissions
permissions:
pull-requests: read
# Set job outputs to values from filter step
outputs:
flat: ${{ steps.flat.outputs.result }}
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 0
lfs: true
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
cache: 'npm'
node-version: 20
- name: Install [email protected] & glob
run: |
npm i -g [email protected] glob
echo "PATH=$(npm config get config):$PATH" >> $GITHUB_ENV
- name: Verify turbo installation
shell: bash
run: |
source $GITHUB_ENV
turbo --version
- name: Debug TURBO_RUN_FILTER
run: echo "TURBO_RUN_FILTER is $TURBO_RUN_FILTER"
- name: Validate JSON Output
run: |
content=$(turbo build --filter=$TURBO_RUN_FILTER --dry-run=json)
echo $content | jq .
- name: Debug turbo command
run: |
set -x
turbo build --filter=$TURBO_RUN_FILTER --dry-run=json
set +x
- name: Verify turbo installation
run: which turbo
- name: Debug content
run: |
content=`turbo build --filter=$TURBO_RUN_FILTER --dry-run=json`
echo "Content is: $content"
- name: Changeset
id: changeset
run: |
content=`turbo build --filter=$TURBO_RUN_FILTER --dry-run=json`
content="${content//'%'/'%25'}"
content="${content//$'\n'/'%0A'}"
content="${content//$'\r'/'%0D'}"
echo "::set-output name=result::$content"
- name: Flat output
id: flat
run: |
filteredPkgs=`turbo build --filter=$TURBO_RUN_FILTER --dry-run=json | node ./scripts/diff.js`
echo "::set-output name=result::$filteredPkgs"
echo "$filteredPkgs"
verify:
name: Verify changes
needs: changes
runs-on: ubuntu-latest
if: ${{ needs.changes.outputs.flat != '[]' }}
defaults:
run:
shell: bash
working-directory: ./out
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 20
cache: "yarn"
- name: Install turbo
run: yarn global add [email protected]
- name: prune
run: turbo prune ${{ needs.changes.outputs.flat }}
working-directory: ./
- name: Turbo Cache
id: turbo-cache
uses: actions/cache@v3
with:
path: .turbo
key: turbo-${{ github.job }}-${{ github.head_ref }}-${{ github.sha }}
restore-keys: |
turbo-${{ github.job }}-${{ github.head_ref }}-
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Install dependencies
run: yarn --frozen-lockfile --immutable
- name: Linting
run: yarn lint
# verify that build scripts function correctly
- name: Build
run: yarn build
- name: Test
run: yarn run test
- uses: actions/upload-artifact@v3
if: always()
with:
name: cypress-artifacts
path: |
./**/cypress/snapshots
./**/cypress/screenshots