Conversation

a1012112796

@GiteaBotGiteaBot added the lgtm/need 2This PR needs two approvals by maintainers to be considered for merging.label Jun 26, 2023
@silverwind

Wait, is this changing something that works on GH Actions to work on Gitea Actions? Why not fix the root cause?

@a1012112796

Wait, is this changing something that works on GH Actions to work on Gitea Actions? Why not fix the root cause?

not, just want make act_runner exec useable, checking changed files is meaningless when using act_runner exec, so just skip this step and make all jobs runable.

@silverwind

Right, so act_runner exec does not run in the scope of a commit with a diff?

Maybe it should instead be something like act_runner exec <commit-ish> to run on a specific commit hash, so that the environment is more close to what it would usually run and changed-when can do its work? I guess there is still value in running locally without a commit, but I'm not sure how to solve that. A number of actions will depend on commit data being present.

@silverwind

I would at minimum make it skip when commit-related environment variables are not set, which I think is the case of exec, e.g. don't make it detect ACT_EXEC but instead _SHA or GITEA_SHA being unset.

Ideally this check would be done in the paths-filter action, e.g. when it is unset, trigger all changes.

@a1012112796

I would at minimum make it skip when commit-related environment variables are not set, which I think is the case of exec, e.g. don't make it detect ACT_EXEC but instead _SHA or GITEA_SHA being unset.

Ideally this check would be done in the paths-filter action, e.g. when it is unset, trigger all changes.

I think checking changed files is meaningless when using act_runner exec. that's because when using act_runner exec, user can choose a job to run manually, so it's not necessary to auto check whether a job should run. not meaning I can't produe some commit-related environment variables to make paths-filter action work in act_runner exec.

@silverwind

Hmm I still wonder if there is a cleaner solution and whetherpaths-filter could somehow be made into emitting all files as changed. Detecting based on ACT_EXEC feels like user-agent sniffing, a very bad practice.

@silverwind

Would base: HEAD option of paths-filter work for this? I think it should also work on uncommited changes as per https://.com/dorny/paths-filter docs, and I think it should also work for our regular runs.

@pull-request-sizepull-request-size bot added size/S and removed size/M labels Jun 30, 2023
Signed-off-by: a1012112796 <[email protected]>
@GiteaBotGiteaBot added lgtm/need 1This PR needs approval from one additional maintainer to be merged.and removed lgtm/need 2This PR needs two approvals by maintainers to be considered for merging.labels Aug 19, 2023
@GiteaBotGiteaBot added lgtm/doneThis PR has enough approvals to get merged. There are no important open reservations anymore.and removed lgtm/need 1This PR needs approval from one additional maintainer to be merged.labels Aug 19, 2023
@silverwindsilverwind self-requested a review August 19, 2023 13:01
@GiteaBotGiteaBot added lgtm/need 1This PR needs approval from one additional maintainer to be merged.and removed lgtm/doneThis PR has enough approvals to get merged. There are no important open reservations anymore.labels Aug 19, 2023
@GiteaBotGiteaBot removed the lgtm/need 1This PR needs approval from one additional maintainer to be merged.label Aug 20, 2023
@GiteaBotGiteaBot added the lgtm/doneThis PR has enough approvals to get merged. There are no important open reservations anymore.label Aug 20, 2023
@silverwind

Let's try with base: HEAD, I think it will work fine for regular runs as well because:

  1. There are no unclean files in a PR checkout, so HEAD should equal the last commit on the branch
  2. The option says that base is ignored for pull_request events

@silverwind

Actually it did not work, with HEAD:

Run dorny/paths-filter@v2
Change detection on HEAD
Detected 0 changed files
Results:
Filter backend = false
Filter frontend = false
Filter docs = false
Filter actions = false
Filter templates = false
Filter docker = false
Filter swagger = false
Changes output set to []

Without HEAD:

