Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fails when using nektos/act (running locally) #125

Open
techieshark opened this issue Oct 6, 2023 · 4 comments
Open

fails when using nektos/act (running locally) #125

techieshark opened this issue Oct 6, 2023 · 4 comments
Assignees

Comments

@techieshark
Copy link

I'm trying to use https://github.com/nektos/act to run the github actions workflow locally, during development.

I'm getting this error though:

[Pull Request CI/main]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/3-composite-setSHAs.sh] user= workdir=
| /run/act/actions/nrwl-nx-set-shas@v3/dist/index.js:14919
|     if ((['pull_request', 'pull_request_target'].includes(eventName) && !github.context.payload.pull_request.merged) ||
|                                                                                                              ^
|
| TypeError: Cannot read properties of undefined (reading 'merged')
|     at /run/act/actions/nrwl-nx-set-shas@v3/dist/index.js:14919:110
|     at Generator.next (<anonymous>)
|     at /run/act/actions/nrwl-nx-set-shas@v3/dist/index.js:14889:71
|     at new Promise (<anonymous>)
|     at __webpack_modules__.5468.__awaiter (/run/act/actions/nrwl-nx-set-shas@v3/dist/index.js:14885:12)
|     at /run/act/actions/nrwl-nx-set-shas@v3/dist/index.js:14907:8
|     at 5468 (/run/act/actions/nrwl-nx-set-shas@v3/dist/index.js:14966:4)
|     at __nccwpck_require__ (/run/act/actions/nrwl-nx-set-shas@v3/dist/index.js:15256:43)
|     at /run/act/actions/nrwl-nx-set-shas@v3/dist/index.js:15276:37
|     at Object.<anonymous> (/run/act/actions/nrwl-nx-set-shas@v3/dist/index.js:15279:12)
|
| Node.js v18.18.0

The .github/workflows/file.yaml is like this:

name: Pull Request CI
on:
  pull_request:
    branches:
      develop

jobs:
  main:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Install Yarn
        run: yarn --version 2> /dev/null || echo 'yarn was missing so we will install it now' && npm install -g yarn

      # allow the nx command to work when using 'act' to run github action locally for development/testing
      # see https://github.com/nrwl/nx-set-shas/issues/118#issuecomment-1738657287
      - name: Set Directory as Safe
        run: |
          git config --system --add safe.directory "$GITHUB_WORKSPACE"

      - uses: nrwl/nx-set-shas@v3
        with:
          main-branch-name: 'develop'

To run it in the repo, I just do

brew install act
act

and that's where I get the error up top.

According to https://docs.github.com/en/actions/learn-github-actions/contexts#github-context I'm guessing perhaps it would work if the code accessed github.event.merged rather than github.context.payload.pull_request.merged ? It's a bit unclear to me if this is an issue in this repo or perhaps some failing in act, to not mirror the properties in the two different object locations or something. (I'm a bit new to github actions as well, so perhaps I'm missing something else)

@meeroslav meeroslav self-assigned this Nov 14, 2023
@meeroslav
Copy link
Collaborator

Thank you @techieshark, for reporting this. I will investigate as soon as possible.

@JamesHenry
Copy link
Collaborator

Surely if act is not aligned with GitHub, then this is an issue on the act side? Have you reported it there or discussed it on their gitter?

@jantoodre
Copy link

I managed to get it running by doing the following:

  1. Create event file event.json
  2. Provide the pull_request event payload:
    act pull_request -W .github/workflows/file.yaml --eventpath event.json

I'm using act v0.2.54 and nrwl/nx-set-shas@v4

@mandarini
Copy link
Member

Do we think that this is a bug with nx-set-shas, or something that can be configured and possibly on the arc side? @jantoodre @techieshark

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants