From 1727f41878bcac2e6bea7e7f864f86b0f2706827 Mon Sep 17 00:00:00 2001 From: Bernhard Kaindl Date: Mon, 31 Aug 2026 12:00:00 +0200 Subject: [PATCH] Add support for running Linux-based actions workflows locally using nektos/act --- .actrc | 3 +++ .github/act/push-and-merge-group-events.json | 9 +++++++++ .github/workflows/audit.yaml | 11 +++++++---- .github/workflows/bootstrap.yml | 11 +++++++++++ .github/workflows/prechecks.yml | 5 +++++ .github/workflows/triage.yml | 1 + .github/workflows/unit_tests.yaml | 12 ++++++++++++ 7 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 .actrc create mode 100644 .github/act/push-and-merge-group-events.json diff --git a/.actrc b/.actrc new file mode 100644 index 00000000000..fc101468987 --- /dev/null +++ b/.actrc @@ -0,0 +1,3 @@ +--env=PIP_BREAK_SYSTEM_PACKAGES=1 +--env=PIP_ROOT_USER_ACTION=ignore +--eventpath=.github/act/push-and-merge-group-events.json diff --git a/.github/act/push-and-merge-group-events.json b/.github/act/push-and-merge-group-events.json new file mode 100644 index 00000000000..e7518a546fd --- /dev/null +++ b/.github/act/push-and-merge-group-events.json @@ -0,0 +1,9 @@ +{ + "ref": "", + "repository": { + "default_branch": "develop" + }, + "merge_group": { + "base_ref": "develop" + } +} diff --git a/.github/workflows/audit.yaml b/.github/workflows/audit.yaml index 26f97cb2cf7..86c09cce43f 100644 --- a/.github/workflows/audit.yaml +++ b/.github/workflows/audit.yaml @@ -19,10 +19,13 @@ jobs: strategy: fail-fast: false matrix: - system: - - { os: windows-latest, shell: powershell } - - { os: ubuntu-latest, shell: bash } - - { os: macos-latest, shell: bash } + # In a local docker-based workflow run using act, only Linux-based systems are available + system: >- + ${{ github.actor == 'nektos/act' + && fromJSON('[{"os":"ubuntu-latest","shell":"bash"}]') + || fromJSON('[{"os":"ubuntu-latest","shell":"bash"}, + {"os":"windows-latest","shell":"powershell"}, + {"os":"macos-latest","shell":"bash"}]') }} # An empty ref means the commit pinned in .ci/env, the others are the # released versions we keep the packages repository compatible with spack_ref: ['', 'v1.2.2', 'v1.1.1'] diff --git a/.github/workflows/bootstrap.yml b/.github/workflows/bootstrap.yml index 4393c2369a9..b10d30257a7 100644 --- a/.github/workflows/bootstrap.yml +++ b/.github/workflows/bootstrap.yml @@ -69,6 +69,11 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 + - name: Install Node.js for local workflow runs using act + if: ${{ github.actor == 'nektos/act' }} + run: | + yum update -y + yum install -y nodejs - uses: ./.github/actions/checkout-spack - name: Bootstrap clingo run: | @@ -176,6 +181,7 @@ jobs: bootstrap-dev-rhel8: runs-on: ubuntu-latest + if: ${{ github.actor != 'nektos/act' }} container: registry.access.redhat.com/ubi8/ubi steps: - name: Install dependencies @@ -187,6 +193,11 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 + - name: Install Node.js for local workflow runs using act + if: ${{ github.actor == 'nektos/act' }} + run: | + yum update -y + yum install -y nodejs - uses: ./.github/actions/checkout-spack with: fetch-depth: 0 diff --git a/.github/workflows/prechecks.yml b/.github/workflows/prechecks.yml index a8516b476a3..13d0d9059ae 100644 --- a/.github/workflows/prechecks.yml +++ b/.github/workflows/prechecks.yml @@ -80,6 +80,11 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 + - name: Install Node.js for local workflow runs using act + if: ${{ github.actor == 'nektos/act' }} + run: | + apt-get update + apt-get install -y nodejs - uses: ./.github/actions/checkout-spack - name: Test package.py canonicalization diff --git a/.github/workflows/triage.yml b/.github/workflows/triage.yml index 54b0c9ab1fa..7871e50d417 100644 --- a/.github/workflows/triage.yml +++ b/.github/workflows/triage.yml @@ -14,6 +14,7 @@ on: jobs: pr: runs-on: ubuntu-latest + if: ${{ github.actor != 'nektos/act' }} permissions: contents: read pull-requests: write diff --git a/.github/workflows/unit_tests.yaml b/.github/workflows/unit_tests.yaml index 56821891c36..9205679bdf9 100644 --- a/.github/workflows/unit_tests.yaml +++ b/.github/workflows/unit_tests.yaml @@ -1,6 +1,9 @@ name: unit tests on: + # Allows act's default push event to select this workflow locally. The job + # guards below prevent this local-only trigger from running tests on GitHub. + push: workflow_dispatch: workflow_call: @@ -11,6 +14,9 @@ concurrency: jobs: # Run unit tests with different configurations on linux ubuntu: + # Run act's synthetic push, or GitHub's workflow_call/dispatch events, but + # skip ordinary GitHub push events introduced only for act compatibility. + if: ${{ github.actor == 'nektos/act' || github.event_name != 'push' }} runs-on: ${{ matrix.os }} strategy: matrix: @@ -39,6 +45,8 @@ jobs: steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + # In local workflow runs using act, setup-python is not supported and not needed + if: ${{ github.actor != 'nektos/act' }} with: python-version: ${{ matrix.python-version }} - name: Install System packages @@ -56,6 +64,8 @@ jobs: # Run unit tests on MacOS macos: + # Keep the same event guard as the Linux matrix; act skips this platform. + if: ${{ github.actor == 'nektos/act' || github.event_name != 'push' }} runs-on: ${{ matrix.os }} strategy: matrix: @@ -76,6 +86,8 @@ jobs: # Run unit tests on Windows windows: + # Keep the same event guard as the Linux matrix; act skips this platform. + if: ${{ github.actor == 'nektos/act' || github.event_name != 'push' }} defaults: run: shell: