-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix: Missing job-index and job-total attributes in strategy context
#5988
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
base: master
Are you sure you want to change the base?
fix: Missing job-index and job-total attributes in strategy context
#5988
Conversation
This commit adds missing job-index and job-total attributes to the strategy context to match GitHub Actions behavior. - Added MatrixIndex and MatrixCount fields to RunContext - Updated newRunContext to accept and store job index and total count - Added job-index and job-total to strategy context in expression evaluators Fixes nektos#5976 Signed-off-by: majiayu000 <1835304752@qq.com>
|
Thank you for taking a look, You missed updating composite action runcontext creation act/pkg/runner/action_composite.go Lines 47 to 82 in b2aee4b
We also need tests for both workflow and composite action, so we can ensure this will continue to work in the future. Tests can be workflows in pkg/runner/testdata//push.yml use "act -W /push.yml" in pkg/runner/testdata/ to run them manually. I can help adding entries to runner_test.go I would suggest to try writing test workflows yourself, without the help from AI tooling to learn more about act itself. |
This commit adds comprehensive tests for the job-index and job-total strategy context attributes and fixes a boundary condition: - Added MatrixIndex and MatrixCount to the test RunContext fixture - Created createRunContextWithoutMatrix helper for testing non-matrix jobs - Added TestStrategyContext to verify job-index and job-total values - Added TestStrategyContextInStep to verify values in step evaluator - Fixed boundary condition: job-index and job-total are now only set when there's an actual matrix (MatrixCount > 0) The fix ensures that when a job has a Strategy but no actual matrix combinations (MatrixCount == 0), the job-index and job-total properties are not set in the strategy context, matching GitHub Actions behavior. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This ensures strategy.job-index and strategy.job-total are accessible within composite actions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
@ChristopherHX Thanks for your review. Added the requested integration tests:
|
Summary
This PR fixes #5976
Changes
MatrixIndexandMatrixCountfields toRunContextstruct to track the current matrix job index (0-based) and total number of matrix jobsnewRunContextfunction signature to accept and initialize these new fieldsjob-indexandjob-totalattributes to the strategy context in bothNewExpressionEvaluatorWithEnvandnewStepExpressionEvaluatorfunctionsstrategy.job-indexandstrategy.job-totalexpressions in workflows, matching GitHub Actions behaviorThe implementation follows GitHub Actions specification where:
job-index: 0-based index of the current job in the matrix (e.g., 0, 1, 2, 3 for 4 jobs)job-total: Total number of jobs in the matrixGenerated with Claude Code