[PR #2272] [MERGED] Fix for issue 2232: Many lines of "Could not find any stages to run" on run #2362

Closed
opened 2026-03-01 21:55:07 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/nektos/act/pull/2272
Author: @Andy4495
Created: 4/4/2024
Status: Merged
Merged: 5/13/2024
Merged by: @mergify[bot]

Base: masterHead: fix_for_issue_2232


📝 Commits (10+)

  • ee5da82 Initial commit
  • 81057bb Merge branch 'master' into fix_for_issue_2232
  • 1524929 Merge branch 'nektos:master' into fix_for_issue_2232
  • a1ff36a Put the tests back
  • 9d7cdd8 Remove unnecessary checks
  • ac4c99c Remove unneeded check and fix test code
  • 70ba451 Merge branch 'master' into fix_for_issue_2232
  • cefb9c9 Merge branch 'master' into fix_for_issue_2232
  • e2a2b26 Merge branch 'master' into fix_for_issue_2232
  • 1e3e842 Merge branch 'master' into fix_for_issue_2232

📊 Changes

3 files changed (+7 additions, -11 deletions)

View changed files

📝 cmd/root.go (+5 -0)
📝 pkg/model/planner.go (+0 -4)
📝 pkg/model/planner_test.go (+2 -7)

📄 Description

Fixes #2232: Many lines of "Could not find any stages to run" on run
Fixes #1993: Unexpected failure due to warning "Could not find any stages to run"

Issues #2232 and #1993 were introduced with pull request #1970.

The Problem

#1970 prints a lot of messages even when there isn’t a problem, since the check is called twice for each workflow file in the workflows directory:

WARN[0000] Could not find any stages to run. View the valid jobs with `act --list`. Use `act --help` to find how to filter by Job ID/Workflow/Event Name

In addition, it prints an error message at the end of the run, even if the job was run successfully:

Error: Could not find any stages to run. View the valid jobs with `act --list`. Use `act --help` to find how to filter by Job ID/Workflow/Event Name

This also has the side effect of causing act to return an error code (1), even if the run was successful:

> act -j the-test
INFO[0000] Using docker host 'unix:///var/run/docker.sock', and daemon socket 'unix:///var/run/docker.sock' 
WARN[0000] Could not find any stages to run. View the valid jobs with `act --list`. Use `act --help` to find how to filter by Job ID/Workflow/Event Name 
WARN[0000] Could not find any stages to run. View the valid jobs with `act --list`. Use `act --help` to find how to filter by Job ID/Workflow/Event Name 
WARN[0000] Could not find any stages to run. View the valid jobs with `act --list`. Use `act --help` to find how to filter by Job ID/Workflow/Event Name 
WARN[0000] Could not find any stages to run. View the valid jobs with `act --list`. Use `act --help` to find how to filter by Job ID/Workflow/Event Name 
WARN[0000] Could not find any stages to run. View the valid jobs with `act --list`. Use `act --help` to find how to filter by Job ID/Workflow/Event Name 
WARN[0000] Could not find any stages to run. View the valid jobs with `act --list`. Use `act --help` to find how to filter by Job ID/Workflow/Event Name 
WARN[0000] Could not find any stages to run. View the valid jobs with `act --list`. Use `act --help` to find how to filter by Job ID/Workflow/Event Name 
WARN[0000] Could not find any stages to run. View the valid jobs with `act --list`. Use `act --help` to find how to filter by Job ID/Workflow/Event Name 
. . . job run output deleted for brevity . . . 
[Test-Workflow/the-test] 🏁  Job succeeded
Error: Could not find any stages to run. View the valid jobs with `act --list`. Use `act --help` to find how to filter by Job ID/Workflow/Event Name
[1] > echo $?                                                                                                 
1

The Fix

This pull request fixes these issues by making the following changes:

  1. Revert the changes made by pull request #1970
  2. Add the "no stages to run" check and error message to the file root.go

This solves both problems mentioned above:

  1. The error message is only printed once, and only if there truly are no stages/jobs to run.
  2. act returns success (0) if the run was successful, and failure (1) if there were no stages to run

With this fix, the output is as follows. Note the error code returned in both cases:

Normal run, including return code of 0:

> act-test -j the-test
INFO[0000] Using docker host 'unix:///var/run/docker.sock', and daemon socket 'unix:///var/run/docker.sock' 
[Test-Workflow/the-test] 🚀  Start image=ghcr.io/catthehacker/ubuntu:act-latest
[Test-Workflow/the-test]   🐳  docker pull image=ghcr.io/catthehacker/ubuntu:act-latest platform= username= forcePull=true
[Test-Workflow/the-test]   🐳  docker create image=ghcr.io/catthehacker/ubuntu:act-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
[Test-Workflow/the-test]   🐳  docker run image=ghcr.io/catthehacker/ubuntu:act-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
[Test-Workflow/the-test] ⭐ Run Main actions/checkout@v4
[Test-Workflow/the-test]   🐳  docker cp src=/Users/test/Documents/act-error-test/act/. dst=/Users/test/Documents/act-error-test/act
[Test-Workflow/the-test]   ✅  Success - Main actions/checkout@v4
[Test-Workflow/the-test] ⭐ Run Main echo "Test-workflow run."
[Test-Workflow/the-test]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/1] user= workdir=
| Test-workflow run.
[Test-Workflow/the-test]   ✅  Success - Main echo "Test-workflow run."
[Test-Workflow/the-test] Cleaning up container for job the-test
[Test-Workflow/the-test] 🏁  Job succeeded
> echo $?
0

