Skip to content

Conversation

@abretonc7s
Copy link
Collaborator

@abretonc7s abretonc7s commented Feb 5, 2025

Description

Context

This PR updates our GitHub Actions workflows to use artifacts instead of caching for better control over build outputs. The changes affect the lint-build-test.yml and publish-release.yml workflows.

Changes

  • Removed cache: yarn configurations from all Node.js setup steps in lint-build-test.yml
  • Updated publish-release.yml workflow to:
    • Replace caching mechanism with GitHub Artifacts for build outputs
    • Upgrade GitHub Actions to newer versions (checkout@v4, setup-node@v4)
    • Remove the npm publish dry-run step for a more streamlined release process
    • Implement proper artifact handling between jobs using upload-artifact@v4 and download-artifact@v4

Implementation Details

This change replaces the GitHub Actions caching mechanism with artifacts for managing build outputs between jobs. This provides more explicit control over how build artifacts are handled and transferred throughout the workflow.

Performance Considerations

Build times may slightly increase without caching, but the artifact implementation ensures efficient transfer of build outputs between jobs. We can monitor and optimize if needed.

Breaking Changes

None. This is an internal workflow change that doesn't affect the published packages or their consumers.

Testing Instructions

  1. Create a test release to verify the complete workflow
  2. Monitor build times to assess performance impact
  3. Verify that build artifacts are properly transferred between the release and publish jobs

Related Issues

#3925 - Remove usage of GitHub action caching from critical workflows

Updated the publish-release GitHub Actions workflow to use newer versions of actions and removed the dry-run step for npm publish.
@abretonc7s abretonc7s requested a review from a team as a code owner February 5, 2025 12:18
chakra-guy
chakra-guy previously approved these changes Feb 5, 2025
Copy link
Collaborator

@chakra-guy chakra-guy left a comment

Choose a reason for hiding this comment

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

LGTM

@paulmillr
Copy link

I don't understand this.

If files are cached, surely their checksumms are verified after downloading. If so it doesn't matter if it's cached or not, so it can be cached for perf reasons. No?

@codecov
Copy link

codecov bot commented Feb 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.05%. Comparing base (62331c6) to head (7b07fc8).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1209   +/-   ##
=======================================
  Coverage   74.05%   74.05%           
=======================================
  Files         182      182           
  Lines        4351     4351           
  Branches     1066     1066           
=======================================
  Hits         3222     3222           
  Misses       1129     1129           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sonarqubecloud
Copy link

@abretonc7s abretonc7s merged commit 89b057e into main Feb 12, 2025
37 checks passed
@abretonc7s abretonc7s deleted the removecache branch February 12, 2025 09:49
@NicholasEllul
Copy link
Contributor

@paulmillr behind the scenes setup-node is using GitHub's action cache to perform the caching/restoration of dependencies.

When a cache is to be restored, it is downloaded into a temp directory, and then extracted. This extraction happens relative to the GITHUB_WORKSPACE directory (generally the repository's root), and will override any existing files that have the same path.

This means that if someone were to poison the cache to include a malicious package.json, yarn.lock, or any other file that is known to exist, it would overwrite the legitimate copy with the poisoned one upon extraction (in addition to restoring dependencies as expected).

@paulmillr
Copy link

@NicholasEllul that sounds idiotic and is a real security issue. Why does GitHub allow it?

@NicholasEllul
Copy link
Contributor

@paulmillr Originally when a security researcher had reported the issue to them, GitHub had dismissed it (Blog post). However, the issue has since been seen exploited in the wild, and people have started to create more noise around it. Per their comment, it sounds like they are exploring how this can be improved. Until then, we do not consider it safe to use action cache in publishing workflows.

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.

5 participants