Skip to content

Commit abbab85

Browse files
chore: Use node 24 and npm trusted publishing, and update cspell (backport of #3411 for 2.9) (#3417)
This PR is a backport of #3411 for the `version-2.10` branch. Specifically, this PR: - Adds an ignore rule to cspell for GHSA IDs. - Backports the node orb version bump and lint CircleCI jobs from `main` (previously using `node/run`). - Bumps `actions/checkout` to v4 and adds OIDC/changesets permissions in the release GitHub action. - Bumps node to v24 for the repo (which is bundled with npm v11), updating the lint CircleCI jobs and release GitHub action as well. - This is because npm trusted publishing requires at least npm v11.5.1. - Bumps the npm constraint in `engines` in `package.json` to `<12` (to allow running npm v11). - Runs the test CircleCI jobs for node v22, v24, and latest. - The job was previously installing npm v9 because node v14's bundled npm version was too low to support the `package-lock.json`, but it was doing this for all node versions. We've now changed this to only happen for node v14. - Stops passing `NPM_TOKEN` to `changesets/action` in the release GitHub action. - Note that npm versions that support trusted publishing will [ignore locally configured tokens when OIDC environment variables are present](https://github.com/npm/cli/blob/8afa3bd21461c0984caf1bcc2e486c4881bda516/lib/utils/oidc.js#L141) (which they are for GH actions, since we've set that up), so `NPM_TOKEN` would be ignored anyway. But the main reason for this change is to stop `changesets/action` from printing a misleading log message saying `NPM_TOKEN` has been placed into `.npmrc` (which, while true, will be ignored by `npm publish`). - Note that we still need to keep the `NPM_TOKEN` GitHub secret around to run any tag-changing scripts, as `npm dist-tag` sadly doesn't support OIDC yet (see npm/cli#8547 for discussion). This means we'll need to manually rotate the token every 90 days. - Uses `npm ci` instead of `npm i` in the release GitHub action. - As a requirement for releasing (or filing a release PR), the `package-lock.json` should be aligned with the `package.json`. - Remove the `federation-rs` step in the release GitHub action, as this is no longer necessary in the release process. - We also stop setting `FEDERATION_VERSION`, since it's no longer used. - Sets the tag for npm publishes to the branch name for `version-*` branches. - Previously, it was the default of `latest`, which was causing backport releases to mistakenly change the `latest` tag (used when someone `npm i`s without a version number). - We also tightened the `version-*` branch pattern down to `version-[0-9]+.[0-9]+` (since it's getting passed around in bash now). - Backports #3195, which removes security CircleCI jobs (they've been replaced with a GitHub app).
1 parent f4ef6eb commit abbab85

6 files changed

Lines changed: 76 additions & 85 deletions

File tree

.circleci/config.yml

Lines changed: 38 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
version: 2.1
22

33
orbs:
4-
node: circleci/[email protected]
5-
secops: apollo/[email protected]
4+
node: circleci/[email protected]
65

76
jobs:
87
# Unfortunately cimg/node doesn't tag its images with major only, you have to specify a minor version.
@@ -14,13 +13,18 @@ jobs:
1413
type: string
1514
docker:
1615
- image: cimg/base:stable
16+
resource_class: large
1717
steps:
1818
- checkout
1919
- node/install:
2020
node-version: << parameters.node-version >>
2121
# node v14 defaults to npm 6, which is too old for our package-lock.json
2222
# should be able to remove this step when we drop node v14
23-
- run: npm install -g npm@9
23+
- when:
24+
condition:
25+
equal: [ "14", << parameters.node-version >> ]
26+
steps:
27+
- run: npm install -g npm@9
2428
- node/install-packages
2529
- run:
2630
name: Run tests
@@ -30,6 +34,24 @@ jobs:
3034
command: npm run coverage:upload
3135
- store_test_results:
3236
path: junit.xml
37+
Lint:
38+
description: "Run a lint command using a specific Node.js version"
39+
parameters:
40+
script:
41+
type: string
42+
docker:
43+
- image: cimg/base:stable
44+
steps:
45+
- checkout
46+
- node/install:
47+
node-version: '24'
48+
- node/install-packages
49+
- run:
50+
name: Compile
51+
command: npm run compile
52+
- run:
53+
name: Run lint
54+
command: npm run << parameters.script >>
3355

3456
workflows:
3557
Build:
@@ -43,48 +65,16 @@ workflows:
4365
- "16"
4466
- "18"
4567
- "20"
46-
- node/run:
47-
name: Check Error Code Doc
48-
npm-run: error-code-doc:check
49-
setup:
50-
- node/install:
51-
node-version: "20"
52-
- node/run:
53-
name: Check GraphQL Types
54-
npm-run: codegen:check
55-
setup:
56-
- node/install:
57-
node-version: "20"
58-
- node/run:
59-
name: Check Hints Code Doc
60-
override-ci-command: npm ci && npm run compile
61-
npm-run: hints-doc:check
62-
setup:
63-
- node/install:
64-
node-version: "20"
65-
- node/run:
66-
name: Check Spelling
67-
npm-run: spell:check
68-
setup:
69-
- node/install:
70-
node-version: "20"
71-
- node/run:
72-
name: Check Prettier (tests)
73-
npm-run: prettier:check
74-
setup:
75-
- node/install:
76-
node-version: "20"
77-
security-scans:
78-
jobs:
79-
- secops/gitleaks:
80-
context:
81-
- platform-docker-ro
82-
- github-orb
83-
- secops-oidc
84-
git-base-revision: <<#pipeline.git.base_revision>><<pipeline.git.base_revision>><</pipeline.git.base_revision >>
85-
git-revision: << pipeline.git.revision >>
86-
- secops/semgrep:
87-
context:
88-
- secops-oidc
89-
- github-orb
90-
git-base-revision: <<#pipeline.git.base_revision>><<pipeline.git.base_revision>><</pipeline.git.base_revision >>
68+
- "22"
69+
- "24"
70+
- "latest"
71+
- Lint:
72+
name: Lint - << matrix.script >>
73+
matrix:
74+
parameters:
75+
script:
76+
- "error-code-doc:check"
77+
- "codegen:check"
78+
- "hints-doc:check"
79+
- "spell:check"
80+
- "prettier:check"

.cspell/cspell-dict.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,5 +284,3 @@ webp
284284
whith
285285
wizz
286286
woudl
287-
pfjj
288-
rvmh

.cspell/cspell.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ overrides:
3434
- filename: '**/CHANGELOG*.md'
3535
ignoreRegExpList:
3636
- "@[-\\w]+"
37+
# Ignore GitHub GHSA IDs.
38+
- filename: '**/*.md*'
39+
ignoreRegExpList:
40+
- "GHSA-[2-9cfghjmpqrvwx]{4}-[2-9cfghjmpqrvwx]{4}-[2-9cfghjmpqrvwx]{4}"
3741
# Ignore the targets of links and YouTube IDs in Markdown/MDX files.
3842
- filename: '**/*.md*'
3943
ignoreRegExpList:

.github/workflows/release.yml

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,68 +5,67 @@ on:
55
branches:
66
- main
77
- next
8-
- version-*
8+
- version-[0-9]+.[0-9]+
99

1010
concurrency: ${{ github.workflow }}-${{ github.ref }}
1111

12+
permissions:
13+
id-token: write # Required for OIDC
14+
contents: write # Required for changesets to push release branch
15+
pull-requests: write # Required for changesets to create release PR
16+
1217
jobs:
1318
release:
1419
name: Release
1520
runs-on: ubuntu-latest
1621
if: github.repository == 'apollographql/federation'
1722
steps:
1823
- name: Checkout Repo
19-
uses: actions/checkout@v3
24+
uses: actions/checkout@v4
2025

21-
- name: Setup Node.js 16
22-
uses: actions/setup-node@v3
26+
- name: Setup Node.js 24
27+
uses: actions/setup-node@v4
2328
with:
24-
node-version: 16
29+
node-version: '24'
30+
registry-url: 'https://registry.npmjs.org'
2531

2632
- name: Install Dependencies
27-
run: npm i
28-
29-
- name: Set env
30-
run: echo "FEDERATION_VERSION=$(npm --prefix ./internals-js version --json |jq -r '.["@apollo/federation-internals"]')" >> $GITHUB_ENV
33+
run: npm ci
34+
35+
- name: Determine npm tag override for version branches
36+
id: npm-tag
37+
run: |
38+
if [[ ! -f .changeset/pre.json ]] && [[ "${{ github.ref_name }}" =~ ^version-.+$ ]]; then
39+
echo "args=-- --tag=${{ github.ref_name }}" >> $GITHUB_OUTPUT
40+
else
41+
echo "args=" >> $GITHUB_OUTPUT
42+
fi
3143
32-
- name: Create Release Pull Request
44+
- name: Create Release Pull Request or Publish to npm
3345
id: changesets
3446
uses: changesets/action@v1
3547
with:
3648
title: "release: on branch ${{ github.ref_name }}"
3749
createGithubReleases: true
38-
publish: npm run build-and-publish
50+
publish: npm run build-and-publish ${{ steps.npm-tag.outputs.args }}
3951
# workaround for https://github.com/changesets/action/issues/203, includes an `npm i` after running the version command
4052
version: npm run changeset-version
4153
env:
4254
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
44-
55+
4556
- name: Sleep for 20 seconds (arbitrary, give NPM time to populate new `latest` versions)
4657
if: steps.changesets.outputs.published == 'true'
4758
run: sleep 20
4859
shell: bash
4960

50-
- name: Kick off release in federation-rs
51-
if: steps.changesets.outputs.published == 'true'
52-
uses: actions/github-script@v6
53-
with:
54-
github-token: ${{ secrets.ACTION_PAT }}
55-
script: |
56-
await github.rest.actions.createWorkflowDispatch({
57-
owner: 'apollographql',
58-
repo: 'federation-rs',
59-
workflow_id: '.github/workflows/release.yml',
60-
ref: 'main',
61-
inputs: {
62-
version: "${{ env.FEDERATION_VERSION }}"
63-
}
64-
})
61+
# While "npm publish" can use OIDC tokens, "npm dist-tag" sadly cannot, so we'll still need to
62+
# regenerate a granular access token every 90 days via the npmjs.com UI and set the NPM_TOKEN
63+
# secret in GitHub. The relevant npm GitHub issue is at https://github.com/npm/cli/issues/8547
6564
- name: Write token to the NPM rc file (login)
6665
if: steps.changesets.outputs.published == 'true'
6766
# write token to the NPM rc file (npm login)
6867
run: echo //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} > ~/.npmrc
69-
68+
7069
- name: Update next tags if appropriate
7170
if: steps.changesets.outputs.published == 'true'
7271
run: node scripts/update-next-tags.mjs

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@
2727
"changeset-version": "changeset version && npm i",
2828
"build-and-publish": "npm run compile && changeset publish",
2929
"spell:check": "cspell lint --no-progress --config .cspell/cspell.yml || (echo 'Add any real words to ./cspell/cspell-dict.txt.'; exit 1)",
30-
"//": "This only needs to use prettier@2 for as long as jest disallows using prettier@3",
30+
"__comment_for_prettier": "This only needs to use prettier@2 for as long as jest disallows using prettier@3",
3131
"prettier:check": "node ./node_modules/prettier-2/bin-prettier.js --check ./**/__tests__/**/*.test.ts",
3232
"prettier:fix": "node ./node_modules/prettier-2/bin-prettier.js --write ./**/__tests__/**/*.test.ts",
33-
"//": "Optional: run this to configure git hooks and blame ignore revs",
33+
"__comment_for_git:configure": "Optional: run this to configure git hooks and blame ignore revs",
3434
"git:configure": "git config core.hooksPath .git-hooks; git config blame.ignoreRevsFile .git-blame-ignore-revs"
3535
},
3636
"engines": {
3737
"node": ">=14.15.0",
38-
"npm": "<11"
38+
"npm": "<12"
3939
},
4040
"workspaces": [
4141
"internals-js",
@@ -106,7 +106,7 @@
106106
]
107107
},
108108
"volta": {
109-
"node": "20.10.0",
110-
"npm": "10.2.4"
109+
"node": "24.14.0",
110+
"npm": "11.9.0"
111111
}
112112
}

0 commit comments

Comments
 (0)