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

hashFiles does not resolve paths relative to GITHUB_WORKSPACE #2014

Closed
notmgsk opened this issue Sep 20, 2023 · 2 comments · Fixed by #1940
Closed

hashFiles does not resolve paths relative to GITHUB_WORKSPACE #2014

notmgsk opened this issue Sep 20, 2023 · 2 comments · Fixed by #1940
Labels
kind/bug Something isn't working

Comments

@notmgsk
Copy link

notmgsk commented Sep 20, 2023

Bug report info

act version:            0.2.50
GOOS:                   linux
GOARCH:                 amd64
NumCPU:                 16
Docker host:            DOCKER_HOST environment variable is not set
Sockets found:
	/var/run/docker.sock
Config files:           
	/home/mgsk/.actrc:
		-P ubuntu-latest=catthehacker/ubuntu:act-latest
		-P ubuntu-22.04=catthehacker/ubuntu:act-22.04
		-P ubuntu-20.04=catthehacker/ubuntu:act-20.04
		-P ubuntu-18.04=catthehacker/ubuntu:act-18.04
		--env ACTIONS_CACHE_URL=http://localhost:8080/
		--env ACTIONS_RUNTIME_URL=http://localhost:8080/
		--env ACTIONS_RUNTIME_TOKEN=foo
Build info:
	Go version:            go1.20.7
	Module path:           github.com/nektos/act
	Main version:          (devel)
	Main path:             github.com/nektos/act
	Main checksum:         
	Build settings:
		-buildmode:           exe
		-compiler:            gc
		-ldflags:             -s -w -X main.version=0.2.50 -X main.commit=80b0955303888742c3ab73af5758bb7b01f5f57c -X main.date=2023-09-01T02:12:50Z -X main.builtBy=goreleaser
		CGO_ENABLED:          0
		GOARCH:               amd64
		GOOS:                 linux
		GOAMD64:              v1
		vcs:                  git
		vcs.revision:         80b0955303888742c3ab73af5758bb7b01f5f57c
		vcs.time:             2023-09-01T02:12:28Z
		vcs.modified:         false
Docker Engine:
	Engine version:        20.10.21
	Engine runtime:        runc
	Cgroup version:        2
	Cgroup driver:         systemd
	Storage driver:        overlay2
	Registry URI:          https://index.docker.io/v1/
	OS:                    Ubuntu 23.04
	OS type:               linux
	OS version:            23.04
	OS arch:               x86_64
	OS kernel:             6.2.0-32-generic
	OS CPU:                16
	OS memory:             64232 MB
	Security options:
		name=apparmor
		name=seccomp,profile=default
		name=cgroupns

Command used with act

`./bin/act`

Describe issue

The github actions docs state

The path is relative to the GITHUB_WORKSPACE directory
but that does not appear to be so when using act.

See the attached repo which

  • has a workflow that uses the checkout action with a path
  • has a file foo at its root
  • has a step which prints the value of hashFiles('foo')

In Github's own runner, this works fine: the file foo is found, hashed, and printed. When using act, the file is not found.

Link to GitHub repository

https://github.com/notmgsk/act-bug

Workflow content

name: Test

on:
  push:

jobs:
  test:
    name: Test
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
        with:
          path: "test"

      - name: test
        env:
          THE_HASH: ${{ hashFiles('test/foo') }}
        run: echo $THE_HASH

Relevant log output

