Skip to content

CI: activate Yarn 4 via Corepack in CI and release workflows - #42

Merged
dcapslock merged 3 commits into
masterfrom
copilot/update-ci-workflow-yarn-version
Jun 5, 2026
Merged

CI: activate Yarn 4 via Corepack in CI and release workflows#42
dcapslock merged 3 commits into
masterfrom
copilot/update-ci-workflow-yarn-version

Conversation

Copilot AI commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

PR workflows were failing because runners resolved global Yarn 1.x while the repo requires yarn@4.9.2 via packageManager. This aligns all relevant workflows to explicitly activate Yarn 4 through Corepack before dependency install.

  • Workflow alignment with packageManager

    • Updated .github/workflows/ci.yml (lint, build) to activate Yarn 4.9.2 after Corepack enablement.
    • Updated .github/workflows/release.yml (release-bundle) with the same activation step.
    • Kept actions/setup-node and cache: yarn intact.
  • Resulting execution path

    • Each job now uses Corepack-managed Yarn 4 before yarn install --immutable, preventing fallback to global Yarn 1.x.
- name: Enable Corepack
  run: corepack enable
- name: Activate Yarn 4.9.2
  run: corepack prepare yarn@4.9.2 --activate
- name: Install dependencies
  run: yarn install --immutable
Original prompt

Repo: Lint-Free-Technology/flipdown-timer-card

A GitHub Actions CI job is failing on PR #41 because the workflow is using global Yarn 1.22.22, but the repository specifies "packageManager": "yarn@4.9.2" in package.json. The job log shows:

  • error This project's package.json defines "packageManager": "yarn@4.9.2". However the current global version of Yarn is 1.22.22.
  • It indicates the project is meant to be used with Corepack.

Failing runId: 26991471883, jobId: 79652338154
Workflow file:

  • .github/workflows/ci.yml

Task:

  1. Update .github/workflows/ci.yml so that CI reliably uses Yarn v4.9.2 via Corepack, instead of global Yarn 1.x.
  2. After corepack enable, add a step to prepare and activate the exact Yarn version (4.9.2), in BOTH lint and build jobs:
    • corepack prepare yarn@4.9.2 --activate
  3. Keep actions/setup-node and caching intact (cache: yarn).
  4. Ensure workflow YAML remains valid.

Deliverable:

  • Open a pull request with the change.
  • PR title: "CI: activate Yarn 4 via Corepack".

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Please find a solution for this failing job. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.

Assistant: The job is failing because the workflow is invoking the global Yarn 1.x (1.22.22) even though your package.json declares:

"packageManager": "yarn@4.9.2"

From the logs, the failure happens at the point where the workflow checks Yarn / cache dir, before it ever installs dependencies:

error This project's package.json defines "packageManager": "yarn@4.9.2". However the current global version of Yarn is 1.22.22.
Corepack must currently be enabled...

Fix (make Yarn 4 actually be used in CI)

You already have an “Enable Corepack” step in .github/workflows/ci.yml (lines 21–24 and 36–39), but in practice the runner is still picking up Yarn 1.x. The most reliable fix is to explicitly activate the Yarn version declared by the repo after enabling Corepack.

Patch: update both jobs in .github/workflows/ci.yml

Add a Corepack prepare step right after corepack enable:

      - name: Enable Corepack
        run: corepack enable

      - name: Use Yarn from packageManager
        run: corepack prepare yarn@4.9.2 --activate

So the lint job becomes:

  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: Use Node.js LTS
        uses: actions/setup-node@v6
        with:
          node-version: lts/*
          cache: yarn
      - name: Enable Corepack
        run: corepack enable
      - name: Use Yarn from packageManager
        run: corepack prepare yarn@4.9.2 --activate
      - name: Install dependencies
        run: yarn install --immutable
      - name: Lint the code
        run: npm run lint --if-present

And apply the same change to the build job.

Why this works

  • corepack enable turns on Corepack shims, but doesn’t always guarantee the requested Yarn version is activated in every environment.
  • corepack prepare ... --activate forces Yarn 4.9.2 to be installed/selected, ensuring yarn install --immutable runs with Yarn 4 as required by packageManager.

After this change, the Yarn version mismatch error should be resolved and the job should proceed to dependency installation and the actual lint/build steps.

User: Please generate PR to fix.

Assistant: I’m ready to open the pull request with the CI workflow change, but I need your confirmation

User: Please proceed

Assistant: I can’t proceed with creating the PR from my side right now because I don’t currently have access to run the GitHub automation needed to open it.

If you want to do it quickly yourself, here’s the exact change to make and then open a PR:

  1. Edit .github/workflows/ci.yml
  2. In both lint and build jobs, add this step immediately after corepack enable:
      - name: Use Yarn from packageManager
        run: corepack prepare yarn@4.9.2 --activate

So each job should contain (in order):

      - name: Enable Corepack
        run: corepack enable
      - name: Use Yarn from packageManager
        run: corepack prepare yarn@4.9.2 --activate
      - name: Install dependencies
        run: yarn install --immutable

Suggested PR title: “CI: activate Yarn 4 via Corepack”.

If you paste the branch name you want (or tell me your default branch), I can also format this as a ready-to-apply patch/diff.

This pull request was created from Copilot chat.

@dcapslock
dcapslock marked this pull request as ready for review June 5, 2026 02:26
Copilot AI changed the title [WIP] Update CI workflow to use Yarn 4.9.2 CI: activate Yarn 4 via Corepack Jun 5, 2026
Copilot AI requested a review from dcapslock June 5, 2026 02:29

@dcapslock dcapslock left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Also make change for release workflow.

Copilot AI commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

Also make change for release workflow.

Updated the release workflow to activate Yarn 4.9.2 via Corepack as well. Addressed in commit 4392185.

Copilot AI changed the title CI: activate Yarn 4 via Corepack CI: activate Yarn 4 via Corepack in CI and release workflows Jun 5, 2026
@dcapslock
dcapslock merged commit 8e426ff into master Jun 5, 2026
2 of 4 checks passed
@dcapslock
dcapslock deleted the copilot/update-ci-workflow-yarn-version branch June 5, 2026 02:39
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.

2 participants