job.<job_id>.if is ignored when using reusable workflow #31

Open
opened 2024-03-01 17:19:10 +00:00 by Edgarsons · 2 comments

When using a conditional job that utilizes a reusable workflow, job.<job_id>.if is completely ignored.

attels

The workflow test.yaml has two jobs with same condition, but only the job test is skipped, the job test-reusable which is using a reusable workflow is executed.

Workflow content

reusable.yaml

"on":
  - workflow_call
jobs:
  some-job:
    container:
      image: alpine
    defaults:
      run:
        shell: sh
    runs-on: docker
    steps:
      - run: printf 'Output from within a reusable workflow\n'

test.yaml

"on":
  - push
jobs:
  test:
    container:
      image: alpine
    defaults:
      run:
        shell: sh
    if: 1 == 2
    runs-on: docker
    steps:
      - run: printf 'This job should never be executed\n'
  test-reusable:
    if: 1 == 2
    uses: ./.forgejo/workflows/reusable.yaml

Relevant log output

For the job test

runner(version:v3.3.0) received task 1030 of job 1091, be triggered by event: push
workflow prepared
evaluating expression '1 == 2'
expression '1 == 2' evaluated to 'false'
Skipping job 'test' due to '1 == 2'

For the job test-reusable

runner(version:v3.3.0) received task 1031 of job 1092, be triggered by event: push
workflow prepared
evaluating expression '1 == 2'
expression '1 == 2' evaluated to 'false'
  ☁  git clone 'http://server.forgejo_default:3000/EasyFoods/User-service' # ref=b34251e5a4d13d9ba05c3d149935c92119063eff
  cloning http://server.forgejo_default:3000/EasyFoods/User-service to /data/.cache/act/EasyFoods-User-service-.forgejo-workflows-reusable.yaml@b34251e5a4d13d9ba05c3d149935c92119063eff
Cloned http://server.forgejo_default:3000/EasyFoods/User-service to /data/.cache/act/EasyFoods-User-service-.forgejo-workflows-reusable.yaml@b34251e5a4d13d9ba05c3d149935c92119063eff
Checked out b34251e5a4d13d9ba05c3d149935c92119063eff
evaluating expression 'success()'
expression 'success()' evaluated to 'true'
🚀  Start image=alpine
  🐳  docker pull image=alpine platform= username= forcePull=false
  🐳  docker pull alpine
Image exists? false
pulling image 'docker.io/library/alpine' ()
Pulling from library/alpine :: latest
Digest: sha256:c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761f8e1ad6b :: 
Status: Downloaded newer image for alpine:latest :: 
  🐳  docker create image=alpine platform= entrypoint=["/bin/sleep" "10800"] cmd=[]