time="2023-09-20T19:19:40+01:00" level=debug msg="Loading environment from /home/mgsk/hackery/other/act-bug/.env"
time="2023-09-20T19:19:40+01:00" level=debug msg="Loading action inputs from /home/mgsk/hackery/other/act-bug/.input"
time="2023-09-20T19:19:40+01:00" level=debug msg="Loading secrets from /home/mgsk/hackery/other/act-bug/.secrets"
time="2023-09-20T19:19:40+01:00" level=debug msg="Loading vars from /home/mgsk/hackery/other/act-bug/.vars"
time="2023-09-20T19:19:40+01:00" level=debug msg="Conditional GET for notices etag=80e90080-cbc3-41d4-b5f6-18ef0d15e0d0"
time="2023-09-20T19:19:40+01:00" level=debug msg="Evaluated matrix inclusions: map[]"
time="2023-09-20T19:19:40+01:00" level=debug msg="Loading workflows from '/home/mgsk/hackery/other/act-bug/.github/workflows'"
time="2023-09-20T19:19:40+01:00" level=debug msg="Loading workflows recursively"
time="2023-09-20T19:19:40+01:00" level=debug msg="Found workflow 'test.yml' in '/home/mgsk/hackery/other/act-bug/.github/workflows/test.yml'"
time="2023-09-20T19:19:40+01:00" level=debug msg="Reading workflow '/home/mgsk/hackery/other/act-bug/.github/workflows/test.yml'"
time="2023-09-20T19:19:40+01:00" level=debug msg="Preparing plan with all jobs"
time="2023-09-20T19:19:40+01:00" level=debug msg="Using the only detected workflow event: push"
time="2023-09-20T19:19:40+01:00" level=debug msg="Planning jobs for event: push"
time="2023-09-20T19:19:40+01:00" level=debug msg="Plan Stages: [0xc0004ad3b0]"
time="2023-09-20T19:19:40+01:00" level=debug msg="Stages Runs: [Test]"
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Name: Test"
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.RawNeeds: {0 0    <nil> []    0 0}"
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.RawRunsOn: {8 0 !!str ubuntu-latest  <nil> []    9 14}"
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Env: {0 0    <nil> []    0 0}"
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.If: {0 0  success()  <nil> []    0 0}"
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Steps: actions/checkout@v2"
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Steps: test"
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.TimeoutMinutes: "
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Services: map[]"
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Strategy: <nil>"
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.RawContainer: {0 0    <nil> []    0 0}"
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Defaults.Run.Shell: "
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Defaults.Run.WorkingDirectory: "
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Outputs: map[]"
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Uses: "
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.With: map[]"
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Result: "
time="2023-09-20T19:19:40+01:00" level=debug msg="Empty Strategy, matrixes=[map[]]"
time="2023-09-20T19:19:40+01:00" level=debug msg="Job Matrices: [map[]]"
time="2023-09-20T19:19:40+01:00" level=debug msg="Runner Matrices: map[]"
time="2023-09-20T19:19:40+01:00" level=debug msg="Final matrix after applying user inclusions '[map[]]'"
time="2023-09-20T19:19:40+01:00" level=debug msg="Loading revision from git directory"
time="2023-09-20T19:19:40+01:00" level=debug msg="Found revision: 7637d68d81a405033ac72362bec5afffdb10776a"
time="2023-09-20T19:19:40+01:00" level=debug msg="HEAD points to '7637d68d81a405033ac72362bec5afffdb10776a'"
time="2023-09-20T19:19:40+01:00" level=debug msg="using github ref: refs/heads/master"
time="2023-09-20T19:19:40+01:00" level=debug msg="Found revision: 7637d68d81a405033ac72362bec5afffdb10776a"
time="2023-09-20T19:19:40+01:00" level=debug msg="Detected CPUs: 16"
time="2023-09-20T19:19:41+01:00" level=debug msg="Saving notices etag=80e90080-cbc3-41d4-b5f6-18ef0d15e0d0"
time="2023-09-20T19:19:41+01:00" level=debug msg="No new notices"

Additional information

No response

@notmgsk notmgsk added the kind/bug Something isn't working label Sep 20, 2023
@ChristopherHX
Copy link
Contributor

Yeah I wanted to fix it via #1940 (part of my fork of act for github-act-runner), but merging is blocked, by running hashfiles inside the container.

hashfiles currently operates relative to the checked out repository on the caller side where act is run.

@notmgsk
Copy link
Author

notmgsk commented Sep 21, 2023

Yeah I wanted to fix it via #1940 (part of my fork of act for github-act-runner), but merging is blocked, by running hashfiles inside the container.

hashfiles currently operates relative to the checked out repository on the caller side where act is run.

Thanks for the info, @ChristopherHX. I hope you're able to get your fix merged.

In the meantime, I side-stepped the issue by doing hashFiles('**/<file>') where <file> is unique in the repo.

@mergify mergify bot closed this as completed in #1940 Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants