bug: hashFiles with space-separated files is empty #285

Closed
opened 2024-09-27 18:07:55 +00:00 by fnetX · 6 comments
Owner

Reproducer (I put this file into the Forgejo repo locally):

name: example

on:
  pull_request:
  push:

jobs:
  test:
    runs-on: docker
    container:
      image: 'code.forgejo.org/oci/node:20-bookworm'
    steps:
      - uses: https://code.forgejo.org/actions/checkout@v3
      - name: test something
        run: |
          echo ${{ hashFiles('go.sum', 'go.mod')}}
          echo ${{ hashFiles('go.sum go.mod')}}
          echo ${{ hashFiles('go.sum')}}
          echo ${{ hashFiles('go.mod')}}

Output:

[example/test] ⭐ Run Main test something
[example/test] unable to get git repo (githubInstance: ; remoteName: , repoPath: /home/fnetx/Documents/codeberg/forgejo/forgejo): remote not found
[example/test] unable to get git repo (githubInstance: ; remoteName: , repoPath: /home/fnetx/Documents/codeberg/forgejo/forgejo): remote not found
[example/test] unable to get git repo (githubInstance: ; remoteName: , repoPath: /home/fnetx/Documents/codeberg/forgejo/forgejo): remote not found
[example/test] unable to get git repo (githubInstance: ; remoteName: , repoPath: /home/fnetx/Documents/codeberg/forgejo/forgejo): remote not found
[example/test]   🐳  docker exec cmd=[node /var/run/act/workflow/hashfiles/index.js] user= workdir=
[example/test]   🐳  docker exec cmd=[node /var/run/act/workflow/hashfiles/index.js] user= workdir=
[example/test]   🐳  docker exec cmd=[node /var/run/act/workflow/hashfiles/index.js] user= workdir=
[example/test]   🐳  docker exec cmd=[node /var/run/act/workflow/hashfiles/index.js] user= workdir=
[example/test]   🐳  docker exec cmd=[sh -e /var/run/act/workflow/1.sh] user= workdir=
| 39b35c59b92fdb3024d09a4f2f960d123ba59c3d531569f5195b65fbf0a40161
| 
| 5f06936f0fb3951e35c5bd31e9bcd3069e103486fe35de689975aa59b7b64f9c
| 6eb2c5540809c9572b69f883d1fc30eed509260db5fcebae1d5a15573c5dd9c1
[example/test]   ✅  Success - Main test something

Other issues with hashFiles: #54

This is causing issues for me with https://codeberg.org/forgejo/forgejo/pulls/5328 - I'm wondering if this was the root cause for the setup-go action to waste so much resources on the post step 🤔

Reproducer (I put this file into the Forgejo repo locally): ~~~ name: example on: pull_request: push: jobs: test: runs-on: docker container: image: 'code.forgejo.org/oci/node:20-bookworm' steps: - uses: https://code.forgejo.org/actions/checkout@v3 - name: test something run: | echo ${{ hashFiles('go.sum', 'go.mod')}} echo ${{ hashFiles('go.sum go.mod')}} echo ${{ hashFiles('go.sum')}} echo ${{ hashFiles('go.mod')}} ~~~ Output: ~~~ [example/test] ⭐ Run Main test something [example/test] unable to get git repo (githubInstance: ; remoteName: , repoPath: /home/fnetx/Documents/codeberg/forgejo/forgejo): remote not found [example/test] unable to get git repo (githubInstance: ; remoteName: , repoPath: /home/fnetx/Documents/codeberg/forgejo/forgejo): remote not found [example/test] unable to get git repo (githubInstance: ; remoteName: , repoPath: /home/fnetx/Documents/codeberg/forgejo/forgejo): remote not found [example/test] unable to get git repo (githubInstance: ; remoteName: , repoPath: /home/fnetx/Documents/codeberg/forgejo/forgejo): remote not found [example/test] 🐳 docker exec cmd=[node /var/run/act/workflow/hashfiles/index.js] user= workdir= [example/test] 🐳 docker exec cmd=[node /var/run/act/workflow/hashfiles/index.js] user= workdir= [example/test] 🐳 docker exec cmd=[node /var/run/act/workflow/hashfiles/index.js] user= workdir= [example/test] 🐳 docker exec cmd=[node /var/run/act/workflow/hashfiles/index.js] user= workdir= [example/test] 🐳 docker exec cmd=[sh -e /var/run/act/workflow/1.sh] user= workdir= | 39b35c59b92fdb3024d09a4f2f960d123ba59c3d531569f5195b65fbf0a40161 | | 5f06936f0fb3951e35c5bd31e9bcd3069e103486fe35de689975aa59b7b64f9c | 6eb2c5540809c9572b69f883d1fc30eed509260db5fcebae1d5a15573c5dd9c1 [example/test] ✅ Success - Main test something ~~~ Other issues with hashFiles: https://code.forgejo.org/forgejo/runner/issues/54 This is causing issues for me with https://codeberg.org/forgejo/forgejo/pulls/5328 - I'm wondering if this was the root cause for the setup-go action to waste so much resources on the post step 🤔
fnetX changed title from hashFiles with multiple files is empty to hashFiles with space-separated files is empty 2024-09-27 18:09:32 +00:00
Author
Owner