Common container.Config ==> &{Hostname: Domainname: User: AttachStdin:false AttachStdout:false AttachStderr:false ExposedPorts:map[] Tty:false OpenStdin:false StdinOnce:false Env:[RUNNER_TOOL_CACHE=/opt/hostedtoolcache RUNNER_OS=Linux RUNNER_ARCH=X64 RUNNER_TEMP=/tmp LANG=C.UTF-8] Cmd:[] Healthcheck:<nil> ArgsEscaped:false Image:alpine Volumes:map[] WorkingDir:/workspace/EasyFoods/User-service Entrypoint:[] NetworkDisabled:false MacAddress: OnBuild:[] Labels:map[] StopSignal: StopTimeout:<nil> Shell:[]}
Common container.HostConfig ==> &{Binds:[/var/run/docker.sock:/var/run/docker.sock] ContainerIDFile: LogConfig:{Type: Config:map[]} NetworkMode:host PortBindings:map[] RestartPolicy:{Name: MaximumRetryCount:0} AutoRemove:true VolumeDriver: VolumesFrom:[] ConsoleSize:[0 0] Annotations:map[] CapAdd:[] CapDrop:[] CgroupnsMode: DNS:[] DNSOptions:[] DNSSearch:[] ExtraHosts:[] GroupAdd:[] IpcMode: Cgroup: Links:[] OomScoreAdj:0 PidMode: Privileged:false PublishAllPorts:false ReadonlyRootfs:false SecurityOpt:[] StorageOpt:map[] Tmpfs:map[] UTSMode: UsernsMode: ShmSize:0 Sysctls:map[] Runtime: Isolation: Resources:{CPUShares:0 Memory:0 NanoCPUs:0 CgroupParent: BlkioWeight:0 BlkioWeightDevice:[] BlkioDeviceReadBps:[] BlkioDeviceWriteBps:[] BlkioDeviceReadIOps:[] BlkioDeviceWriteIOps:[] CPUPeriod:0 CPUQuota:0 CPURealtimePeriod:0 CPURealtimeRuntime:0 CpusetCpus: CpusetMems: Devices:[] DeviceCgroupRules:[] DeviceRequests:[] KernelMemory:0 KernelMemoryTCP:0 MemoryReservation:0 MemorySwap:0 MemorySwappiness:<nil> OomKillDisable:<nil> PidsLimit:<nil> Ulimits:[] CPUCount:0 CPUPercent:0 IOMaximumIOps:0 IOMaximumBandwidth:0} Mounts:[{Type:volume Source:act-toolcache Target:/toolcache ReadOnly:false Consistency: BindOptions:<nil> VolumeOptions:<nil> TmpfsOptions:<nil> ClusterOptions:<nil>} {Type:volume Source:GITEA-ACTIONS-TASK-1031_WORKFLOW-reusable-yaml_JOB-some-job-env Target:/var/run/act ReadOnly:false Consistency: BindOptions:<nil> VolumeOptions:<nil> TmpfsOptions:<nil> ClusterOptions:<nil>} {Type:volume Source:GITEA-ACTIONS-TASK-1031_WORKFLOW-reusable-yaml_JOB-some-job Target:/workspace/EasyFoods/User-service ReadOnly:false Consistency: BindOptions:<nil> VolumeOptions:<nil> TmpfsOptions:<nil> ClusterOptions:<nil>}] MaskedPaths:[] ReadonlyPaths:[] Init:<nil>}
Created container name=GITEA-ACTIONS-TASK-1031_WORKFLOW-reusable-yaml_JOB-some-job id=738a6ae2e7a16a507addb8d364f04e308902938fe62641ad8247f5aab8ee220a from image alpine (platform: )
ENV ==> [RUNNER_TOOL_CACHE=/opt/hostedtoolcache RUNNER_OS=Linux RUNNER_ARCH=X64 RUNNER_TEMP=/tmp LANG=C.UTF-8]
  🐳  docker run image=alpine platform= entrypoint=["/bin/sleep" "10800"] cmd=[]
