feat(ci): refactor workflows #299
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build All Examples | |
on: | |
pull_request: | |
paths: | |
- "packages/**" | |
- "examples/**" | |
types: | |
- labeled | |
- synchronize | |
- opened | |
- reopened | |
- ready_for_review | |
push: | |
branches: | |
- master | |
schedule: | |
- cron: "0 6 * * *" | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: "Environment to run tests against" | |
type: environment | |
required: false | |
jobs: | |
chunks: | |
runs-on: ubuntu-latest | |
concurrency: | |
group: ${{ github.ref }}-build-examples | |
cancel-in-progress: true | |
name: Create Example Chunks | |
if: "${{ !github.event.pull_request.draft }}" | |
outputs: | |
CHUNKS: ${{ steps.chunkstep.outputs.CHUNKS }} | |
steps: | |
- name: Get PR labels | |
id: pr-labels | |
uses: joerick/[email protected] | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v3 | |
with: | |
version: 9 | |
run_install: | | |
- recursive: false | |
args: [--ignore-scripts] | |
- name: Fetch commits | |
run: git fetch origin ${{ github.base_ref || 'master' }} --depth=1 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
cache: "pnpm" | |
- name: Split Into Chunks | |
id: chunkstep | |
run: CHUNKS=6 BASE_REF=${{ github.base_ref }} BUILD_ALL_EXAMPLES=${{ (contains(steps.pr-labels.outputs.labels, ' build-examples ') || github.event_name == 'schedule' || github.event_name == 'synchronize' ) && 'true' || 'false' }} node ./.github/workflows/scripts/build-example-chunks.js | |
calculate-chunk-hash: | |
runs-on: ubuntu-latest | |
needs: chunks | |
strategy: | |
matrix: | |
chunk: ${{ fromJson(needs.chunks.outputs.CHUNKS) }} | |
outputs: | |
chunk_hash: ${{ steps.calculate-chunk-hash.outputs.chunk_hash }} | |
CHUNKS: ${{ needs.chunks.outputs.CHUNKS }} | |
steps: | |
- name: Calculate CHUNK_HASH | |
id: calculate-chunk-hash | |
run: | | |
chunk_hash=$(cksum <<< "${{ github.ref }}-${{ matrix.chunk }}-${{ github.run_id }}-${{ github.run_attempt }}" | cut -f 1 -d ' ') | |
echo "::set-output name=chunk_hash::$chunk_hash" | |
build-chunk: | |
runs-on: ubuntu-latest | |
needs: calculate-chunk-hash | |
concurrency: | |
group: ${{ github.ref }}-${{ matrix.chunk }}-${{ needs.calculate-chunk-hash.outputs.chunk_hash }} | |
cancel-in-progress: true | |
strategy: | |
matrix: | |
chunk: ${{ fromJson(needs.calculate-chunk-hash.outputs.CHUNKS) }} | |
steps: | |
- name: Get PR labels | |
id: pr-labels | |
uses: joerick/[email protected] | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v3 | |
with: | |
version: 9 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
cache: "pnpm" | |
- name: Install Dependencies | |
run: | | |
pnpm install --ignore-scripts | |
pnpm cypress install | |
- name: Build | |
run: REFINE_NO_TELEMETRY=true pnpm build --no-bail --scope={${{ matrix.chunk }}} | |
- name: Get short SHA | |
id: slug | |
run: echo "::set-output name=sha7::$(echo ${GITHUB_SHA} | cut -c1-7)" | |
- name: Run E2E Tests | |
run: BASE_REF=${{ github.base_ref }} EXAMPLES=${{ matrix.chunk }} CYPRESS_PROJECT_ID=${{ secrets.CYPRESS_PROJECT_ID }} CYPRESS_RECORD_KEY=${{ secrets.CYPRESS_RECORD_KEY }} CI_BUILD_ID=refine-${{ github.ref_name }}-${{ steps.slug.outputs.sha7 }}-chunk-1-${{ github.run_attempt }} node ./.github/workflows/scripts/e2e-examples.js | |