Skip to content

feat(ci): refactor workflows #311

feat(ci): refactor workflows

feat(ci): refactor workflows #311

Workflow file for this run

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
build-chunk:
runs-on: ubuntu-latest
needs: chunks
concurrency:
group: ${{ github.ref }}-${{ format('chunk-{0}', join(fromJson(format('[{0}]', matrix.chunk)), ',')) }}
cancel-in-progress: false
strategy:
matrix:
chunk: ${{ fromJson(needs.chunks.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