Skip to content

Remove hardcoded action pins lists from tests#3922

Merged
pelikhan merged 3 commits into
mainfrom
copilot/remove-builtin-action-pins
Nov 14, 2025
Merged

Remove hardcoded action pins lists from tests#3922
pelikhan merged 3 commits into
mainfrom
copilot/remove-builtin-action-pins

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 14, 2025

Tests contained hardcoded lists of action names that duplicated data already in action_pins.json, creating maintenance burden and incomplete coverage (14 of 18 actions tested).

Changes

Modified pkg/workflow/action_pins_test.go:

  • TestActionPinsExist: Removed hardcoded 14-action array, now iterates over all actions from getActionPins()
  • TestGetActionPinReturnsValidSHA: Removed hardcoded test table, dynamically generates test cases from getActionPins()

Before:

expectedActions := []string{
    "actions/checkout",
    "actions/github-script",
    // ... 12 more hardcoded entries
}
for _, action := range expectedActions {
    // test logic
}

After:

actionPins := getActionPins()  // Reads from action_pins.json
for _, pin := range actionPins {
    // test logic using pin.Repo
}

Impact

  • Tests now cover all 18 actions in JSON (previously 14)
  • Future JSON updates automatically reflected in tests
  • Net -31 lines of code
Original prompt

Remove builtin action pins list and instead read the information from the actions_pins.json exclusively.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Read action pins exclusively from action_pins.json instead of maintaining duplicate hardcoded lists in test files. This ensures:
- Tests automatically cover all actions defined in JSON
- No need to manually sync test lists when JSON changes
- Single source of truth for action pins data

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove builtin action pins list and read from actions_pins.json Remove hardcoded action pins lists from tests Nov 14, 2025
Copilot AI requested a review from pelikhan November 14, 2025 05:00
@pelikhan pelikhan marked this pull request as ready for review November 14, 2025 05:03
Copilot AI review requested due to automatic review settings November 14, 2025 05:03
@pelikhan pelikhan merged commit ccf9e16 into main Nov 14, 2025
13 checks passed
@pelikhan pelikhan deleted the copilot/remove-builtin-action-pins branch November 14, 2025 05:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR eliminates code duplication by removing hardcoded action lists from test files in favor of dynamically reading from the centralized action_pins.json file. The change improves maintainability by ensuring tests automatically cover all actions defined in the JSON configuration without requiring manual updates to test code.

Key changes:

  • Replaced hardcoded 14-action test arrays with dynamic iteration over all actions from getActionPins()
  • Tests now automatically cover all 18 actions in the JSON file (previously only 14)
  • Added defensive checks to ensure action pins are successfully loaded before running tests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants