pankod/refine

View on GitHub
.github/workflows/examples-build.yml

Summary

Maintainability
Test Coverage
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
    strategy:
      matrix:
        node-version: [18.x]

    name: Create Example Chunks

    if: "${{ !github.event.pull_request.draft }}"

    outputs:
      CHUNK_1: ${{ steps.chunkstep.outputs.CHUNK_1 }}
      CHUNK_2: ${{ steps.chunkstep.outputs.CHUNK_2 }}
      CHUNK_3: ${{ steps.chunkstep.outputs.CHUNK_3 }}
      CHUNK_4: ${{ steps.chunkstep.outputs.CHUNK_4 }}
      CHUNK_5: ${{ steps.chunkstep.outputs.CHUNK_5 }}
      CHUNK_6: ${{ steps.chunkstep.outputs.CHUNK_6 }}
      CHUNK_7: ${{ steps.chunkstep.outputs.CHUNK_7 }}
      CHUNK_8: ${{ steps.chunkstep.outputs.CHUNK_8 }}

    steps:
      - name: Get PR labels
        id: pr-labels
        uses: joerick/pr-labels-action@v1.0.6
      - uses: actions/checkout@v4
      - name: Fetch commits
        run: git fetch origin ${{ github.base_ref || 'master' }} --depth=1
      # run npm ci
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
          registry-url: https://registry.npmjs.org/

      - name: Install Dependencies
        run: npm ci

      - name: Split Into Chunks
        id: chunkstep
        run: CHUNKS=8 BASE_REF=${{ github.base_ref }} BUILD_ALL_EXAMPLES=${{ (contains(steps.pr-labels.outputs.labels, ' build-examples ') || github.event_name == 'schedule' ) && 'true' || 'false' }} node ./.github/workflows/build-example-chunks.js

  build-chunk-1:
    runs-on: ubuntu-latest
    if: "${{ needs.chunks.outputs.CHUNK_1 != '' }}"
    concurrency:
      group: ${{ github.ref }}-build-examples-chunk-1
      cancel-in-progress: true
    strategy:
      matrix:
        node-version: [18.x]

    name: Build All Examples (Chunk 1)

    needs: chunks

    steps:
      - name: Get PR labels
        id: pr-labels
        uses: joerick/pr-labels-action@v1.0.6
      - uses: actions/checkout@v4

      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
          registry-url: https://registry.npmjs.org/

      - name: Install Dependencies
        run: npm ci

      - name: Bootstrap
        run: npm run bootstrap -- --scope={@refinedev/core,${{ needs.chunks.outputs.CHUNK_1 }}} --ignore blog-sveltekit-crud --ignore blog-react-aria

      - name: Build
        run: npm run build -- --no-bail --scope={@refinedev/core,${{ needs.chunks.outputs.CHUNK_1 }}} --ignore blog-sveltekit-crud --ignore blog-react-aria

      - 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=${{ needs.chunks.outputs.CHUNK_1 }} KEY=${{ secrets.CYPRESS_RECORD_KEY }} CI_BUILD_ID=refine-${{ github.ref_name }}-${{ steps.slug.outputs.sha7 }}-chunk-1-${{ github.run_attempt }} node ./.github/workflows/e2e-examples.js

  build-chunk-2:
    runs-on: ubuntu-latest
    if: "${{ needs.chunks.outputs.CHUNK_2 != '' }}"
    concurrency:
      group: ${{ github.ref }}-build-examples-chunk-2
      cancel-in-progress: true
    strategy:
      matrix:
        node-version: [18.x]

    name: Build All Examples (Chunk 2)

    needs: chunks

    steps:
      - name: Get PR labels
        id: pr-labels
        uses: joerick/pr-labels-action@v1.0.6
      - uses: actions/checkout@v4

      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
          registry-url: https://registry.npmjs.org/

      - name: Install Dependencies
        run: npm ci

      - name: Bootstrap
        run: npm run bootstrap -- --scope={@refinedev/core,${{ needs.chunks.outputs.CHUNK_2 }}} --ignore blog-sveltekit-crud --ignore blog-react-aria

      - name: Build
        run: REFINE_NO_TELEMETRY=true npm run build -- --no-bail --scope={@refinedev/core,${{ needs.chunks.outputs.CHUNK_2 }}} --ignore blog-sveltekit-crud --ignore blog-react-aria

      - name: Get short SHA
        id: slug
        run: echo "::set-output name=sha7::$(echo ${GITHUB_SHA} | cut -c1-7)"

      - name: Run E2E Tests
        run: REFINE_NO_TELEMETRY=true BASE_REF=${{ github.base_ref }} EXAMPLES=${{ needs.chunks.outputs.CHUNK_2 }} KEY=${{ secrets.CYPRESS_RECORD_KEY }} CI_BUILD_ID=refine-${{ github.ref_name }}-${{ steps.slug.outputs.sha7 }}-chunk-2-${{ github.run_attempt }} node ./.github/workflows/e2e-examples.js

  build-chunk-3:
    runs-on: ubuntu-latest
    if: "${{ needs.chunks.outputs.CHUNK_3 != '' }}"
    concurrency:
      group: ${{ github.ref }}-build-examples-chunk-3
      cancel-in-progress: true
    strategy:
      matrix:
        node-version: [18.x]

    name: Build All Examples (Chunk 3)

    needs: chunks

    steps:
      - name: Get PR labels
        id: pr-labels
        uses: joerick/pr-labels-action@v1.0.6
      - uses: actions/checkout@v4

      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
          registry-url: https://registry.npmjs.org/

      - name: Install Dependencies
        run: npm ci

      - name: Bootstrap
        run: npm run bootstrap -- --scope={@refinedev/core,${{ needs.chunks.outputs.CHUNK_3 }}} --ignore blog-sveltekit-crud --ignore blog-react-aria

      - name: Build
        run: npm run build -- --no-bail --scope={@refinedev/core,${{ needs.chunks.outputs.CHUNK_3 }}} --ignore blog-sveltekit-crud --ignore blog-react-aria

      - 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=${{ needs.chunks.outputs.CHUNK_3 }} KEY=${{ secrets.CYPRESS_RECORD_KEY }} CI_BUILD_ID=refine-${{ github.ref_name }}-${{ steps.slug.outputs.sha7 }}-chunk-3-${{ github.run_attempt }} node ./.github/workflows/e2e-examples.js

  build-chunk-4:
    runs-on: ubuntu-latest
    if: "${{ needs.chunks.outputs.CHUNK_4 != '' }}"
    concurrency:
      group: ${{ github.ref }}-build-examples-chunk-4
      cancel-in-progress: true
    strategy:
      matrix:
        node-version: [18.x]

    name: Build All Examples (Chunk 4)

    needs: chunks

    steps:
      - name: Get PR labels
        id: pr-labels
        uses: joerick/pr-labels-action@v1.0.6
      - uses: actions/checkout@v4

      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
          registry-url: https://registry.npmjs.org/

      - name: Install Dependencies
        run: npm ci

      - name: Bootstrap
        run: npm run bootstrap -- --scope={@refinedev/core,${{ needs.chunks.outputs.CHUNK_4 }}} --ignore blog-sveltekit-crud --ignore blog-react-aria

      - name: Build
        run: npm run build -- --no-bail --scope={@refinedev/core,${{ needs.chunks.outputs.CHUNK_4 }}} --ignore blog-sveltekit-crud --ignore blog-react-aria

      - 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=${{ needs.chunks.outputs.CHUNK_4 }} KEY=${{ secrets.CYPRESS_RECORD_KEY }} CI_BUILD_ID=refine-${{ github.ref_name }}-${{ steps.slug.outputs.sha7 }}-chunk-4-${{ github.run_attempt }}-4 node ./.github/workflows/e2e-examples.js

  build-chunk-5:
    runs-on: ubuntu-latest
    if: "${{ needs.chunks.outputs.CHUNK_5 != '' }}"
    concurrency:
      group: ${{ github.ref }}-build-examples-chunk-5
      cancel-in-progress: true
    strategy:
      matrix:
        node-version: [18.x]

    name: Build All Examples (Chunk 5)

    needs: chunks

    steps:
      - name: Get PR labels
        id: pr-labels
        uses: joerick/pr-labels-action@v1.0.6
      - uses: actions/checkout@v4

      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
          registry-url: https://registry.npmjs.org/

      - name: Install Dependencies
        run: npm ci

      - name: Bootstrap
        run: npm run bootstrap -- --scope={@refinedev/core,${{ needs.chunks.outputs.CHUNK_5 }}} --ignore blog-sveltekit-crud --ignore blog-react-aria

      - name: Build
        run: npm run build -- --no-bail --scope={@refinedev/core,${{ needs.chunks.outputs.CHUNK_5 }}} --ignore blog-sveltekit-crud --ignore blog-react-aria

      - 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=${{ needs.chunks.outputs.CHUNK_5 }} KEY=${{ secrets.CYPRESS_RECORD_KEY }} CI_BUILD_ID=refine-${{ github.ref_name }}-${{ steps.slug.outputs.sha7 }}-chunk-5-${{ github.run_attempt }} node ./.github/workflows/e2e-examples.js

  build-chunk-6:
    runs-on: ubuntu-latest
    if: "${{ needs.chunks.outputs.CHUNK_6 != '' }}"
    concurrency:
      group: ${{ github.ref }}-build-examples-chunk-6
      cancel-in-progress: true
    strategy:
      matrix:
        node-version: [18.x]

    name: Build All Examples (Chunk 6)

    needs: chunks

    steps:
      - name: Get PR labels
        id: pr-labels
        uses: joerick/pr-labels-action@v1.0.6
      - uses: actions/checkout@v4

      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
          registry-url: https://registry.npmjs.org/

      - name: Install Dependencies
        run: npm ci

      - name: Bootstrap
        run: npm run bootstrap -- --scope={@refinedev/core,${{ needs.chunks.outputs.CHUNK_6 }}} --ignore blog-sveltekit-crud --ignore blog-react-aria

      - name: Build
        run: npm run build -- --no-bail --scope={@refinedev/core,${{ needs.chunks.outputs.CHUNK_6 }}} --ignore blog-sveltekit-crud --ignore blog-react-aria

      - 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=${{ needs.chunks.outputs.CHUNK_6 }} KEY=${{ secrets.CYPRESS_RECORD_KEY }} CI_BUILD_ID=refine-${{ github.ref_name }}-${{ steps.slug.outputs.sha7 }}-chunk-6-${{ github.run_attempt }} node ./.github/workflows/e2e-examples.js

  build-chunk-7:
    runs-on: ubuntu-latest
    if: "${{ needs.chunks.outputs.CHUNK_7 != '' }}"
    concurrency:
      group: ${{ github.ref }}-build-examples-chunk-7
      cancel-in-progress: true
    strategy:
      matrix:
        node-version: [18.x]

    name: Build All Examples (Chunk 7)

    needs: chunks

    steps:
      - name: Get PR labels
        id: pr-labels
        uses: joerick/pr-labels-action@v1.0.6
      - uses: actions/checkout@v4

      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
          registry-url: https://registry.npmjs.org/

      - name: Install Dependencies
        run: npm ci

      - name: Bootstrap
        run: npm run bootstrap -- --scope={@refinedev/core,${{ needs.chunks.outputs.CHUNK_7 }}} --ignore blog-sveltekit-crud --ignore blog-react-aria

      - name: Build
        run: npm run build -- --no-bail --scope={@refinedev/core,${{ needs.chunks.outputs.CHUNK_7 }}} --ignore blog-sveltekit-crud --ignore blog-react-aria

      - 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=${{ needs.chunks.outputs.CHUNK_7 }} KEY=${{ secrets.CYPRESS_RECORD_KEY }} CI_BUILD_ID=refine-${{ github.ref_name }}-${{ steps.slug.outputs.sha7 }}-chunk-7-${{ github.run_attempt }} node ./.github/workflows/e2e-examples.js

  build-chunk-8:
    runs-on: ubuntu-latest
    if: "${{ needs.chunks.outputs.CHUNK_8 != '' }}"
    concurrency:
      group: ${{ github.ref }}-build-examples-chunk-8
      cancel-in-progress: true
    strategy:
      matrix:
        node-version: [18.x]

    name: Build All Examples (Chunk 8)

    needs: chunks

    steps:
      - name: Get PR labels
        id: pr-labels
        uses: joerick/pr-labels-action@v1.0.6
      - uses: actions/checkout@v4
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
          registry-url: https://registry.npmjs.org/

      - name: Install Dependencies
        run: npm ci

      - name: Bootstrap
        run: npm run bootstrap -- --scope={@refinedev/core,${{ needs.chunks.outputs.CHUNK_8 }}} --ignore blog-sveltekit-crud --ignore blog-react-aria

      - name: Build
        run: npm run build -- --no-bail --scope={@refinedev/core,${{ needs.chunks.outputs.CHUNK_8 }}} --ignore blog-sveltekit-crud --ignore blog-react-aria

      - 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=${{ needs.chunks.outputs.CHUNK_8 }} KEY=${{ secrets.CYPRESS_RECORD_KEY }} CI_BUILD_ID=refine-${{ github.ref_name }}-${{ steps.slug.outputs.sha7 }}-chunk-8-${{ github.run_attempt }} node ./.github/workflows/e2e-examples.js