Erlang #543
Workflow file for this run
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
| --- | |
| # Erlang CI/CD workflow | |
| # | |
| # Job dependency structure: | |
| # - resolve-playwright-version: Standalone, runs first for E2E jobs | |
| # - cache-erlang: Standalone, caches Erlang build artifacts | |
| # - check/test/artifacts: Depend on cache-erlang only | |
| # - e2e-parallel/e2e-sequential: Depend on both resolve-playwright-version | |
| # and cache-erlang | |
| # | |
| # E2E tests use Playwright Docker containers with pre-installed browsers, | |
| # eliminating the need for browser caching and installation steps. | |
| name: Erlang | |
| "on": | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - "*" | |
| workflow_dispatch: {} | |
| merge_group: | |
| concurrency: | |
| group: ${{github.workflow}}-${{github.ref}} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| # Extracts Playwright version from package.json to ensure E2E tests run in | |
| # Docker containers with matching browser versions. This eliminates the need | |
| # for browser caching and manual installation steps. | |
| resolve-playwright-version: | |
| name: Resolve Playwright version | |
| runs-on: ubuntu-24.04 | |
| outputs: | |
| version: ${{ steps.resolve-playwright-version.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Resolve Playwright version | |
| id: resolve-playwright-version | |
| run: | | |
| # Extract version from package.json devDependencies | |
| version="$(grep -oP '(?<="@playwright/test": ")[^"]+' package.json)" | |
| test -n "$version" || { | |
| echo "No @playwright/test version found in package.json" | |
| exit 1 | |
| } | |
| echo "version=$version" >> "$GITHUB_OUTPUT" | |
| cache-erlang: | |
| name: Cache Erlang | |
| runs-on: ubuntu-24.04 | |
| outputs: | |
| build-cache-key: ${{ steps.set-build-key.outputs.key }} | |
| rebar-cache-key: ${{ steps.set-rebar-key.outputs.key }} | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - uses: erlef/setup-beam@e6d7c94229049569db56a7ad5a540c051a010af9 # v1.20.4 | |
| id: setup-beam | |
| with: | |
| version-type: strict | |
| version-file: .tool-versions | |
| - name: Set build cache key | |
| id: set-build-key | |
| run: | | |
| echo "key=\ | |
| _build-\ | |
| ${{ runner.os }}-\ | |
| otp-${{ steps.setup-beam.outputs.otp-version }}-\ | |
| rebar3-hash-${{ hashFiles('rebar.lock') }}" \ | |
| >> "${GITHUB_OUTPUT}" | |
| - name: Set rebar cache key | |
| id: set-rebar-key | |
| run: | | |
| echo "key=\ | |
| rebar3-\ | |
| ${{ runner.os }}-\ | |
| otp-${{ steps.setup-beam.outputs.otp-version }}-\ | |
| rebar3-${{ steps.setup-beam.outputs.rebar3-version }}-\ | |
| config-${{ hashFiles('rebar.config') }}" \ | |
| >> "${GITHUB_OUTPUT}" | |
| - name: Cache _build | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: _build | |
| key: ${{ steps.set-build-key.outputs.key }} | |
| restore-keys: | | |
| _build-${{ runner.os }}-otp-${{ steps.setup-beam.outputs.otp-version }}- | |
| _build-${{ runner.os }}- | |
| - name: Cache rebar3 | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: ~/.cache/rebar3 | |
| key: ${{ steps.set-rebar-key.outputs.key }} | |
| restore-keys: | | |
| rebar3-${{ runner.os }}-otp-${{ steps.setup-beam.outputs.otp-version }}- | |
| rebar3-${{ runner.os }}- | |
| - name: Compile | |
| run: | | |
| rebar3 as test compile | |
| check: | |
| name: Check | |
| needs: cache-erlang | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - uses: erlef/setup-beam@e6d7c94229049569db56a7ad5a540c051a010af9 # v1.20.4 | |
| id: setup-beam | |
| with: | |
| version-type: strict | |
| version-file: .tool-versions | |
| - name: Restore _build cache | |
| id: restore-build-cache | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: _build | |
| key: ${{ needs.cache-erlang.outputs.build-cache-key }} | |
| restore-keys: | | |
| _build-${{ runner.os }}-otp-${{ steps.setup-beam.outputs.otp-version }}- | |
| _build-${{ runner.os }}- | |
| - name: Restore rebar3 cache | |
| id: restore-rebar3-cache | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: ~/.cache/rebar3 | |
| key: ${{ needs.cache-erlang.outputs.rebar-cache-key }} | |
| restore-keys: | | |
| rebar3-${{ runner.os }}-otp-${{ steps.setup-beam.outputs.otp-version }}- | |
| rebar3-${{ runner.os }}- | |
| - name: Check code | |
| run: | | |
| rebar3 as test check | |
| test: | |
| name: Test | |
| needs: cache-erlang | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - uses: erlef/setup-beam@e6d7c94229049569db56a7ad5a540c051a010af9 # v1.20.4 | |
| id: setup-beam | |
| with: | |
| version-type: strict | |
| version-file: .tool-versions | |
| - name: Restore _build cache | |
| id: restore-build-cache | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: _build | |
| key: ${{ needs.cache-erlang.outputs.build-cache-key }} | |
| restore-keys: | | |
| _build-${{ runner.os }}-otp-${{ steps.setup-beam.outputs.otp-version }}- | |
| _build-${{ runner.os }}- | |
| - name: Restore rebar3 cache | |
| id: restore-rebar3-cache | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: ~/.cache/rebar3 | |
| key: ${{ needs.cache-erlang.outputs.rebar-cache-key }} | |
| restore-keys: | | |
| rebar3-${{ runner.os }}-otp-${{ steps.setup-beam.outputs.otp-version }}- | |
| rebar3-${{ runner.os }}- | |
| - name: Install inotify tools | |
| uses: awalsh128/cache-apt-pkgs-action@2c09a5e66da6c8016428a2172bd76e5e4f14bb17 # v1.5.3 | |
| with: | |
| packages: inotify-tools | |
| version: 1.0 | |
| - name: Test | |
| run: | | |
| rebar3 as test test | |
| artifacts: | |
| name: Verify artifacts | |
| needs: cache-erlang | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - uses: erlef/setup-beam@e6d7c94229049569db56a7ad5a540c051a010af9 # v1.20.4 | |
| id: setup-beam | |
| with: | |
| version-type: strict | |
| version-file: .tool-versions | |
| - name: Restore _build cache | |
| id: restore-build-cache | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: _build | |
| key: ${{ needs.cache-erlang.outputs.build-cache-key }} | |
| restore-keys: | | |
| _build-${{ runner.os }}-otp-${{ steps.setup-beam.outputs.otp-version }}- | |
| _build-${{ runner.os }}- | |
| - name: Restore rebar3 cache | |
| id: restore-rebar3-cache | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: ~/.cache/rebar3 | |
| key: ${{ needs.cache-erlang.outputs.rebar-cache-key }} | |
| restore-keys: | | |
| rebar3-${{ runner.os }}-otp-${{ steps.setup-beam.outputs.otp-version }}- | |
| rebar3-${{ runner.os }}- | |
| - name: Check if build left artifacts | |
| run: | | |
| rebar3 unlock --all | |
| rebar3 upgrade --all | |
| git diff --exit-code | |
| # Runs E2E tests in parallel using Playwright Docker containers with | |
| # pre-installed browsers. The container image version matches package.json | |
| # to ensure consistency. Using containers eliminates browser installation | |
| # time and caching complexity. | |
| # | |
| # Container details: | |
| # - Base: Ubuntu 24.04 (noble) matching runner OS | |
| # - User: root (required for apt package caching) | |
| # - Browsers: Chromium and Firefox pre-installed | |
| e2e-parallel: | |
| name: E2E Tests (Parallel) | |
| needs: [resolve-playwright-version, cache-erlang] | |
| runs-on: ubuntu-24.04 | |
| # Set ImageOS for erlef/setup-beam to work in containers | |
| # Set HOME=/root for Firefox to work when running as root | |
| env: | |
| ImageOS: ubuntu22 | |
| HOME: /root | |
| container: | |
| image: >- | |
| mcr.microsoft.com/playwright:v${{ | |
| needs.resolve-playwright-version.outputs.version | |
| }}-noble | |
| options: --user root | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| # Fix Docker config warnings for GitHub Actions cleanup | |
| - name: Setup Docker config | |
| run: | | |
| mkdir -p /root/.docker | |
| echo '{}' > /root/.docker/config.json | |
| - uses: erlef/setup-beam@e6d7c94229049569db56a7ad5a540c051a010af9 # v1.20.4 | |
| id: setup-beam | |
| with: | |
| version-type: strict | |
| version-file: .tool-versions | |
| # Composite actions don't work in container jobs, use manual apt caching | |
| # Ref: https://github.com/orgs/community/discussions/53771 | |
| - name: Cache apt packages | |
| id: cache-apt | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: /var/cache/apt/archives | |
| key: apt-${{ runner.os }}-build-essential-inotify-tools | |
| - name: Install build dependencies | |
| run: | | |
| apt-get update | |
| apt-get install -y build-essential inotify-tools | |
| - name: Setup Node.js | |
| uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 | |
| with: | |
| node-version-file: .tool-versions | |
| cache: "npm" | |
| cache-dependency-path: "package-lock.json" | |
| - name: Restore _build cache | |
| id: restore-build-cache | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: _build | |
| key: ${{ needs.cache-erlang.outputs.build-cache-key }} | |
| restore-keys: | | |
| _build-${{ runner.os }}-otp-${{ steps.setup-beam.outputs.otp-version }}- | |
| _build-${{ runner.os }}- | |
| - name: Restore rebar3 cache | |
| id: restore-rebar3-cache | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: ~/.cache/rebar3 | |
| key: ${{ needs.cache-erlang.outputs.rebar-cache-key }} | |
| restore-keys: | | |
| rebar3-${{ runner.os }}-otp-${{ steps.setup-beam.outputs.otp-version }}- | |
| rebar3-${{ runner.os }}- | |
| - name: Install Node.js dependencies | |
| run: npm ci | |
| - name: Compile Arizona for test | |
| run: rebar3 as test compile | |
| - name: Run parallel E2E tests | |
| run: npm run test:e2e:parallel | |
| - name: Upload Playwright report | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| if: failure() | |
| with: | |
| name: playwright-report-parallel | |
| path: test-results/ | |
| retention-days: 7 | |
| # Runs E2E tests sequentially (--workers=1) using Playwright Docker | |
| # containers. Same container setup as e2e-parallel job. Sequential execution | |
| # is required for tests that interact with shared state or perform operations | |
| # that cannot run safely in parallel. | |
| e2e-sequential: | |
| name: E2E Tests (Sequential) | |
| needs: [resolve-playwright-version, cache-erlang] | |
| runs-on: ubuntu-24.04 | |
| # Set ImageOS for erlef/setup-beam to work in containers | |
| # Set HOME=/root for Firefox to work when running as root | |
| env: | |
| ImageOS: ubuntu22 | |
| HOME: /root | |
| container: | |
| image: >- | |
| mcr.microsoft.com/playwright:v${{ | |
| needs.resolve-playwright-version.outputs.version | |
| }}-noble | |
| options: --user root | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| # Fix Docker config warnings for GitHub Actions cleanup | |
| - name: Setup Docker config | |
| run: | | |
| mkdir -p /root/.docker | |
| echo '{}' > /root/.docker/config.json | |
| - uses: erlef/setup-beam@e6d7c94229049569db56a7ad5a540c051a010af9 # v1.20.4 | |
| id: setup-beam | |
| with: | |
| version-type: strict | |
| version-file: .tool-versions | |
| # Composite actions don't work in container jobs, use manual apt caching | |
| # Ref: https://github.com/orgs/community/discussions/53771 | |
| - name: Cache apt packages | |
| id: cache-apt | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: /var/cache/apt/archives | |
| key: apt-${{ runner.os }}-build-essential-inotify-tools | |
| - name: Install build dependencies | |
| run: | | |
| apt-get update | |
| apt-get install -y build-essential inotify-tools | |
| - name: Setup Node.js | |
| uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 | |
| with: | |
| node-version-file: .tool-versions | |
| cache: "npm" | |
| cache-dependency-path: "package-lock.json" | |
| - name: Restore _build cache | |
| id: restore-build-cache | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: _build | |
| key: ${{ needs.cache-erlang.outputs.build-cache-key }} | |
| restore-keys: | | |
| _build-${{ runner.os }}-otp-${{ steps.setup-beam.outputs.otp-version }}- | |
| _build-${{ runner.os }}- | |
| - name: Restore rebar3 cache | |
| id: restore-rebar3-cache | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: ~/.cache/rebar3 | |
| key: ${{ needs.cache-erlang.outputs.rebar-cache-key }} | |
| restore-keys: | | |
| rebar3-${{ runner.os }}-otp-${{ steps.setup-beam.outputs.otp-version }}- | |
| rebar3-${{ runner.os }}- | |
| - name: Install Node.js dependencies | |
| run: npm ci | |
| - name: Compile Arizona for test | |
| run: rebar3 as test compile | |
| - name: Run sequential E2E tests | |
| run: npm run test:e2e:sequential | |
| - name: Upload Playwright report | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| if: failure() | |
| with: | |
| name: playwright-report-sequential | |
| path: test-results/ | |
| retention-days: 7 |