Run dorny/paths-filter@v2
Fetching list of changed files for PR#25524 from  API
Detected 4 changed files
Results:
Filter backend = true
Filter frontend = false
Filter docs = false
Filter actions = true
Filter templates = false
Filter docker = false
Filter swagger = false
Changes output set to ["backend","actions"]

Maybe we actually need to detect exec via one of the vars.

@silverwind

@a1012112796 can you try latest change with act exec? I think ref is the right option to set, base was incorrect because that was the base branch it compared to.

@silverwindsilverwind self-requested a review August 20, 2023 14:31
@GiteaBotGiteaBot added lgtm/need 1This PR needs approval from one additional maintainer to be merged.and removed lgtm/doneThis PR has enough approvals to get merged. There are no important open reservations anymore.labels Aug 20, 2023
@a1012112796

@silverwind test result, looks 'base' is required.
image

How about someting like this?

@@ -36,7 +36,7 @@ jobs:
         id: changes
         with:
           # needed for `act_runner exec`
-          ref: ${{ env.ACT_EXEC == 'true' && 'HEAD' || env._REF }}
+          base: ${{ env.ACT_EXEC == 'true' && 'HEAD' || '' }}
           filters: |
             backend:
               - "**/*.go"

@silverwind

Hmm I think we lack .event.repository.default_branch in the act payload, else it would work.

@GiteaBotGiteaBot added lgtm/doneThis PR has enough approvals to get merged. There are no important open reservations anymore.and removed lgtm/need 1This PR needs approval from one additional maintainer to be merged.labels Aug 21, 2023
@silverwindsilverwind self-requested a review August 21, 2023 14:35
@GiteaBotGiteaBot added lgtm/need 1This PR needs approval from one additional maintainer to be merged.and removed lgtm/doneThis PR has enough approvals to get merged. There are no important open reservations anymore.labels Aug 21, 2023
@silverwind

@a1012112796 please try this one, I set base: main, e.g. compare commit to main branch. Likely not correct for non-main PRs but good enough for a test.

@a1012112796

@silverwind looks no changed files was found ...
image

