[PR #5988] fix: Missing job-index and job-total attributes in strategy context #2649

Open
opened 2026-03-01 22:37:35 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/nektos/act/pull/5988
Author: @majiayu000
Created: 12/30/2025
Status: 🔄 Open

Base: masterHead: fix-5976-missing-job-index-and-job-tota-1230-1417


📝 Commits (5)

  • 59ff473 Add job-index and job-total to strategy context
  • 323a155 Add tests for strategy.job-index and strategy.job-total
  • 724568f Pass Matrix, MatrixIndex and MatrixCount to composite action RunContext
  • 45cd029 test: cover strategy job index in workflows
  • 433d160 Merge branch 'master' into fix-5976-missing-job-index-and-job-tota-1230-1417

📊 Changes

9 files changed (+178 additions, -3 deletions)

View changed files

📝 pkg/runner/action_composite.go (+3 -0)
📝 pkg/runner/expression.go (+10 -0)
📝 pkg/runner/expression_test.go (+97 -0)
📝 pkg/runner/run_context.go (+2 -0)
📝 pkg/runner/runner.go (+5 -3)
📝 pkg/runner/runner_test.go (+2 -0)
pkg/runner/testdata/strategy-job-index-composite/composite_action/action.yml (+28 -0)
pkg/runner/testdata/strategy-job-index-composite/push.yml (+14 -0)
pkg/runner/testdata/strategy-job-index/push.yml (+17 -0)

📄 Description

Summary

This PR fixes #5976

Changes

  • Added MatrixIndex and MatrixCount fields to RunContext struct to track the current matrix job index (0-based) and total number of matrix jobs
  • Updated newRunContext function signature to accept and initialize these new fields
  • Added job-index and job-total attributes to the strategy context in both NewExpressionEvaluatorWithEnv and newStepExpressionEvaluator functions
  • These values are now accessible via strategy.job-index and strategy.job-total expressions in workflows, matching GitHub Actions behavior

The 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 matrix

Generated with Claude Code


🔄 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/5988 **Author:** [@majiayu000](https://github.com/majiayu000) **Created:** 12/30/2025 **Status:** 🔄 Open **Base:** `master` ← **Head:** `fix-5976-missing-job-index-and-job-tota-1230-1417` --- ### 📝 Commits (5) - [`59ff473`](https://github.com/nektos/act/commit/59ff473652f4a72fb721b22fbdbbe86965d2e14d) Add job-index and job-total to strategy context - [`323a155`](https://github.com/nektos/act/commit/323a155fdda4de71ccc05544284a2407e1fe2ff2) Add tests for strategy.job-index and strategy.job-total - [`724568f`](https://github.com/nektos/act/commit/724568fd9a88385225ee513173a6011fce5096e8) Pass Matrix, MatrixIndex and MatrixCount to composite action RunContext - [`45cd029`](https://github.com/nektos/act/commit/45cd029cbe9d44cf79ff41176ce7269a0d69e671) test: cover strategy job index in workflows - [`433d160`](https://github.com/nektos/act/commit/433d160601676ffdc3adc22ab60767f2a737ec16) Merge branch 'master' into fix-5976-missing-job-index-and-job-tota-1230-1417 ### 📊 Changes **9 files changed** (+178 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `pkg/runner/action_composite.go` (+3 -0) 📝 `pkg/runner/expression.go` (+10 -0) 📝 `pkg/runner/expression_test.go` (+97 -0) 📝 `pkg/runner/run_context.go` (+2 -0) 📝 `pkg/runner/runner.go` (+5 -3) 📝 `pkg/runner/runner_test.go` (+2 -0) ➕ `pkg/runner/testdata/strategy-job-index-composite/composite_action/action.yml` (+28 -0) ➕ `pkg/runner/testdata/strategy-job-index-composite/push.yml` (+14 -0) ➕ `pkg/runner/testdata/strategy-job-index/push.yml` (+17 -0) </details> ### 📄 Description ## Summary This PR fixes #5976 ## Changes - Added `MatrixIndex` and `MatrixCount` fields to `RunContext` struct to track the current matrix job index (0-based) and total number of matrix jobs - Updated `newRunContext` function signature to accept and initialize these new fields - Added `job-index` and `job-total` attributes to the strategy context in both `NewExpressionEvaluatorWithEnv` and `newStepExpressionEvaluator` functions - These values are now accessible via `strategy.job-index` and `strategy.job-total` expressions in workflows, matching GitHub Actions behavior The 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 matrix --- Generated with Claude Code --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#2649
No description provided.