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

Add required actions rule (and supporting tests) to enforce usage of specific GitHub Actions in workflows #474

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chrisreddington
Copy link

This PR implements issue #469 that I raised a few days ago. It introduces a new linting rule to ensure specific GitHub Actions are present in workflows, along with corresponding tests. Changes include updating the configuration structure, adding the new rule to the linter, implementing the rule, and creating tests for it.

Configuration Changes:

  • Added RequiredActions field to the Config struct in config.go to specify mandatory GitHub Actions in workflows.

Linter Rule Implementation:

  • Updated linter.go to include the new rule RuleRequiredActions if RequiredActions are specified in the configuration.
  • Created rule_required_actions.go to define the RequiredActionRule struct and implement the RuleRequiredActions class, which checks for the presence and correct version of required GitHub Actions in workflows.
    • If the Action is present, then it checks for any version of the Action.
    • If the Action is present as well as a specific version, then it checks for a specific version of the Action.

Testing:

  • Added rule_required_actions_test.go to test the functionality of RuleRequiredActions and the parseActionRef function. This includes various test cases to ensure the rule works correctly under different scenarios.

@rhysd rhysd force-pushed the main branch 2 times, most recently from 05e056b to 5aaa4ce Compare November 12, 2024 16:13
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.

1 participant