feat(ci): refactor workflows #240
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 | |
# TODO: Enable it back after testing. | |
# if: "${{ !github.event.pull_request.draft }}" | |
outputs: | |
CHUNKS: ${{ steps.chunkstep.outputs.CHUNKS }} | |
steps: | |
- 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(github.event.pull_request.labels.*.name, 'build-examples') || github.event_name == 'schedule' ) && 'true' || 'false' }} node ./.github/workflows/scripts/build-example-chunks.js | |
build-chunk: | |
runs-on: ubuntu-latest | |
needs: chunks | |
# TODO: Remove completely or make it shorter. | |
# .github/workflows/build-examples.yml (Line: 67, Col: 7): Concurrency group name must be less than 400 characters | |
# concurrency: | |
# group: ${{ github.ref }}-${{ matrix.chunk }} | |
# cancel-in-progress: true | |
strategy: | |
matrix: | |
chunk: ${{ fromJson(needs.chunks.outputs.CHUNKS) }} | |
steps: | |
- 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 | |