[PR #1675] [MERGED] feat: specify matrix on command line #2067

Closed
opened 2026-03-01 21:53:52 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/nektos/act/pull/1675
Author: @shubhbapna
Created: 3/10/2023
Status: Merged
Merged: 3/19/2023
Merged by: @mergify[bot]

Base: masterHead: issue-114


📝 Commits (8)

  • f1a24fe added matrix option
  • e3824f6 select the correct subset of matrix configuration after producing all the matrix configuration
  • 98b40aa add tests
  • 7db9489 update readme
  • c46b1c9 lint fix
  • 8f6496d Merge branch 'master' into issue-114
  • 6932c5e remove matrix from readme
  • 391c257 Merge branch 'master' into issue-114

📊 Changes

5 files changed (+144 additions, -35 deletions)

View changed files

📝 cmd/input.go (+1 -0)
📝 cmd/root.go (+23 -0)
📝 pkg/runner/runner.go (+58 -35)
📝 pkg/runner/runner_test.go (+28 -0)
pkg/runner/testdata/matrix-with-user-inclusions/push.yml (+34 -0)

📄 Description

Fixes #114

You can selectively choose a subset of matrix options to run by specifying the --matrix flag. It will only run those matrix configurations which include your specified values.

Example workflow file

name: matrix-with-user-inclusions
on: push

jobs:
  build:
    name: Matrix
    runs-on: ubuntu-latest
    steps:
      - run: echo ${NODE_VERSION}
        env:
          NODE_VERSION: ${{ matrix.node }}
    strategy:
      matrix:
        os: [ubuntu-18.04, macos-latest]
        node: [4, 6, 8, 10]
        exclude:
          - os: macos-latest
            node: 4
        include:
          - os: ubuntu-16.04
            node: 10

In this case if we only wanted to run this workflow for node 8, then we would run act push --matrix node:8
This will trigger the workflow to use the following matrix configurations only:

  • os: ubuntu-18.04, node 8
  • os: macos-latest, node 8

Similarly if we just wanted to trigger this workflow for node 10 and macos-latest then we would run act push --matrix node:10 --matrix os:macos-latest.
This will trigger the workflow to use the following matrix configurations only:

  • os: macos-latest, node 10

Note that using the --matrix flag you can't add new values (for e.g. running the above workflow for node 20). It will simply ignore it. Moreover, the exclude field in the workflow will take precedance over the --matrix flag (for e.g. running the above workflow for only macos-latest and node 4 will result in no matrix configuration being used)


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/nektos/act/pull/1675 **Author:** [@shubhbapna](https://github.com/shubhbapna) **Created:** 3/10/2023 **Status:** ✅ Merged **Merged:** 3/19/2023 **Merged by:** [@mergify[bot]](https://github.com/apps/mergify) **Base:** `master` ← **Head:** `issue-114` --- ### 📝 Commits (8) - [`f1a24fe`](https://github.com/nektos/act/commit/f1a24fe236ca08e0178fea5e7a687f56a63d3499) added matrix option - [`e3824f6`](https://github.com/nektos/act/commit/e3824f65e879f33c0b790daf76d0d7876e939efc) select the correct subset of matrix configuration after producing all the matrix configuration - [`98b40aa`](https://github.com/nektos/act/commit/98b40aaaaf6dee2f2be8fe3e0999d77000d502d6) add tests - [`7db9489`](https://github.com/nektos/act/commit/7db94895c624ce4d460f0db31ee8cbf42cc90ac7) update readme - [`c46b1c9`](https://github.com/nektos/act/commit/c46b1c97b8bf63d5ce9fdeeeb090f920de7b6266) lint fix - [`8f6496d`](https://github.com/nektos/act/commit/8f6496dd0ec3159bc3837e41e478d823f5ae6122) Merge branch 'master' into issue-114 - [`6932c5e`](https://github.com/nektos/act/commit/6932c5ec4b405cab8acee4179fc24e1c7cd5b6cc) remove matrix from readme - [`391c257`](https://github.com/nektos/act/commit/391c257892ee65f4f29e521f81bf826a2c1776f2) Merge branch 'master' into issue-114 ### 📊 Changes **5 files changed** (+144 additions, -35 deletions) <details> <summary>View changed files</summary> 📝 `cmd/input.go` (+1 -0) 📝 `cmd/root.go` (+23 -0) 📝 `pkg/runner/runner.go` (+58 -35) 📝 `pkg/runner/runner_test.go` (+28 -0) ➕ `pkg/runner/testdata/matrix-with-user-inclusions/push.yml` (+34 -0) </details> ### 📄 Description Fixes #114 You can selectively choose a subset of matrix options to run by specifying the `--matrix` flag. It will only run those matrix configurations which include your specified values. Example workflow file ```yaml name: matrix-with-user-inclusions on: push jobs: build: name: Matrix runs-on: ubuntu-latest steps: - run: echo ${NODE_VERSION} env: NODE_VERSION: ${{ matrix.node }} strategy: matrix: os: [ubuntu-18.04, macos-latest] node: [4, 6, 8, 10] exclude: - os: macos-latest node: 4 include: - os: ubuntu-16.04 node: 10 ``` In this case if we only wanted to run this workflow for node 8, then we would run `act push --matrix node:8` This will trigger the workflow to use the following matrix configurations only: - `os: ubuntu-18.04, node 8` - `os: macos-latest, node 8` Similarly if we just wanted to trigger this workflow for node 10 and macos-latest then we would run `act push --matrix node:10 --matrix os:macos-latest`. This will trigger the workflow to use the following matrix configurations only: - `os: macos-latest, node 10` Note that using the `--matrix` flag you can't add new values (for e.g. running the above workflow for node 20). It will simply ignore it. Moreover, the `exclude` field in the workflow will take precedance over the `--matrix` flag (for e.g. running the above workflow for only macos-latest and node 4 will result in no matrix configuration being used) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-01 21:53:52 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/act#2067
No description provided.