Skip to content

BUILD-11553: Avoid workspace pollution in CI actions#287

Merged
matemoln merged 1 commit into
masterfrom
mate/BUILD-11553-runnerTempBuildNumber
Jun 9, 2026
Merged

BUILD-11553: Avoid workspace pollution in CI actions#287
matemoln merged 1 commit into
masterfrom
mate/BUILD-11553-runnerTempBuildNumber

Conversation

@matemoln

@matemoln matemoln commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Keep the GitHub workspace checkout clean by moving ephemeral CI state out of the repository tree. This prevents downstream steps (e.g. Docker image tagging in gitar) from behaving differently when the working tree is polluted with untracked files or directories.

  • get-build-number: write build_number.txt to ${RUNNER_TEMP} instead of the workspace; update cache paths and shell specs accordingly
  • config-npm / build-npm / build-yarn: use jf npm-config --global so .jfrog/projects/ is created under the runner home, not the workspace
  • config-npm / build-npm / build-yarn: remove transient .actions/ symlinks after local composite action references are consumed (only symlinks created by the action; rmdir if empty)

Why

Blocks gitar/actions/runs/27045793684: image tagging logic behaves differently when the workspace is clean vs polluted.

Test plan

Copilot AI review requested due to automatic review settings June 5, 2026 23:13
@matemoln matemoln requested a review from a team as a code owner June 5, 2026 23:13
@hashicorp-vault-sonar-prod

hashicorp-vault-sonar-prod Bot commented Jun 5, 2026

Copy link
Copy Markdown

BUILD-11553

Copilot AI left a comment

Copy link
Copy Markdown

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 updates the get-build-number composite action and its ShellSpec tests to store the cached build_number.txt under RUNNER_TEMP (instead of the workspace checkout), preventing ephemeral cache state from modifying the repository tree during workflow runs.

Changes:

  • Update the action to write/read the build number file via a BUILD_NUMBER_FILE path pointing to ${RUNNER_TEMP}/build_number.txt.
  • Update the underlying get_build_number.sh script to use BUILD_NUMBER_FILE / RUNNER_TEMP for its cache file location.
  • Adjust ShellSpec tests to set RUNNER_TEMP and assert the cache file is created in the temp directory.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
spec/get_build_number_spec.sh Sets RUNNER_TEMP in tests and updates assertions to expect the cache file in temp.
get-build-number/get_build_number.sh Uses BUILD_NUMBER_FILE / RUNNER_TEMP to determine where to write the cache file.
get-build-number/action.yml Exports BUILD_NUMBER_FILE into the composite action environment and updates cache/read/write steps to use it.

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

Comment thread get-build-number/get_build_number.sh
@matemoln matemoln changed the title BUILD-11553 Use RUNNER_TEMP for get-build-number cache file BUILD-11553: Avoid workspace pollution in CI actions Jun 8, 2026
@matemoln matemoln force-pushed the mate/BUILD-11553-runnerTempBuildNumber branch from 8230a09 to 387d67f Compare June 8, 2026 23:12
@matemoln matemoln force-pushed the mate/BUILD-11553-runnerTempBuildNumber branch from 387d67f to d0c01f6 Compare June 8, 2026 23:14

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks as good improvement.
However, the motivation for it is unclear: "working tree is polluted with untracked files or directories". There are many other files and directories created by the build. If they are breaking Gitar tagging behavior, then the fix should live in Gitar with running a git clean.

Keep the GitHub workspace checkout clean so downstream steps (e.g. Docker
image tagging in gitar) behave consistently regardless of whether CI
actions have run.

- get-build-number: write build_number.txt to ${RUNNER_TEMP} instead of
  the workspace; update cache paths, get_build_number.sh, and specs
- config-npm, build-npm, build-yarn: use jf npm-config --global so
  .jfrog/projects/ is stored under the runner home, not the workspace
- config-npm, build-npm, build-yarn: remove transient .actions/ symlinks
  after local composite action references are consumed
@matemoln matemoln force-pushed the mate/BUILD-11553-runnerTempBuildNumber branch from d0c01f6 to fcb20bf Compare June 9, 2026 18:09
@sonarqubecloud

sonarqubecloud Bot commented Jun 9, 2026

Copy link
Copy Markdown

@matemoln

matemoln commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

This looks as good improvement. However, the motivation for it is unclear: "working tree is polluted with untracked files or directories". There are many other files and directories created by the build. If they are breaking Gitar tagging behavior, then the fix should live in Gitar with running a git clean.

There are many other files and directories created by the build, but that is expected and they have entries in the .gitignore for those. I agree that the tagging behaviour is a bit too strict, I'll check if git clean is needed.

@matemoln matemoln merged commit 1ea2cea into master Jun 9, 2026
17 checks passed
@matemoln matemoln deleted the mate/BUILD-11553-runnerTempBuildNumber branch June 9, 2026 22:38
@gitar-bot

gitar-bot Bot commented Jun 9, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Moves ephemeral CI state for NPM, Yarn, and build number generation to runner-specific directories to prevent workspace pollution. No issues found.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

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