kiegroup / act-js

A node.js wrapper for nektos/act to programmatically run your github actions locally
Apache License 2.0
53 stars 8 forks source link

Ability to add a step to a job #71

Closed TWiStErRob closed 5 months ago

TWiStErRob commented 5 months ago

Feature request I would like to insert a step into a workflow from a test.

I think this syntax would work:

      mockSteps: {
        "job-name": [
          {
            before: N, // or after: N,
            mockWith: {...}
          }
        ]
      }

Additional context When testing local actions, we need to clone the MockGithub repository, but in production we don't need this and we don't want to create noise in the real executions by doing an if: ... or having a placeholder step to replace with mock.

Workaround For now I did this:

      # "Placeholder for test to hook into."
      - id: checkout
        run: |
          true

+

      mockSteps: {
        "job-name": [
          {
            id: "checkout",
            mockWith: {
              name: "Checkout (test only)"
              uses: "actions/checkout@v4",
              run: undefined,
            }
          }
        ]
      }

Proposed solution

No yaml changes. +

      mockSteps: {
        "job-name": [
          {
            before: 0,
            mockWith: {
              name: "Checkout (test only)"
              uses: "actions/checkout@v4",
            }
          }
        ]
      }