chore: migrate workflows from circleci to github actions [SWC-767] #117
This file contains hidden or 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: PR verification | |
| # ------------------------------------------------------------- | |
| # This workflow will build and verify pull requests. It will: | |
| # - Build the branch and fail if the build fails | |
| # - Run code coverage tests on the PR branch | |
| # - Lint the PR branch | |
| # ------------------------------------------------------------- | |
| on: | |
| pull_request: | |
| types: | |
| - opened | |
| - synchronize | |
| - reopened | |
| - labeled | |
| - unlabeled | |
| - auto_merge_enabled | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| concurrency: | |
| group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label }}' | |
| cancel-in-progress: true | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| # ------------------------------------------------------------- | |
| # Validate build for various environments | |
| # ------------------------------------------------------------- | |
| verify_builds: | |
| name: Verify build | |
| # Check that the PR is not in draft mode (or if it is, that it has the run_ci label to force a build) | |
| if: ${{ github.event.pull_request.draft != 'true' || contains(github.event.pull_request.labels.*.name, 'run_ci') }} | |
| uses: ./.github/workflows/build.yml | |
| secrets: inherit | |
| test: | |
| name: Tests and coverage | |
| # Check that the PR is not in draft mode (or if it is, that it has the run_ci label to force a build) | |
| if: ${{ github.event.pull_request.draft != 'true' || contains(github.event.pull_request.labels.*.name, 'run_ci') }} | |
| uses: ./.github/workflows/tests.yml | |
| secrets: inherit | |
| # ------------------------------------------------------------- | |
| # Lint pre-compiled assets for consistency | |
| # ------------------------------------------------------------- | |
| lint: | |
| name: Lint | |
| if: ${{ contains(github.event.pull_request.labels.*.name, 'skip_lint') == false }} | |
| uses: ./.github/workflows/lint.yml | |
| secrets: inherit | |
| # ------------------------------------------------------------- | |
| # Browser performance tests | |
| # ------------------------------------------------------------- | |
| performance: | |
| name: Performance | |
| if: ${{ github.event.pull_request.draft != 'true' || contains(github.event.pull_request.labels.*.name, 'run_ci') }} | |
| uses: ./.github/workflows/browser-tests.yml | |
| secrets: inherit | |
| comment-previews: | |
| name: Create preview URLs and comment | |
| # The job will only run if the pull request is from the same repository. | |
| # Benchmarks can't run on PRs from forked repos due to comment posting restrictions without a GitHub token. | |
| if: github.event.pull_request.head.repo.full_name == github.repository | |
| runs-on: ubuntu-latest | |
| outputs: | |
| doc_url: ${{ steps.extract_doc_url.outputs.DOC_URL }} | |
| steps: | |
| - name: Checkout main | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| - name: Checkout PR branch | |
| uses: actions/checkout@v4 | |
| - name: Setup Job and Install Dependencies | |
| uses: ./.github/actions/setup-job | |
| with: | |
| skip-build: true | |
| - name: Extract branch name | |
| run: echo "BRANCH=$(npx slugify-cli ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}})" >> $GITHUB_OUTPUT | |
| id: extract_branch | |
| - name: Extract doc preview url | |
| run: echo "DOC_URL=https://${{ steps.extract_branch.outputs.BRANCH }}--spectrum-wc.netlify.app/" >> $GITHUB_OUTPUT | |
| id: extract_doc_url | |
| - name: Post Previews Comment | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const { buildPreviewURLComment } = await import('${{ github.workspace }}/tasks/build-preview-urls-comment.js'); | |
| const body = buildPreviewURLComment(process.env.GITHUB_HEAD_REF); | |
| const { getDocPreviewURL } = await import('${{ github.workspace }}/tasks/build-preview-urls-comment.js'); | |
| const { commentOrUpdate } = await import('${{ github.workspace }}/tasks/comment-or-update.js'); | |
| commentOrUpdate(github, context, '## Branch preview', body); | |
| smoke-tests: | |
| name: Smoke tests | |
| runs-on: macos-latest | |
| needs: comment-previews | |
| steps: | |
| - name: Checkout PR branch | |
| uses: actions/checkout@v4 | |
| - name: Setup Job and Install Dependencies | |
| uses: ./.github/actions/setup-job | |
| with: | |
| skip-build: true | |
| with-playwright: true | |
| - name: Run Playwright tests | |
| run: yarn playwright test projects/documentation/e2e/published.spec.ts --reporter html | |
| env: | |
| DOC_PREVIEW_URL: ${{ needs.comment-previews.outputs.doc_url }} | |
| NODE_ENV: CI | |
| - name: Upload Playwright Report | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: docs-report | |
| path: playwright-report/ |