Failed run because no valid jobs were found, including return code of 1:

> act-test -j gibberish                                                                                                                        ~/Documents/act-error-test/act
INFO[0000] Using docker host 'unix:///var/run/docker.sock', and daemon socket 'unix:///var/run/docker.sock' 
Error: Could not find any stages to run. View the valid jobs with `act --list`. Use `act --help` to find how to filter by Job ID/Workflow/Event Name
[1] > echo $?
1

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/nektos/act/pull/2272 **Author:** [@Andy4495](https://github.com/Andy4495) **Created:** 4/4/2024 **Status:** ✅ Merged **Merged:** 5/13/2024 **Merged by:** [@mergify[bot]](https://github.com/apps/mergify) **Base:** `master` ← **Head:** `fix_for_issue_2232` --- ### 📝 Commits (10+) - [`ee5da82`](https://github.com/nektos/act/commit/ee5da82775d25d873c7bd11e7839b21e328d8154) Initial commit - [`81057bb`](https://github.com/nektos/act/commit/81057bb8c6059c864426884c49a205729c1ace8f) Merge branch 'master' into fix_for_issue_2232 - [`1524929`](https://github.com/nektos/act/commit/152492958cb801ee09386bbbdef11dd53ebae081) Merge branch 'nektos:master' into fix_for_issue_2232 - [`a1ff36a`](https://github.com/nektos/act/commit/a1ff36a67f52c9f23febcfe416081a8f1c4b6808) Put the tests back - [`9d7cdd8`](https://github.com/nektos/act/commit/9d7cdd8420f7629e7ad6970cd8fab804b668aa5e) Remove unnecessary checks - [`ac4c99c`](https://github.com/nektos/act/commit/ac4c99c927baa0f5e88698d0e7a131131df2b179) Remove unneeded check and fix test code - [`70ba451`](https://github.com/nektos/act/commit/70ba451f91d562393e8d71614172319af1ea7198) Merge branch 'master' into fix_for_issue_2232 - [`cefb9c9`](https://github.com/nektos/act/commit/cefb9c902a010e5965bd73fce116268eb31675f2) Merge branch 'master' into fix_for_issue_2232 - [`e2a2b26`](https://github.com/nektos/act/commit/e2a2b265bbecbf8a873089126ca3f1a82afe68aa) Merge branch 'master' into fix_for_issue_2232 - [`1e3e842`](https://github.com/nektos/act/commit/1e3e842bf21612a9bd3069c5c48309c4b1cce7c4) Merge branch 'master' into fix_for_issue_2232 ### 📊 Changes **3 files changed** (+7 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `cmd/root.go` (+5 -0) 📝 `pkg/model/planner.go` (+0 -4) 📝 `pkg/model/planner_test.go` (+2 -7) </details> ### 📄 Description Fixes #2232: Many lines of "Could not find any stages to run" on run Fixes #1993: Unexpected failure due to warning "Could not find any stages to run" Issues #2232 and #1993 were introduced with pull request #1970. ## The Problem #1970 prints a lot of messages even when there isn’t a problem, since the check is called twice for each workflow file in the workflows directory: ```text WARN[0000] Could not find any stages to run. View the valid jobs with `act --list`. Use `act --help` to find how to filter by Job ID/Workflow/Event Name ``` In addition, it prints an error message at the end of the run, even if the job was run successfully: ```text Error: Could not find any stages to run. View the valid jobs with `act --list`. Use `act --help` to find how to filter by Job ID/Workflow/Event Name ``` This also has the side effect of causing act to return an error code (1), even if the run was successful: ```shell > act -j the-test INFO[0000] Using docker host 'unix:///var/run/docker.sock', and daemon socket 'unix:///var/run/docker.sock' WARN[0000] Could not find any stages to run. View the valid jobs with `act --list`. Use `act --help` to find how to filter by Job ID/Workflow/Event Name WARN[0000] Could not find any stages to run. View the valid jobs with `act --list`. Use `act --help` to find how to filter by Job ID/Workflow/Event Name WARN[0000] Could not find any stages to run. View the valid jobs with `act --list`. Use `act --help` to find how to filter by Job ID/Workflow/Event Name WARN[0000] Could not find any stages to run. View the valid jobs with `act --list`. Use `act --help` to find how to filter by Job ID/Workflow/Event Name WARN[0000] Could not find any stages to run. View the valid jobs with `act --list`. Use `act --help` to find how to filter by Job ID/Workflow/Event Name WARN[0000] Could not find any stages to run. View the valid jobs with `act --list`. Use `act --help` to find how to filter by Job ID/Workflow/Event Name WARN[0000] Could not find any stages to run. View the valid jobs with `act --list`. Use `act --help` to find how to filter by Job ID/Workflow/Event Name WARN[0000] Could not find any stages to run. View the valid jobs with `act --list`. Use `act --help` to find how to filter by Job ID/Workflow/Event Name . . . job run output deleted for brevity . . . [Test-Workflow/the-test] 🏁 Job succeeded Error: Could not find any stages to run. View the valid jobs with `act --list`. Use `act --help` to find how to filter by Job ID/Workflow/Event Name [1] > echo $? 1 ``` ## The Fix This pull request fixes these issues by making the following changes: 1. Revert the changes made by pull request #1970 2. Add the "no stages to run" check and error message to the file `root.go` This solves both problems mentioned above: 1. The error message is only printed once, and only if there truly are no stages/jobs to run. 2. act returns success (0) if the run was successful, and failure (1) if there were no stages to run With this fix, the output is as follows. Note the error code returned in both cases: Normal run, including return code of 0: ```shell > act-test -j the-test INFO[0000] Using docker host 'unix:///var/run/docker.sock', and daemon socket 'unix:///var/run/docker.sock' [Test-Workflow/the-test] 🚀 Start image=ghcr.io/catthehacker/ubuntu:act-latest [Test-Workflow/the-test] 🐳 docker pull image=ghcr.io/catthehacker/ubuntu:act-latest platform= username= forcePull=true [Test-Workflow/the-test] 🐳 docker create image=ghcr.io/catthehacker/ubuntu:act-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host" [Test-Workflow/the-test] 🐳 docker run image=ghcr.io/catthehacker/ubuntu:act-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host" [Test-Workflow/the-test] ⭐ Run Main actions/checkout@v4 [Test-Workflow/the-test] 🐳 docker cp src=/Users/test/Documents/act-error-test/act/. dst=/Users/test/Documents/act-error-test/act [Test-Workflow/the-test] ✅ Success - Main actions/checkout@v4 [Test-Workflow/the-test] ⭐ Run Main echo "Test-workflow run." [Test-Workflow/the-test] 🐳 docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/1] user= workdir= | Test-workflow run. [Test-Workflow/the-test] ✅ Success - Main echo "Test-workflow run." [Test-Workflow/the-test] Cleaning up container for job the-test [Test-Workflow/the-test] 🏁 Job succeeded > echo $? 0 ``` Failed run because no valid jobs were found, including return code of 1: ```shell > act-test -j gibberish ~/Documents/act-error-test/act INFO[0000] Using docker host 'unix:///var/run/docker.sock', and daemon socket 'unix:///var/run/docker.sock' Error: Could not find any stages to run. View the valid jobs with `act --list`. Use `act --help` to find how to filter by Job ID/Workflow/Event Name [1] > echo $? 1 ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-01 21:55:07 +03:00
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#2362
No description provided.