Skip to content

Module cache in code-analysis blocks SHA pinning enforcement #3036

Description

@nohwnd

GitHub's "Require actions to be pinned to a full-length commit SHA" (Settings > Actions > General) applies to actions referenced inside composite actions, not only to the ones in our own workflows. potatoqualitee/psmodulecache is a composite action and does not pin its own actions/cache reference:

psmodulecache nested reference
v6.2.1 (what we use) actions/cache@v4.2.0
v6.3 (latest) actions/cache@v5.0.5

With the policy on, code-analysis.yml fails at Set up job before running anything:

Error: The action actions/cache@v4.2.0 is not allowed in pester/Pester because all
actions must be pinned to a full-length commit SHA.

PSScriptAnalyzer is a required check, so that blocks every merge. The policy is off again, so nothing is broken right now.

Bumping to v6.3 does not help, it just moves to a different unpinned reference. I sent potatoqualitee/psmodulecache#68 upstream to pin it, but even if that merges we stay coupled to their internal pinning from one release to the next.

psmodulecache is the only action we use with unpinned nested references. checkout, setup-dotnet, upload-artifact, download-artifact, codecov-action and codeql-action are all clean, and main, rel/4.x.x, rel/5.x.x and rel/6.0.x are fully pinned.

Timing, for what it is worth

  • CI, the 8-leg matrix: 638-743 s
  • Code analysis: 65-92 s
  • Installing PSScriptAnalyzer and ConvertToSARIF straight from PSGallery: 21 s, measured

The two workflows run in parallel, so code analysis finishes well before CI either way.

Options

  1. Keep psmodulecache and leave the policy off. Nothing to do.
  2. Keep psmodulecache, turn the policy on once upstream pins and we bump. Breaks again if a later release un-pins.
  3. Cache with actions/cache pinned directly in our own workflow. Keeps the caching, drops the composite action, roughly six lines.
  4. Install the two modules directly, no cache.

@fflaten

You added the module cache and I do not want to remove something without understanding what it was for. Was it build time, or was it PSGallery being slow or rate limited? If it is about reliability rather than speed then options 3 and 4 are not equivalent, and I would rather keep the cache and solve the pinning differently.

🤖

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions