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

Fix for issue 2232: Many lines of "Could not find any stages to run" on run #2272

Merged
merged 12 commits into from
May 13, 2024

Conversation

Andy4495
Copy link
Contributor

@Andy4495 Andy4495 commented Apr 4, 2024

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 fix: fail if no stages were found #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

@Andy4495 Andy4495 requested a review from a team as a code owner April 4, 2024 16:52
Copy link
Contributor

mergify bot commented Apr 4, 2024

@Andy4495 this pull request has failed checks 🛠

@mergify mergify bot added the needs-work Extra attention is needed label Apr 4, 2024
@Andy4495
Copy link
Contributor Author

Andy4495 commented Apr 4, 2024

This also fixes #1993, which is the same issue as #2232.

For reference, the issue was introduced in act version v0.2.50

Copy link

codecov bot commented Apr 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.49%. Comparing base (5a80a04) to head (a02f1f7).
Report is 67 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #2272       +/-   ##
===========================================
+ Coverage   61.56%   76.49%   +14.92%     
===========================================
  Files          53       59        +6     
  Lines        9002     7504     -1498     
===========================================
+ Hits         5542     5740      +198     
+ Misses       3020     1241     -1779     
- Partials      440      523       +83     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

mergify bot commented Apr 10, 2024

@Andy4495 this pull request has failed checks 🛠

Copy link
Contributor

mergify bot commented Apr 18, 2024

@Andy4495 this pull request has failed checks 🛠

@pull-request-size pull-request-size bot added size/S and removed size/M labels Apr 18, 2024
Copy link
Contributor

mergify bot commented Apr 18, 2024

@Andy4495 this pull request has failed checks 🛠

Copy link
Contributor

mergify bot commented Apr 18, 2024

@Andy4495 this pull request has failed checks 🛠

@mergify mergify bot removed the needs-work Extra attention is needed label Apr 18, 2024
@Andy4495
Copy link
Contributor Author

After investigating the failed test cases in the codecov report, I realized that the following check in createStages() is never true:

	if len(stages) == 0 && err != nil {
 		return nil, err
 	}

since err is always nil (it is never given a value after it is declared).

This check was added as part of pull request #1619 (issue #1595), released in version 0.2.43.

I therefore removed the check and updated the test case.

@jedahan
Copy link

jedahan commented May 7, 2024

So is it currently safe to ignore these warnings? Just want to make sure I am using act correctly.

@Andy4495
Copy link
Contributor Author

Andy4495 commented May 7, 2024

So is it currently safe to ignore these warnings? Just want to make sure I am using act correctly.

Yes, the currently released code has the check in the wrong place, so the "Could not find any stages to run" warning is displayed even when there are jobs to run.

@mergify mergify bot merged commit 657a3d7 into nektos:master May 13, 2024
11 checks passed
@Andy4495 Andy4495 deleted the fix_for_issue_2232 branch May 14, 2024 15:08
qlonik added a commit to qlonik/musical-parakeet that referenced this pull request Jun 10, 2024
Since the recent release of act, it now fails when there are no workflow files
to execute. In particular because of this PR:
nektos/act#2272. With this fix, we now only run act
when the workflow files were generated by actionsflow.
qlonik added a commit to qlonik/musical-parakeet that referenced this pull request Jun 10, 2024
Since the recent release of act, it now fails when there are no workflow files
to execute. In particular because of this PR:
nektos/act#2272. With this fix, we now only run act
when the workflow files were generated by actionsflow.
qlonik added a commit to qlonik/musical-parakeet that referenced this pull request Jun 10, 2024
Since the recent release of act, it now fails when there are no workflow files
to execute. In particular because of this PR:
nektos/act#2272. With this fix, we now only run act
when the workflow files were generated by actionsflow.
qlonik added a commit to qlonik/musical-parakeet that referenced this pull request Jun 10, 2024
Since the recent release of act, it now fails when there are no workflow files
to execute. In particular because of this PR:
nektos/act#2272. With this fix, we now only run act
when the workflow files were generated by actionsflow.
qlonik added a commit to qlonik/musical-parakeet that referenced this pull request Jun 10, 2024
Since the recent release of act, it now fails when there are no workflow files
to execute. In particular because of this PR:
nektos/act#2272. With this fix, we now only run act
when the workflow files were generated by actionsflow.
qlonik added a commit to qlonik/musical-parakeet that referenced this pull request Jun 10, 2024
Since the recent release of act, it now fails when there are no workflow files
to execute. In particular because of this PR:
nektos/act#2272. With this fix, we now only run act
when the workflow files were generated by actionsflow.
qlonik added a commit to qlonik/musical-parakeet that referenced this pull request Jun 10, 2024
Since the recent release of act, it now fails when there are no workflow files
to execute. In particular because of this PR:
nektos/act#2272. With this fix, we now only run act
when the workflow files were generated by actionsflow.
qlonik added a commit to qlonik/musical-parakeet that referenced this pull request Jun 10, 2024
Since the recent release of act, it now fails when there are no workflow files
to execute. In particular because of this PR:
nektos/act#2272. With this fix, we now only run act
when the workflow files were generated by actionsflow.
qlonik added a commit to qlonik/musical-parakeet that referenced this pull request Jun 10, 2024
Since the recent release of act, it now fails when there are no workflow files
to execute. In particular because of this PR:
nektos/act#2272. With this fix, we now only run act
when the workflow files were generated by actionsflow.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants