[GH-ISSUE #526] Issue: act will parse/evaluate arithmetic context expressions that github wont #356

Closed
opened 2026-03-01 21:42:37 +03:00 by kerem · 5 comments
Owner

Originally created by @dannystaple on GitHub (Feb 9, 2021).
Original GitHub issue: https://github.com/nektos/act/issues/526

Act version

$ act --version
act version 0.2.20

Expected behaviour

The code below, which looks viable, is actually invalid. Run within the genuine github workflow context, it will result in invalid reference and not run the whole workflow file. I would expect act to output the same error for the same line.

Actual behaviour

Act will evaluate this expression to the value. This leads to workflows debugged/developed locally that will not run in github.

Workflow and/or repository

The step definition (minimal reproducible):

name: unreal
jobs:
  reproduce:
    runs-on: ubuntu-latest
    steps:
      - env:
          EXPIRY_TIME: ${{ 3 * 24 * 60 * 60 }}
        run: echo ${EXPIRY_TIME}

Steps to reproduce

Run the above in act (eg act push), it will run, and echo that calculated time.
Commit to github (with the right on definition to function) and it will fail.

Originally created by @dannystaple on GitHub (Feb 9, 2021). Original GitHub issue: https://github.com/nektos/act/issues/526 ## Act version ```none $ act --version act version 0.2.20 ``` ## Expected behaviour The code below, which looks viable, is actually invalid. Run within the genuine github workflow context, it will result in invalid reference and not run the whole workflow file. I would expect act to output the same error for the same line. ## Actual behaviour Act will evaluate this expression to the value. This leads to workflows debugged/developed locally that will not run in github. ## Workflow and/or repository The step definition (minimal reproducible): ``` name: unreal jobs: reproduce: runs-on: ubuntu-latest steps: - env: EXPIRY_TIME: ${{ 3 * 24 * 60 * 60 }} run: echo ${EXPIRY_TIME} ``` ## Steps to reproduce Run the above in act (eg `act push`), it will run, and echo that calculated time. Commit to github (with the right on definition to function) and it will fail.
Author
Owner

@github-actions[bot] commented on GitHub (Mar 12, 2021):

Issue is stale and will be closed in 14 days unless there is new activity

<!-- gh-comment-id:797146555 --> @github-actions[bot] commented on GitHub (Mar 12, 2021): Issue is stale and will be closed in 14 days unless there is new activity
Author
Owner

@mikemonkers commented on GitHub (Mar 12, 2021):

I also see this very same issue. It would be nice to align with GitHub or indicate whether GitHub have plans to add support?

<!-- gh-comment-id:797354268 --> @mikemonkers commented on GitHub (Mar 12, 2021): I also see this very same issue. It would be nice to align with GitHub or indicate whether GitHub have plans to add support?
Author
Owner

@jsoref commented on GitHub (Apr 4, 2021):

Short of reinventing parsing, I can't imagine a good way of handling this. Under the hood, act creates a JavaScript VM (Otto):
github.com/nektos/act@41b03b581chile96e9a5ea27009542a798d4/pkg/runner/expression.go#L34-L37

It then asks the VM to evaluate the expression.

* could appear in strings, or in comments. At least the former should be legal in GHA. Not sure about the latter.

While I can understand getting bitten by this edge 😦, I'd hate to have to try to write a fix for it 😨.

(There are other nearby edges that I do want to fix...)

<!-- gh-comment-id:812993917 --> @jsoref commented on GitHub (Apr 4, 2021): Short of reinventing parsing, I can't imagine a good way of handling this. Under the hood, act creates a JavaScript VM (Otto): https://github.com/nektos/act/blob/41b03b581c7aec251dhile96e9a5ea27009542a798d4/pkg/runner/expression.go#L34-L37 It then asks the VM to evaluate the expression. `*` could appear in strings, or in comments. At least the former should be legal in GHA. Not sure about the latter. While I can understand getting bitten by this edge 😦, I'd hate to have to try to write a fix for it 😨. (There are other nearby edges that I do want to fix...)
Author
Owner

@github-actions[bot] commented on GitHub (May 5, 2021):

Issue is stale and will be closed in 14 days unless there is new activity

<!-- gh-comment-id:832331525 --> @github-actions[bot] commented on GitHub (May 5, 2021): Issue is stale and will be closed in 14 days unless there is new activity
Author
Owner

@ZauberNerd commented on GitHub (Feb 1, 2022):

This has been fixed with: https://github.com/nektos/act/pull/908 and will be released with the next version.
If you want to try it out earlier, use one of the snapshots: https://github.com/nektos/act/actions/runs/1653750680 or install / build from master: https://github.com/nektos/act#go-linuxwindowsmacosany-other-platform-supported-by-go https://github.com/nektos/act#manually-building-from-source

<!-- gh-comment-id:1027161413 --> @ZauberNerd commented on GitHub (Feb 1, 2022): This has been fixed with: https://github.com/nektos/act/pull/908 and will be released with the next version. If you want to try it out earlier, use one of the snapshots: https://github.com/nektos/act/actions/runs/1653750680 or install / build from master: https://github.com/nektos/act#go-linuxwindowsmacosany-other-platform-supported-by-go https://github.com/nektos/act#manually-building-from-source
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#356
No description provided.