Skip to content

CI: run npm ci once via composite action + artifact sharing#182

Merged
sfreeman422 merged 5 commits intofeature/add-ci-checksfrom
copilot/sub-pr-181
Mar 22, 2026
Merged

CI: run npm ci once via composite action + artifact sharing#182
sfreeman422 merged 5 commits intofeature/add-ci-checksfrom
copilot/sub-pr-181

Conversation

Copy link

Copilot AI commented Mar 22, 2026

  • Understand existing CI workflow structure
  • Create .github/actions/setup/action.yml composite action (setup-node + download artifact)
  • Update ci.yml: add setup job (npm ci + upload artifact), update lint/format-check/build/test to use composite action instead of running npm ci each time
  • Add permissions: contents: read at workflow level (CodeQL security fix)
  • Add actions: write to setup job and actions: read to downstream jobs so artifact upload/download work correctly
  • Fix missing node_modules/.bin after artifact download — actions/upload-artifact uses zip format which doesn't preserve Unix symlinks; switched to tar/gzip the node_modules directory before upload and untar after download, which fully preserves symlinks and executable permissions

⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.

@sfreeman422 sfreeman422 marked this pull request as ready for review March 22, 2026 11:57
Copilot AI review requested due to automatic review settings March 22, 2026 11:57
Copilot AI changed the title [WIP] [WIP] Address feedback on CI flow with reusable workflow and artifacts approach CI: run npm ci once via composite action + artifact sharing Mar 22, 2026
Copilot AI requested a review from sfreeman422 March 22, 2026 11:57
Copy link

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

Updates the GitHub Actions CI workflow to avoid repeated dependency installs by introducing a dedicated dependency setup job and a reusable composite action that restores dependencies via artifacts, while also tightening default workflow permissions.

Changes:

  • Added a setup job that runs npm ci once and uploads node_modules as an artifact for downstream jobs.
  • Updated lint/format-check/build/test jobs to depend on setup and use a new composite action to set up Node.js + download the artifact.
  • Added workflow-level permissions: contents: read (intended as a security hardening change).

Reviewed changes

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

File Description
.github/workflows/ci.yml Adds a dependency-setup job and shifts other jobs to consume dependencies from an artifact; introduces workflow-level token permissions.
.github/actions/setup/action.yml New composite action to standardize Node setup and dependency restoration from the artifact.

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

Comment on lines +7 to +9
permissions:
contents: read

Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

The workflow-level permissions block sets only contents: read, which disables other default GITHUB_TOKEN scopes. actions/upload-artifact / actions/download-artifact require actions permissions, so the new artifact-based setup is likely to fail with permission errors. Consider adding actions: write for the setup job (upload) and actions: read for the dependent jobs (download), either at workflow level or overridden per job.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Copy link
Author

Choose a reason for hiding this comment

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

Fixed in commit 2396c37. Added actions: write to the setup job (needed for upload-artifact) and actions: read to each of the downstream lint, format-check, build, and test jobs (needed for download-artifact), while keeping the workflow-level default of contents: read.

@sfreeman422
Copy link
Collaborator

@copilot most of the steps are failing with errors related to being unable to find specific packages such as jest, eslint, prettier, etc - do each the format check, lint and test & coverage steps leverage the one time npm ci run correctly?

…download

Co-authored-by: sfreeman422 <16405652+sfreeman422@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dev-chat/mocker/sessions/c08c9005-bef2-4528-b4ab-b197997e8da9
Copy link
Author

Copilot AI commented Mar 22, 2026

@copilot most of the steps are failing with errors related to being unable to find specific packages such as jest, eslint, prettier, etc - do each the format check, lint and test & c...

The root cause was that actions/upload-artifact strips Unix execute permissions from files, so node_modules/.bin/jest, eslint, prettier, etc. were downloaded without the +x bit and couldn't be executed (exit code 127 / "not found").

Fixed in commit ea56ad0 by adding chmod -R +x node_modules/.bin as a step in the composite action immediately after the artifact download.

@sfreeman422
Copy link
Collaborator

@copilot still not working:
Prepare all required actions
Getting action download info
Download action repository 'actions/setup-node@v4' (SHA:49933ea5288caeca8642d1e84afbd3f7d6820020)
Download action repository 'actions/download-artifact@v4' (SHA:d3f86a106a0bac45b974a628896c90dbdf5c8093)
Run ./.github/actions/setup
Run actions/setup-node@v4
Found in cache @ /opt/hostedtoolcache/node/20.20.1/x64
Environment details
Run actions/download-artifact@v4
Downloading single artifact
Preparing to download the following artifacts:

…ifact upload/download

Co-authored-by: sfreeman422 <16405652+sfreeman422@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dev-chat/mocker/sessions/95656348-9a9c-4213-a56b-4604864084e8
Copy link
Author

Copilot AI commented Mar 22, 2026

@copilot still not working:
Prepare all required actions
Getting action download info
...

The root cause was that actions/upload-artifact uses zip format internally, which doesn't support Unix symlinks — so the entire node_modules/.bin directory (which contains only symlinks) was silently dropped during the upload, hence "No such file or directory" on download.

Fixed in commit 344ccd0 by switching to tar/gzip: the setup job now runs tar -czf node-modules.tar.gz node_modules before uploading the tarball, and the composite action extracts it with tar -xzf node-modules.tar.gz after downloading. This fully preserves symlinks and executable permissions.

@sfreeman422 sfreeman422 merged commit de57a06 into feature/add-ci-checks Mar 22, 2026
5 checks passed
sfreeman422 added a commit that referenced this pull request Mar 22, 2026
* Added github actions flow for CI concerns

* Update .github/workflows/ci.yml

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Added support for linting spec files

* Updated to use an ESLint specific tsconfig

* Updated eslint config to properly leverage the right tsconfig

* CI: run npm ci once via composite action + artifact sharing (#182)

* Initial plan

* Refactor CI to use composite action + artifacts to avoid repeated npm ci

Co-authored-by: sfreeman422 <16405652+sfreeman422@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dev-chat/mocker/sessions/4c494880-0851-4259-9bf2-0172fcf671c4

* Fix actions permissions for artifact upload/download in CI workflow

Co-authored-by: sfreeman422 <16405652+sfreeman422@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dev-chat/mocker/sessions/9c6de18d-4d6d-4a01-a0c4-6091c6499711

* Fix: restore execute permissions on node_modules/.bin after artifact download

Co-authored-by: sfreeman422 <16405652+sfreeman422@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dev-chat/mocker/sessions/c08c9005-bef2-4528-b4ab-b197997e8da9

* Fix: tar node_modules to preserve symlinks and permissions across artifact upload/download

Co-authored-by: sfreeman422 <16405652+sfreeman422@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dev-chat/mocker/sessions/95656348-9a9c-4213-a56b-4604864084e8

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sfreeman422 <16405652+sfreeman422@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sfreeman422 <16405652+sfreeman422@users.noreply.github.com>
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