full logs:time="2023-08-22T01:04:24Z" level=info msg="Using chosed event for filtering: pull_request" time="2023-08-22T01:04:24Z" level=info msg="Planning job: test-unit" time="2023-08-22T01:04:24Z" level=info msg="cache handler listens on: http://192.168.170.128:43319" time="2023-08-22T01:04:24Z" level=info msg="Start server on http://192.168.170.128:34567" [files-changed/files-changed/detect] 🚀 Start image=catthehacker/ubuntu:runner-latest time="2023-08-22T01:04:24Z" level=info msg="Parallel tasks (0) below minimum, setting to 1" [files-changed/files-changed/detect] 🐳 docker pull image=catthehacker/ubuntu:runner-latest platform= username= forcePull=false time="2023-08-22T01:04:24Z" level=info msg="Parallel tasks (0) below minimum, setting to 1" [files-changed/files-changed/detect] 🐳 docker create image=catthehacker/ubuntu:runner-latest platform= entrypoint=["/bin/sleep" "10800"] cmd=[] [files-changed/files-changed/detect] 🐳 docker run image=catthehacker/ubuntu:runner-latest platform= entrypoint=["/bin/sleep" "10800"] cmd=[] [files-changed/files-changed/detect] 🐳 docker exec cmd=[chown -R 1001:1001 /home/zzc/gitea_ws/gitea] user=0 workdir= [files-changed/files-changed/detect] ☁ git clone 'https://.com/dorny/paths-filter' # ref=v2 [files-changed/files-changed/detect] ⭐ Run Main actions/checkout@v3 [files-changed/files-changed/detect] 🐳 docker cp src=/home/zzc/gitea_ws/gitea/. dst=/home/zzc/gitea_ws/gitea [files-changed/files-changed/detect] 🐳 docker exec cmd=[chown -R 1001:1001 /home/zzc/gitea_ws/gitea] user=0 workdir= [files-changed/files-changed/detect] ✅ Success - Main actions/checkout@v3 [files-changed/files-changed/detect] ⭐ Run Main dorny/paths-filter@v2 [files-changed/files-changed/detect] 🐳 docker cp src=/home/zzc/.cache/act/dorny-paths-filter@v2/ dst=/var/run/act/actions/dorny-paths-filter@v2/ [files-changed/files-changed/detect] 🐳 docker exec cmd=[chown -R 1001:1001 /var/run/act/actions/dorny-paths-filter@v2/] user=0 workdir= [files-changed/files-changed/detect] 🐳 docker exec cmd=[node /var/run/act/actions/dorny-paths-filter@v2/dist/index.js] user= workdir= [files-changed/files-changed/detect] ❓ ::group::Get current git ref [files-changed/files-changed/detect] | ::group::Get current git ref [files-changed/files-changed/detect] | [command]/usr/bin/git branch --show-current [files-changed/files-changed/detect] | zzc/dev/act_runner_exec [files-changed/files-changed/detect] ❓ ::endgroup:: [files-changed/files-changed/detect] | ::endgroup:: [files-changed/files-changed/detect] | Changes will be detected between main and HEAD [files-changed/files-changed/detect] ❓ ::group::Searching for merge-base main...HEAD [files-changed/files-changed/detect] | ::group::Searching for merge-base main...HEAD [files-changed/files-changed/detect] | [command]/usr/bin/git show-ref main [files-changed/files-changed/detect] | b3f713717407fcb66515a7a702e81b2028800f76 refs/heads/main [files-changed/files-changed/detect] | 3db3f5daaeea38a9a8d8ec1a05d864e288338f82 refs/remotes/or_p/main [files-changed/files-changed/detect] | da6df0d0636c9e7bb5481e41dcd7d8f9b46deed5 refs/remotes/or_zzc/main [files-changed/files-changed/detect] | b3f713717407fcb66515a7a702e81b2028800f76 refs/remotes/origin/main [files-changed/files-changed/detect] | 1e76a824bcd71acd59cdfb2c4547806bc34b3d86 refs/remotes/yp05327/main [files-changed/files-changed/detect] | [command]/usr/bin/git show-ref HEAD [files-changed/files-changed/detect] | b3f713717407fcb66515a7a702e81b2028800f76 refs/remotes/origin/HEAD [files-changed/files-changed/detect] | [command]/usr/bin/git merge-base refs/remotes/origin/main refs/remotes/origin/HEAD [files-changed/files-changed/detect] | b3f713717407fcb66515a7a702e81b2028800f76 [files-changed/files-changed/detect] ❓ ::endgroup:: [files-changed/files-changed/detect] | ::endgroup:: [files-changed/files-changed/detect] ❓ ::group::Change detection refs/remotes/origin/main...refs/remotes/origin/HEAD [files-changed/files-changed/detect] | ::group::Change detection refs/remotes/origin/main...refs/remotes/origin/HEAD [files-changed/files-changed/detect] | [command]/usr/bin/git diff --no-renames --name-status -z refs/remotes/origin/main...refs/remotes/origin/HEAD [files-changed/files-changed/detect] | [files-changed/files-changed/detect] ❓ ::endgroup:: [files-changed/files-changed/detect] | ::endgroup:: [files-changed/files-changed/detect] | Detected 0 changed files [files-changed/files-changed/detect] | Results: [files-changed/files-changed/detect] ❓ ::group::Filter backend = false [files-changed/files-changed/detect] | ::group::Filter backend = false [files-changed/files-changed/detect] | Matching files: none [files-changed/files-changed/detect] ❓ ::endgroup:: [files-changed/files-changed/detect] | ::endgroup:: [files-changed/files-changed/detect] ❓ ::group::Filter frontend = false [files-changed/files-changed/detect] | ::group::Filter frontend = false [files-changed/files-changed/detect] | Matching files: none [files-changed/files-changed/detect] ❓ ::endgroup:: [files-changed/files-changed/detect] | ::endgroup:: [files-changed/files-changed/detect] ❓ ::group::Filter docs = false [files-changed/files-changed/detect] | ::group::Filter docs = false [files-changed/files-changed/detect] | Matching files: none [files-changed/files-changed/detect] ❓ ::endgroup:: [files-changed/files-changed/detect] | ::endgroup:: [files-changed/files-changed/detect] ❓ ::group::Filter actions = false [files-changed/files-changed/detect] | ::group::Filter actions = false [files-changed/files-changed/detect] | Matching files: none [files-changed/files-changed/detect] ❓ ::endgroup:: [files-changed/files-changed/detect] | ::endgroup:: [files-changed/files-changed/detect] ❓ ::group::Filter templates = false [files-changed/files-changed/detect] | ::group::Filter templates = false [files-changed/files-changed/detect] | Matching files: none [files-changed/files-changed/detect] ❓ ::endgroup:: [files-changed/files-changed/detect] | ::endgroup:: [files-changed/files-changed/detect] ❓ ::group::Filter docker = false [files-changed/files-changed/detect] | ::group::Filter docker = false [files-changed/files-changed/detect] | Matching files: none [files-changed/files-changed/detect] ❓ ::endgroup:: [files-changed/files-changed/detect] | ::endgroup:: [files-changed/files-changed/detect] ❓ ::group::Filter swagger = false [files-changed/files-changed/detect] | ::group::Filter swagger = false [files-changed/files-changed/detect] | Matching files: none [files-changed/files-changed/detect] ❓ ::endgroup:: [files-changed/files-changed/detect] | ::endgroup:: [files-changed/files-changed/detect] | Changes output set to [] [files-changed/files-changed/detect] ✅ Success - Main dorny/paths-filter@v2 [files-changed/files-changed/detect] ⚙ ::set-output:: backend_count=0 [files-changed/files-changed/detect] ⚙ ::set-output:: frontend=false [files-changed/files-changed/detect] ⚙ ::set-output:: actions_count=0 [files-changed/files-changed/detect] ⚙ ::set-output:: swagger=false [files-changed/files-changed/detect] ⚙ ::set-output:: swagger_count=0 [files-changed/files-changed/detect] ⚙ ::set-output:: changes=[] [files-changed/files-changed/detect] ⚙ ::set-output:: docs_count=0 [files-changed/files-changed/detect] ⚙ ::set-output:: actions=false [files-changed/files-changed/detect] ⚙ ::set-output:: docs=false [files-changed/files-changed/detect] ⚙ ::set-output:: templates=false [files-changed/files-changed/detect] ⚙ ::set-output:: templates_count=0 [files-changed/files-changed/detect] ⚙ ::set-output:: docker=false [files-changed/files-changed/detect] ⚙ ::set-output:: backend=false [files-changed/files-changed/detect] ⚙ ::set-output:: frontend_count=0 [files-changed/files-changed/detect] ⚙ ::set-output:: docker_count=0 [files-changed/files-changed/detect] Cleaning up services for job detect time="2023-08-22T01:04:32Z" level=info msg="Parallel tasks (0) below minimum, setting to 1" [files-changed/files-changed/detect] Cleaning up container for job detect [files-changed/files-changed/detect] Cleaning up network for job detect, and network name is: GITEA-ACTIONS-TASK-pull-request_WORKFLOW-files-changed_JOB-detect-network [files-changed/files-changed/detect] 🏁 Job succeeded

looks only when the base is HEAD it will detect on HEAD directly.
image

@silverwind

Hmm, the problem with base: HEAD is that if you have commited changes on the branch, it would incorrectly use the last commit on the branch.

What we want is a diff between PR target branch and current working tree including any potential uncomitted changes, e.g. the output of git diff <target-branch>, not git diff HEAD. The module seems to diff with ref..head, but as far as I know, working tree has no commit-ish reference.

@lunny

Could you resolve the conflicts?

Sign up for free to join this conversation on . Already have an account? Sign in to comment
lgtm/need 1This PR needs approval from one additional maintainer to be merged.
None yet

Successfully merging this pull request may close these issues.