Making the arguments comma-separated works. I used the space-separated syntax, because I copied from https://github.com/actions/setup-go/issues/316#issuecomment-1632123279

Making the arguments comma-separated works. I used the space-separated syntax, because I copied from https://github.com/actions/setup-go/issues/316#issuecomment-1632123279
Author
Owner

For the record, I would suspect this issue is also present in upstream act. I could not find related changes and the testcases do not cover the syntax presented here github.com/Bigpet/act@d6b2e9df78/pkg/runner/expression_test.go (L85)

For the record, I would suspect this issue is also present in upstream act. I could not find related changes and the testcases do not cover the syntax presented here https://github.com/Bigpet/act/blob/d6b2e9df784921dc82b9ee36ec89e4a5b358f41c/pkg/runner/expression_test.go#L85
earl-warren changed title from hashFiles with space-separated files is empty to bug: hashFiles with space-separated files is empty 2025-07-01 17:39:23 +00:00
Contributor

The documentation should be updated to explain this in the entry documenting the hashFile function https://forgejo.org/docs/v12.0/user/actions/#functions and a test added to end-to-end.

- uses: actions/checkout@v4
- name: hashFiles
run: |
set -x
hash="aea6ca2329c852f5b480ec35e1fe09d39a6bd1b50f4f9cc38fbd4fef870dc107"
test "${{ hashFiles('.forgejo/fileone.txt') }}" = $hash
test "${{ hashFiles('.forgejo/fileone.*') }}" = $hash

The documentation should be updated to explain this in the entry documenting the `hashFile` function https://forgejo.org/docs/v12.0/user/actions/#functions and a test added to end-to-end. https://code.forgejo.org/forgejo/end-to-end/src/commit/4ee6b65584a034db246fa9efa444adc29e8ad7b7/actions/example-expression/.forgejo/workflows/test.yml#L101-L108
Contributor

https://docs.github.com/en/actions/reference/workflows-and-actions/expressions#hashfiles does not suggest a whitespace separated list of files in a single argument is allowed. Only that multiple arguments can be provided, each for a file or pattern. Therefore I don't think it could be the reason why setup-go is taking long in the post step.

https://docs.github.com/en/actions/reference/workflows-and-actions/expressions#hashfiles does not suggest a whitespace separated list of files in a single argument is allowed. Only that multiple arguments can be provided, each for a file or pattern. Therefore I don't think it could be the reason why setup-go is taking long in the post step.
Contributor

An update to the documentation to explain the hashFiles function is proposed at https://codeberg.org/forgejo/docs/pulls/1492

An update to the documentation to explain the `hashFiles` function is proposed at https://codeberg.org/forgejo/docs/pulls/1492
Contributor

The documentation update was merged.

The documentation update was merged.
Sign in to join this conversation.
No milestone
No assignees
2 participants
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
forgejo/runner#285
No description provided.