Starting container: 738a6ae2e7a16a507addb8d364f04e308902938fe62641ad8247f5aab8ee220a
Started container: 738a6ae2e7a16a507addb8d364f04e308902938fe62641ad8247f5aab8ee220a
Writing entry to tarball workflow/event.json len:6249
Writing entry to tarball workflow/envs.txt len:0
Extracting content to '/var/run/act/'
setupEnv => map[ACT:true ACTIONS_CACHE_URL:http://192.168.128.5:44421/ ACTIONS_RUNTIME_TOKEN:*** ACTIONS_RUNTIME_URL:http://server.forgejo_default:3000/api/actions_pipeline/ CI:true GITEA_ACTIONS:true GITEA_ACTIONS_RUNNER_VERSION:v3.3.0 GITHUB_ACTION:0 GITHUB_ACTIONS:true GITHUB_ACTION_PATH: GITHUB_ACTION_REF: GITHUB_ACTION_REPOSITORY: GITHUB_ACTOR:Name GITHUB_API_URL:http://server.forgejo_default:3000/api/v1 GITHUB_BASE_REF: GITHUB_EVENT_NAME:push GITHUB_EVENT_PATH:/var/run/act/workflow/event.json GITHUB_GRAPHQL_URL: GITHUB_HEAD_REF: GITHUB_JOB:some-job GITHUB_REF:refs/heads/Pull-request-preview-environment GITHUB_REF_NAME:Pull-request-preview-environment GITHUB_REF_TYPE:branch GITHUB_REPOSITORY:EasyFoods/User-service GITHUB_REPOSITORY_OWNER:EasyFoods GITHUB_RETENTION_DAYS: GITHUB_RUN_ID:517 GITHUB_RUN_NUMBER:274 GITHUB_SERVER_URL:http://server.forgejo_default:3000 GITHUB_SHA:b34251e5a4d13d9ba05c3d149935c92119063eff GITHUB_TOKEN:*** GITHUB_WORKFLOW:reusable.yaml GITHUB_WORKSPACE:/workspace/EasyFoods/User-service ImageOS:docker JOB_CONTAINER_NAME:GITEA-ACTIONS-TASK-1031_WORKFLOW-reusable-yaml_JOB-some-job RUNNER_PERFLOG:/dev/null RUNNER_TRACKING_ID:]
evaluating expression ''
expression '' evaluated to 'true'
⭐ Run Main printf 'Output from within a reusable workflow\n'
Writing entry to tarball workflow/outputcmd.txt len:0
Writing entry to tarball workflow/statecmd.txt len:0
Writing entry to tarball workflow/pathcmd.txt len:0
Writing entry to tarball workflow/envs.txt len:0
Writing entry to tarball workflow/SUMMARY.md len:0
Extracting content to '/var/run/act'
Wrote command \n\nprintf 'Output from within a reusable workflow\n'\n\n to 'workflow/0.sh'
Writing entry to tarball workflow/0.sh len:51
Extracting content to '/var/run/act'
  🐳  docker exec cmd=[sh -e /var/run/act/workflow/0.sh] user= workdir=
Exec command '[sh -e /var/run/act/workflow/0.sh]'
Working directory '/workspace/EasyFoods/User-service'
Output from within a reusable workflow
  ✅  Success - Main printf 'Output from within a reusable workflow\n'
Cleaning up services for job some-job
Cleaning up container for job some-job
Removed container: 738a6ae2e7a16a507addb8d364f04e308902938fe62641ad8247f5aab8ee220a
  🐳  docker volume rm GITEA-ACTIONS-TASK-1031_WORKFLOW-reusable-yaml_JOB-some-job
  🐳  docker volume rm GITEA-ACTIONS-TASK-1031_WORKFLOW-reusable-yaml_JOB-some-job-env
🏁  Job succeeded

Additional information

Here is the relevant issue in the nektos/act GitHub repository, which has been fixed with the commit 5547789, and the fix was released with the version 0.2.54.

As a workaround I added an input run to the reusable workflow where it is used as a condition (inputs.run == 'true') for all jobs.

When using a conditional job that utilizes a reusable workflow, `job.<job_id>.if` is completely ignored. ![attels](/attachments/497a3a99-83c9-46be-936c-9d10cccb4882) The workflow `test.yaml` has two jobs with same condition, but only the job `test` is skipped, the job `test-reusable` which is using a reusable workflow is executed. ## Workflow content ### `reusable.yaml` ```yaml "on": - workflow_call jobs: some-job: container: image: alpine defaults: run: shell: sh runs-on: docker steps: - run: printf 'Output from within a reusable workflow\n' ``` ### `test.yaml` ```yaml "on": - push jobs: test: container: image: alpine defaults: run: shell: sh if: 1 == 2 runs-on: docker steps: - run: printf 'This job should never be executed\n' test-reusable: if: 1 == 2 uses: ./.forgejo/workflows/reusable.yaml ``` ## Relevant log output ### For the job `test` ```sh runner(version:v3.3.0) received task 1030 of job 1091, be triggered by event: push workflow prepared evaluating expression '1 == 2' expression '1 == 2' evaluated to 'false' Skipping job 'test' due to '1 == 2' ``` ### For the job `test-reusable` ```sh runner(version:v3.3.0) received task 1031 of job 1092, be triggered by event: push workflow prepared evaluating expression '1 == 2' expression '1 == 2' evaluated to 'false' ☁ git clone 'http://server.forgejo_default:3000/EasyFoods/User-service' # ref=b34251e5a4d13d9ba05c3d149935c92119063eff cloning http://server.forgejo_default:3000/EasyFoods/User-service to /data/.cache/act/EasyFoods-User-service-.forgejo-workflows-reusable.yaml@b34251e5a4d13d9ba05c3d149935c92119063eff Cloned http://server.forgejo_default:3000/EasyFoods/User-service to /data/.cache/act/EasyFoods-User-service-.forgejo-workflows-reusable.yaml@b34251e5a4d13d9ba05c3d149935c92119063eff Checked out b34251e5a4d13d9ba05c3d149935c92119063eff evaluating expression 'success()' expression 'success()' evaluated to 'true' 🚀 Start image=alpine 🐳 docker pull image=alpine platform= username= forcePull=false 🐳 docker pull alpine Image exists? false pulling image 'docker.io/library/alpine' () Pulling from library/alpine :: latest Digest: sha256:c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761f8e1ad6b :: Status: Downloaded newer image for alpine:latest :: 🐳 docker create image=alpine platform= entrypoint=["/bin/sleep" "10800"] cmd=[] Common container.Config ==> &{Hostname: Domainname: User: AttachStdin:false AttachStdout:false AttachStderr:false ExposedPorts:map[] Tty:false OpenStdin:false StdinOnce:false Env:[RUNNER_TOOL_CACHE=/opt/hostedtoolcache RUNNER_OS=Linux RUNNER_ARCH=X64 RUNNER_TEMP=/tmp LANG=C.UTF-8] Cmd:[] Healthcheck:<nil> ArgsEscaped:false Image:alpine Volumes:map[] WorkingDir:/workspace/EasyFoods/User-service Entrypoint:[] NetworkDisabled:false MacAddress: OnBuild:[] Labels:map[] StopSignal: StopTimeout:<nil> Shell:[]} Common container.HostConfig ==> &{Binds:[/var/run/docker.sock:/var/run/docker.sock] ContainerIDFile: LogConfig:{Type: Config:map[]} NetworkMode:host PortBindings:map[] RestartPolicy:{Name: MaximumRetryCount:0} AutoRemove:true VolumeDriver: VolumesFrom:[] ConsoleSize:[0 0] Annotations:map[] CapAdd:[] CapDrop:[] CgroupnsMode: DNS:[] DNSOptions:[] DNSSearch:[] ExtraHosts:[] GroupAdd:[] IpcMode: Cgroup: Links:[] OomScoreAdj:0 PidMode: Privileged:false PublishAllPorts:false ReadonlyRootfs:false SecurityOpt:[] StorageOpt:map[] Tmpfs:map[] UTSMode: UsernsMode: ShmSize:0 Sysctls:map[] Runtime: Isolation: Resources:{CPUShares:0 Memory:0 NanoCPUs:0 CgroupParent: BlkioWeight:0 BlkioWeightDevice:[] BlkioDeviceReadBps:[] BlkioDeviceWriteBps:[] BlkioDeviceReadIOps:[] BlkioDeviceWriteIOps:[] CPUPeriod:0 CPUQuota:0 CPURealtimePeriod:0 CPURealtimeRuntime:0 CpusetCpus: CpusetMems: Devices:[] DeviceCgroupRules:[] DeviceRequests:[] KernelMemory:0 KernelMemoryTCP:0 MemoryReservation:0 MemorySwap:0 MemorySwappiness:<nil> OomKillDisable:<nil> PidsLimit:<nil> Ulimits:[] CPUCount:0 CPUPercent:0 IOMaximumIOps:0 IOMaximumBandwidth:0} Mounts:[{Type:volume Source:act-toolcache Target:/toolcache ReadOnly:false Consistency: BindOptions:<nil> VolumeOptions:<nil> TmpfsOptions:<nil> ClusterOptions:<nil>} {Type:volume Source:GITEA-ACTIONS-TASK-1031_WORKFLOW-reusable-yaml_JOB-some-job-env Target:/var/run/act ReadOnly:false Consistency: BindOptions:<nil> VolumeOptions:<nil> TmpfsOptions:<nil> ClusterOptions:<nil>} {Type:volume Source:GITEA-ACTIONS-TASK-1031_WORKFLOW-reusable-yaml_JOB-some-job Target:/workspace/EasyFoods/User-service ReadOnly:false Consistency: BindOptions:<nil> VolumeOptions:<nil> TmpfsOptions:<nil> ClusterOptions:<nil>}] MaskedPaths:[] ReadonlyPaths:[] Init:<nil>} Created container name=GITEA-ACTIONS-TASK-1031_WORKFLOW-reusable-yaml_JOB-some-job id=738a6ae2e7a16a507addb8d364f04e308902938fe62641ad8247f5aab8ee220a from image alpine (platform: ) ENV ==> [RUNNER_TOOL_CACHE=/opt/hostedtoolcache RUNNER_OS=Linux RUNNER_ARCH=X64 RUNNER_TEMP=/tmp LANG=C.UTF-8] 🐳 docker run image=alpine platform= entrypoint=["/bin/sleep" "10800"] cmd=[] Starting container: 738a6ae2e7a16a507addb8d364f04e308902938fe62641ad8247f5aab8ee220a Started container: 738a6ae2e7a16a507addb8d364f04e308902938fe62641ad8247f5aab8ee220a Writing entry to tarball workflow/event.json len:6249 Writing entry to tarball workflow/envs.txt len:0 Extracting content to '/var/run/act/' setupEnv => map[ACT:true ACTIONS_CACHE_URL:http://192.168.128.5:44421/ ACTIONS_RUNTIME_TOKEN:*** ACTIONS_RUNTIME_URL:http://server.forgejo_default:3000/api/actions_pipeline/ CI:true GITEA_ACTIONS:true GITEA_ACTIONS_RUNNER_VERSION:v3.3.0 GITHUB_ACTION:0 GITHUB_ACTIONS:true GITHUB_ACTION_PATH: GITHUB_ACTION_REF: GITHUB_ACTION_REPOSITORY: GITHUB_ACTOR:Name GITHUB_API_URL:http://server.forgejo_default:3000/api/v1 GITHUB_BASE_REF: GITHUB_EVENT_NAME:push GITHUB_EVENT_PATH:/var/run/act/workflow/event.json GITHUB_GRAPHQL_URL: GITHUB_HEAD_REF: GITHUB_JOB:some-job GITHUB_REF:refs/heads/Pull-request-preview-environment GITHUB_REF_NAME:Pull-request-preview-environment GITHUB_REF_TYPE:branch GITHUB_REPOSITORY:EasyFoods/User-service GITHUB_REPOSITORY_OWNER:EasyFoods GITHUB_RETENTION_DAYS: GITHUB_RUN_ID:517 GITHUB_RUN_NUMBER:274 GITHUB_SERVER_URL:http://server.forgejo_default:3000 GITHUB_SHA:b34251e5a4d13d9ba05c3d149935c92119063eff GITHUB_TOKEN:*** GITHUB_WORKFLOW:reusable.yaml GITHUB_WORKSPACE:/workspace/EasyFoods/User-service ImageOS:docker JOB_CONTAINER_NAME:GITEA-ACTIONS-TASK-1031_WORKFLOW-reusable-yaml_JOB-some-job RUNNER_PERFLOG:/dev/null RUNNER_TRACKING_ID:] evaluating expression '' expression '' evaluated to 'true' ⭐ Run Main printf 'Output from within a reusable workflow\n' Writing entry to tarball workflow/outputcmd.txt len:0 Writing entry to tarball workflow/statecmd.txt len:0 Writing entry to tarball workflow/pathcmd.txt len:0 Writing entry to tarball workflow/envs.txt len:0 Writing entry to tarball workflow/SUMMARY.md len:0 Extracting content to '/var/run/act' Wrote command \n\nprintf 'Output from within a reusable workflow\n'\n\n to 'workflow/0.sh' Writing entry to tarball workflow/0.sh len:51 Extracting content to '/var/run/act' 🐳 docker exec cmd=[sh -e /var/run/act/workflow/0.sh] user= workdir= Exec command '[sh -e /var/run/act/workflow/0.sh]' Working directory '/workspace/EasyFoods/User-service' Output from within a reusable workflow ✅ Success - Main printf 'Output from within a reusable workflow\n' Cleaning up services for job some-job Cleaning up container for job some-job Removed container: 738a6ae2e7a16a507addb8d364f04e308902938fe62641ad8247f5aab8ee220a 🐳 docker volume rm GITEA-ACTIONS-TASK-1031_WORKFLOW-reusable-yaml_JOB-some-job 🐳 docker volume rm GITEA-ACTIONS-TASK-1031_WORKFLOW-reusable-yaml_JOB-some-job-env 🏁 Job succeeded ``` ## Additional information Here is [the relevant issue](https://github.com/nektos/act/issues/2085) in the [nektos/act GitHub repository](https://github.com/nektos/act), which has been fixed with the commit [5547789](https://github.com/nektos/act/commit/55477899e70595ec8d8269387643ccca46fd6b38), and the fix was released with the version [0.2.54](https://github.com/nektos/act/releases/tag/v0.2.54). As a workaround I added an input `run` to the reusable workflow where it is used as a condition (`inputs.run == 'true'`) for all jobs.
Owner

It is unclear to me how reusable workflows are supported by the ACT at the moment. They are not yet supported by the Forgejo runner and it is unfortunate that they do not fail instead of trying to run. How did you run the workflow above?

It is unclear to me how reusable workflows are supported by the ACT at the moment. They are not yet supported by the Forgejo runner and it is unfortunate that they do not fail instead of trying to run. How did you run the workflow above?
Author

How did you run the workflow above?

This workflow was initially tested directly in repository's actions, but the same behaviour can be observed also with forgejo-runner exec.

> How did you run the workflow above? This workflow was initially tested directly in repository's actions, but the same behaviour can be observed also with `forgejo-runner exec`.
Sign in to join this conversation.
No labels
No milestone
No project
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/act#31
No description provided.