on: push: branches: - master - 'cherry-pick/**' pull_request: merge_group: concurrency: # group by workflow and ref; the last slightly strange component ensures that for pull # requests, we limit to 1 concurrent job, but for the master branch we don't group: ${{github.workflow}}-${{github.ref}}-${{github.ref != 'refs/heads/master' || github.run_number}} # Cancel intermediate builds, but only if it is a pull request build. cancel-in-progress: ${{startsWith(github.ref, 'refs/pull/')}} env: node-version: '18.x' name: 'Integration' jobs: chore: name: 'Testing chores' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: | git fetch --no-tags --unshallow origin HEAD master - name: 'Use Node.js ${{ env.node-version }}' uses: actions/setup-node@v4 with: node-version: ${{ env.node-version }} - name: 'Check that the Yarn files don''t change on new installs (fix w/ "yarn install")' run: | node ./scripts/run-yarn.js --immutable --immutable-cache shell: bash - name: 'Check that the cache files are consistent with their remote sources' run: | if [[ $(git diff --name-only "$(git merge-base origin/"$TARGET_BRANCH" HEAD)" HEAD -- '.yarn/cache' 'packages/yarnpkg-libzip' | wc -l) -gt 0 ]]; then node ./scripts/run-yarn.js --immutable --immutable-cache --check-cache fi shell: bash if: | (success() || failure()) && github.event.pull_request != '' env: TARGET_BRANCH: ${{github.event.pull_request.base.ref}} - name: 'Check that the patch files are consistent with fresh builds' run: | if [[ $(git diff --name-only "$(git merge-base origin/"$TARGET_BRANCH" HEAD)" HEAD -- packages/plugin-compat/sources/patches | wc -l) -gt 0 ]]; then for generator in packages/plugin-compat/extra/*/gen-*-patch.sh; do bash $generator; done for generator in packages/plugin-compat/extra/*/gen-*-patch.js; do yarn node $generator; done [[ $(git diff --name-only packages/plugin-compat/sources/patches "packages/plugin-compat/extra/typescript/patch*" | tee /dev/stderr | wc -l) -eq 0 ]] fi shell: bash if: | (success() || failure()) && github.event.pull_request != '' env: TARGET_BRANCH: ${{github.event.pull_request.base.ref}} - name: 'Check that libzip artifacts are consistent with a fresh build (fix w/ "git merge master && bash packages/yarnpkg-libzip/artifacts/build.sh")' run: | if [[ $(git diff --name-only "$(git merge-base origin/"$TARGET_BRANCH" HEAD)" HEAD -- 'packages/yarnpkg-libzip/artifacts' 'packages/yarnpkg-libzip/sources/*.js' | wc -l) -gt 0 ]]; then bash packages/yarnpkg-libzip/artifacts/build.sh [[ $(git diff --name-only 'packages/yarnpkg-libzip/artifacts' 'packages/yarnpkg-libzip/sources/*.js' | wc -l) -eq 0 ]] fi shell: bash if: | (success() || failure()) && github.event.pull_request != '' env: TARGET_BRANCH: ${{github.event.pull_request.base.ref}} - name: 'Check that the PnP hooks are consistent with a fresh build (fix w/ "git merge master && yarn update:pnp:hook")' run: | if [[ $(git diff --name-only "$(git merge-base origin/"$TARGET_BRANCH" HEAD)" HEAD -- 'packages/yarnpkg-{fslib,libzip,pnp}/sources/**/*' | wc -l) -gt 0 ]]; then node ./scripts/run-yarn.js build:pnp:hook [[ $(git diff --name-only packages/yarnpkg-pnp/sources/{hook.js,esm-loader/built-loader.js} | wc -l) -eq 0 ]] fi shell: bash if: | (success() || failure()) && github.event.pull_request != '' env: TARGET_BRANCH: ${{github.event.pull_request.base.ref}} - name: 'Check that the Zip worker is consistent with a fresh build (fix w/ "git merge master && yarn update:zip:worker")' run: | if [[ $(git diff --name-only "$(git merge-base origin/"$TARGET_BRANCH" HEAD)" HEAD -- 'packages/yarnpkg-{fslib,libzip,core}/sources/**/*' | wc -l) -gt 0 ]]; then node ./scripts/run-yarn.js build:zip:worker [[ $(git diff --name-only packages/yarnpkg-core/sources/worker-zip/index.js | wc -l) -eq 0 ]] fi shell: bash if: | (success() || failure()) && github.event.pull_request != '' env: TARGET_BRANCH: ${{github.event.pull_request.base.ref}} - name: 'Check that the pluginCommands file is consistent with a fresh build (fix w/ "yarn build:plugin-commands")' run: | if [[ $(git diff --name-only "$(git merge-base origin/"$TARGET_BRANCH" HEAD)" HEAD -- packages/yarnpkg-cli/sources/pluginCommands.ts 'packages/*/sources/commands/**/*' | wc -l) -gt 0 ]]; then node ./scripts/run-yarn.js build:plugin-commands [[ $(git diff --name-only packages/yarnpkg-cli/sources/pluginCommands.ts | tee /dev/stderr | wc -l) -eq 0 ]] fi shell: bash if: | (success() || failure()) && github.event.pull_request != '' env: TARGET_BRANCH: ${{github.event.pull_request.base.ref}} - name: 'Check that the grammars are consistent with fresh builds (fix w/ "yarn grammar:all")' run: | if [[ $(git diff --name-only "$(git merge-base origin/"$TARGET_BRANCH" HEAD)" HEAD -- 'packages/yarnpkg-parsers/sources/grammars/*.{pegjs,js}' | wc -l) -gt 0 ]]; then node ./scripts/run-yarn.js grammar:all [[ $(git diff --name-only packages/yarnpkg-parsers/sources/grammars/*.js | tee /dev/stderr | wc -l) -eq 0 ]] fi shell: bash if: | (success() || failure()) && github.event.pull_request != '' env: TARGET_BRANCH: ${{github.event.pull_request.base.ref}} - name: 'Check that the PR describes which packages should be bumped (fix w/ "yarn version check -i")' run: | node ./scripts/run-yarn.js version check shell: bash if: | (success() || failure()) && github.event.pull_request != '' - name: 'Check for linting errors (fix w/ "yarn test:lint --fix")' run: | node ./scripts/run-yarn.js test:lint shell: bash if: | success() || failure() - name: 'Check for unmet constraints (fix w/ "yarn constraints --fix")' run: | node ./scripts/run-yarn.js constraints shell: bash if: | success() || failure() - name: 'Check for type errors' run: | node ./scripts/run-yarn.js typecheck:all shell: bash if: | success() || failure() - name: 'Check for duplicate dependencies (fix w/ "yarn dedupe")' run: | node ./scripts/run-yarn.js dedupe --check shell: bash if: | success() || failure() - name: 'Check for outdated e2e status list (fix w/ "node ./scripts/generate-e2e-status-list.mjs")' run: | node ./scripts/generate-e2e-status-list.mjs git diff --exit-code shell: bash if: | success() || failure() build: name: 'Build artifacts' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: 'Use Node.js ${{ env.node-version }}' uses: actions/setup-node@v4 with: node-version: ${{ env.node-version }} - name: 'Build bundle & plugins' run: | node --version node ./scripts/run-yarn.js build:pnp:hook node ./scripts/run-yarn.js build:zip:worker node ./scripts/run-yarn.js build:cli mv ./packages/yarnpkg-cli/bundles/yarn.js ./packages/yarnpkg-cli/bundles/yarn-min.js node ./scripts/run-yarn.js build:cli --no-minify shell: bash - uses: actions/upload-artifact@v4 with: name: yarn-artifacts path: | ./packages/*/bundles ./packages/yarnpkg-pnp/sources/hook.js ./packages/yarnpkg-core/sources/worker-zip/index.js - name: 'Build vscode-zipfs' run: | node ./scripts/run-yarn.js package:vscode-zipfs if: | success() || failure() - uses: actions/upload-artifact@v4 with: name: vscode-zipfs path: ./packages/vscode-zipfs/vscode-zipfs-*.vsix node-versions: name: 'Acceptance test node versions' outputs: versions: ${{ steps.versions.outputs.versions }} nightly: ${{ steps.versions.outputs.nightly }} runs-on: ubuntu-latest steps: - id: versions shell: bash run: > # Get the latest and LTS major versions that we support echo -n 'versions=' >> $GITHUB_OUTPUT curl https://nodejs.org/dist/index.json | jq -c '[.[0:1] + map(select(.lts)) | .[].version | capture("^v(?\\d+)") | .major | tonumber] | unique | map(select(. >= 18))' >> $GITHUB_OUTPUT # Get the latest nightly version that runs on both macOS and Windows echo -n 'nightly=' >> $GITHUB_OUTPUT curl https://nodejs.org/download/nightly/index.json | jq -r 'map(select([("osx-arm64-tar", "win-x64-exe") as $FILE | .files | any(. == $FILE)] | all)) | first | .version' >> $GITHUB_OUTPUT # Show output in logs cat $GITHUB_OUTPUT acceptance: strategy: fail-fast: false matrix: # We run the ubuntu tests on multiple Node versions with 2 shards since they're the fastest. node: ${{ fromJson(needs.node-versions.outputs.versions) }} platform: [ubuntu-22.04] shard: ['1/2', '2/2'] include: # We run the rest of the tests on the minimum Node version we support with 3 shards. # Windows tests - {node: 18, platform: windows-latest, shard: 1/3} - {node: 18, platform: windows-latest, shard: 2/3} - {node: 18, platform: windows-latest, shard: 3/3} # macOS tests - {node: 18, platform: macos-latest, shard: 1/3} - {node: 18, platform: macos-latest, shard: 2/3} - {node: 18, platform: macos-latest, shard: 3/3} # We also run them on the maximum Node version we support, to catch potential regressions in Node.js. # Windows tests - {node: "${{ needs.node-versions.outputs.nightly }}", platform: windows-latest, shard: 1/3, nightly: true} - {node: "${{ needs.node-versions.outputs.nightly }}", platform: windows-latest, shard: 2/3, nightly: true} - {node: "${{ needs.node-versions.outputs.nightly }}", platform: windows-latest, shard: 3/3, nightly: true} # macOS tests - {node: "${{ needs.node-versions.outputs.nightly }}", platform: macos-latest, shard: 1/3, nightly: true} - {node: "${{ needs.node-versions.outputs.nightly }}", platform: macos-latest, shard: 2/3, nightly: true} - {node: "${{ needs.node-versions.outputs.nightly }}", platform: macos-latest, shard: 3/3, nightly: true} name: '${{matrix.platform}} w/ Node.js ${{matrix.node}} (${{matrix.shard}})' runs-on: ${{matrix.platform}} continue-on-error: ${{matrix.nightly == true}} needs: [build, node-versions] # Permission required to produce a valid provenance statement during the tests # Only run inside the main repository; this may fail in master since it doesn't run in PRs from forks permissions: id-token: write steps: - uses: actions/checkout@v4 - name: 'Use Node.js ${{matrix.node}}' uses: actions/setup-node@v4 with: node-version: ${{matrix.node}} - uses: actions/download-artifact@v4 with: name: yarn-artifacts path: packages - name: 'Run the integration tests' run: | node ./scripts/run-yarn.js test:integration --maxWorkers=100% --shard=${{matrix.shard}} shell: bash - name: 'Run the unit tests' run: | node ./scripts/run-yarn.js test:unit --maxWorkers=100% --shard=${{matrix.shard}} shell: bash if: | success() || failure() big-endian: strategy: fail-fast: false matrix: shard: ['1/4', '2/4', '3/4', '4/4'] name: 'Big-endian debian w/ Node.js latest (${{matrix.shard}})' runs-on: ubuntu-22.04 if: | github.ref == 'refs/heads/master' needs: build steps: - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 with: name: yarn-artifacts path: packages # https://github.com/tonistiigi/binfmt - name: 'Enable execution of multi-arch containers' run: | docker run --rm --privileged tonistiigi/binfmt:latest --install all shell: bash # Apparently @babel/register is insanely slow inside the big-endian # docker container, so we don't want to run yarn from sources at all. - name: 'Run the integration tests' run: | docker run --rm --volume "$PWD:/berry" --env GITHUB_ACTIONS --env YARN_IGNORE_PATH=1 --workdir /berry --platform linux/s390x node /bin/bash -c 'node ./packages/yarnpkg-cli/bundles/yarn.js test:integration --maxWorkers=100% --shard=${{matrix.shard}}' shell: bash - name: 'Run the unit tests' run: | docker run --rm --volume "$PWD:/berry" --env GITHUB_ACTIONS --env YARN_IGNORE_PATH=1 --workdir /berry --platform linux/s390x node /bin/bash -c 'node ./packages/yarnpkg-cli/bundles/yarn.js test:unit --maxWorkers=100% --shard=${{matrix.shard}}' shell: bash if: | success() || failure() test-results: name: 'Acceptance test results' runs-on: ubuntu-latest needs: [acceptance, big-endian] if: "!cancelled() && (github.event_name == 'pull_request' || github.event_name == 'merge_group')" steps: - id: test-results shell: bash run: > if [[ "${{ needs.acceptance.result }}" != "success" ]]; then exit 1 elif [[ "${{ needs.big-endian.result }}" != "success" && "${{ needs.big-endian.result }}" != "skipped" ]]; then exit 1 fi