Skip to content

Commit a815187

Browse files
authored
Merge branch 'nodejs:main' into allow-toc-to-scroll-independently
2 parents 1428437 + d122e58 commit a815187

82 files changed

Lines changed: 2342 additions & 829 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/lint-and-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,10 @@ jobs:
149149
if: ${{ !cancelled() && github.event_name != 'merge_group' }}
150150
uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2
151151
with:
152-
files: ./apps/site/lcov.info,./packages/ui-components/lcov.info
152+
files: ./apps/site/lcov.info,./packages/*/lcov.info
153153

154154
- name: Upload test results to Codecov
155155
if: ${{ !cancelled() && github.event_name != 'merge_group' }}
156156
uses: codecov/test-results-action@f2dba722c67b86c6caa034178c6e4d35335f6706 # v1.1.0
157157
with:
158-
files: ./apps/site/junit.xml,./packages/ui-components/junit.xml
158+
files: ./apps/site/junit.xml,./packages/*/junit.xml

.github/workflows/playwright.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Security Notes
2+
# Only selected Actions are allowed within this repository. Please refer to (https://github.com/nodejs/nodejs.org/settings/actions)
3+
# for the full list of available actions. If you want to add a new one, please reach out a maintainer with Admin permissions.
4+
# REVIEWERS, please always double-check security practices before merging a PR that contains Workflow changes!!
5+
# AUTHORS, please only use actions with explicit SHA references, and avoid using `@master` or `@main` references or `@version` tags.
6+
# MERGE QUEUE NOTE: This Workflow does not run on `merge_group` trigger, as this Workflow is not required for Merge Queue's
7+
8+
name: Playwright Tests
9+
10+
on:
11+
pull_request:
12+
branches:
13+
- main
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
permissions:
20+
contents: read
21+
actions: read
22+
23+
jobs:
24+
get-vercel-preview:
25+
name: Get Vercel Preview
26+
runs-on: ubuntu-latest
27+
outputs:
28+
deployment_found: ${{ steps.set_outputs.outputs.deployment_found }}
29+
url: ${{ steps.set_outputs.outputs.url }}
30+
steps:
31+
- name: Capture Vercel Preview
32+
id: check_deployment
33+
uses: patrickedqvist/wait-for-vercel-preview@06c79330064b0e6ef7a2574603b62d3c98789125 # v1.3.2
34+
with:
35+
token: ${{ secrets.GITHUB_TOKEN }}
36+
max_timeout: 300 # timeout after 5 minutes
37+
check_interval: 10 # check every 10 seconds
38+
continue-on-error: true
39+
- name: Set Outputs
40+
if: always()
41+
id: set_outputs
42+
run: |
43+
if [[ -z "${{ steps.check_deployment.outputs.url }}" ]]; then
44+
echo "deployment_found=false" >> $GITHUB_OUTPUT
45+
else
46+
echo "deployment_found=true" >> $GITHUB_OUTPUT
47+
echo "url=${{ steps.check_deployment.outputs.url }}" >> $GITHUB_OUTPUT
48+
fi
49+
50+
playwright:
51+
needs: get-vercel-preview
52+
if: needs.get-vercel-preview.outputs.deployment_found == 'true'
53+
name: Playwright Tests
54+
runs-on: ubuntu-latest
55+
56+
steps:
57+
- name: Harden Runner
58+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
59+
with:
60+
egress-policy: audit
61+
62+
- name: Git Checkout
63+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
64+
65+
- name: Set up pnpm
66+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
67+
with:
68+
cache: true
69+
70+
- name: Set up Node.js
71+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
72+
with:
73+
# We want to ensure that the Node.js version running here respects our supported versions
74+
node-version-file: '.nvmrc'
75+
cache: 'pnpm'
76+
77+
- name: Install packages
78+
run: pnpm install --frozen-lockfile
79+
80+
- name: Get Playwright version
81+
id: playwright-version
82+
working-directory: apps/site
83+
run: echo "version=$(pnpm exec playwright --version | awk '{print $2}')" >> $GITHUB_OUTPUT
84+
85+
- name: Cache Playwright browsers
86+
id: playwright-cache
87+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
88+
with:
89+
path: ~/.cache/ms-playwright
90+
key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}
91+
92+
- name: Install Playwright Browsers
93+
working-directory: apps/site
94+
run: pnpm exec playwright install --with-deps
95+
96+
- name: Run Playwright tests
97+
working-directory: apps/site
98+
run: pnpm playwright
99+
env:
100+
VERCEL_PREVIEW_URL: ${{ needs.get-vercel-preview.outputs.url }}
101+
102+
- name: Upload Playwright test results
103+
if: always()
104+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
105+
with:
106+
name: playwright-report
107+
path: apps/site/playwright-report/
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
name: Publish Packages
2+
3+
# This workflow publishes packages to NPM when changes are merged to main branch or when manually triggered.
4+
# It runs automatically after successful tests or can be run manually for specific packages.
5+
6+
on:
7+
workflow_run:
8+
# Only run after linting and tests have passed on main branch
9+
workflows: ['Linting and Tests']
10+
types: [completed]
11+
# For security reasons, this should never be set to anything but `main`
12+
branches: [main]
13+
workflow_dispatch:
14+
inputs:
15+
package:
16+
description: 'Specific package to publish (leave empty for all packages)'
17+
required: false
18+
type: string
19+
20+
permissions:
21+
contents: read
22+
23+
env:
24+
# Use the SHA from the workflow run that triggered this or the current SHA for manual runs
25+
COMMIT_SHA: ${{ github.event.workflow_run.head_sha || github.sha }}
26+
27+
jobs:
28+
prepare-packages:
29+
runs-on: ubuntu-latest
30+
# Only run if manually triggered or if the triggering workflow succeeded from a push event
31+
if: github.event_name == 'workflow_dispatch' || (
32+
github.event.workflow_run.conclusion == 'success' &&
33+
github.event.workflow_run.event == 'push' &&
34+
github.repository == 'nodejs/nodejs.org')
35+
outputs:
36+
# Output the matrix of packages to publish for use in the publish job
37+
matrix: ${{ steps.generate-matrix.outputs.matrix }}
38+
steps:
39+
- name: Harden Runner
40+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
41+
with:
42+
egress-policy: audit
43+
44+
- name: Verify commit authenticity
45+
env:
46+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
run: |
48+
# Get commit data from GitHub API to verify its authenticity
49+
COMMIT_DATA=$(gh api repos/${{ github.repository }}/commits/$COMMIT_SHA)
50+
# Check if commit signature is verified (GPG signed)
51+
VERIFIED=$(echo "$COMMIT_DATA" | jq -r '.commit.verification.verified')
52+
# Check if commit was made through GitHub's web interface (merge queue)
53+
COMMITTER=$(echo "$COMMIT_DATA" | jq -r '.commit.committer.email')
54+
55+
# Security checks to ensure we only publish from verified and trusted sources
56+
if [[ "$VERIFIED" != "true" ]]; then
57+
echo "❌ Unverified commit! Aborting."
58+
exit 1
59+
fi
60+
61+
if [[ "$COMMITTER" != "[email protected]" ]]; then
62+
echo "❌ Not merged with the merge queue! Aborting."
63+
exit 1
64+
fi
65+
66+
echo "✅ Commit is verified and trusted."
67+
68+
- name: Checkout repository
69+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
70+
with:
71+
fetch-depth: 2 # Need at least 2 commits to detect changes between commits
72+
73+
- name: Generate package matrix
74+
id: generate-matrix
75+
env:
76+
PACKAGE: ${{ github.event.inputs.package }}
77+
EVENT_NAME: ${{ github.event_name }}
78+
run: |
79+
if [ -n "$PACKAGE" ]; then
80+
# If a specific package is requested via workflow_dispatch, just publish that one
81+
echo "matrix={\"package\":[\"$PACKAGE\"]}" >> $GITHUB_OUTPUT
82+
else
83+
# Otherwise, identify all packages with changes since the last commit
84+
CHANGED_PACKAGES=()
85+
for pkg in $(ls -d packages/*); do
86+
PKG_NAME=$(basename "$pkg")
87+
# For manual runs, include all packages. For automatic runs, only include packages with changes
88+
if [ "$EVENT_NAME" == "workflow_dispatch" ] || ! git diff --quiet $COMMIT_SHA~1 $COMMIT_SHA -- "$pkg/"; then
89+
CHANGED_PACKAGES+=("$PKG_NAME")
90+
fi
91+
done
92+
93+
# Format the output for GitHub Actions matrix using jq
94+
PACKAGES_JSON=$(jq -n '$ARGS.positional' --args "${CHANGED_PACKAGES[@]}" -c)
95+
echo "matrix={\"package\":$PACKAGES_JSON}" >> $GITHUB_OUTPUT
96+
fi
97+
98+
publish:
99+
needs: prepare-packages
100+
runs-on: ubuntu-latest
101+
# Use the dynamic matrix from prepare-packages job to create parallel jobs for each package
102+
strategy:
103+
matrix: ${{ fromJson(needs.prepare-packages.outputs.matrix) }}
104+
fail-fast: false # Continue publishing other packages even if one fails
105+
steps:
106+
- name: Harden Runner
107+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
108+
with:
109+
egress-policy: audit
110+
111+
- name: Checkout repository
112+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
113+
114+
- name: Set up pnpm
115+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
116+
with:
117+
cache: true
118+
119+
- name: Setup Node.js
120+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
121+
with:
122+
node-version-file: '.nvmrc'
123+
registry-url: 'https://registry.npmjs.org'
124+
cache: pnpm
125+
126+
- name: Publish
127+
working-directory: packages/${{ matrix.package }}
128+
env:
129+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
130+
run: |
131+
# Create a unique version using the commit SHA as a prerelease identifier
132+
# This ensures we can publish multiple times from the same codebase with unique versions
133+
npm version --no-git-tag-version 1.0.1-$COMMIT_SHA
134+
# Publish the package to the npm registry with public access flag
135+
pnpm publish --access public --no-git-checks
136+
137+
- name: Notify on Manual Release
138+
if: ${{ github.event_name == 'workflow_dispatch' }}
139+
uses: rtCamp/action-slack-notify@e31e87e03dd19038e411e38ae27cbad084a90661 # 2.3.3
140+
env:
141+
SLACK_COLOR: '#43853D'
142+
SLACK_ICON: https://github.com/nodejs.png?size=48
143+
SLACK_TITLE: ':rocket: Package Published: ${{ matrix.package }}'
144+
SLACK_MESSAGE: |
145+
:package: *Package*: `${{ matrix.package }}` (<https://www.npmjs.com/package/@node-core/${{ matrix.package }}|View on npm>)
146+
:bust_in_silhouette: *Published by*: ${{ github.triggering_actor }}
147+
:octocat: *Commit*: <https://github.com/${{ github.repository }}/commit/${{ env.COMMIT_SHA }}|${{ env.COMMIT_SHA }}>
148+
SLACK_USERNAME: nodejs-bot
149+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

.github/workflows/translations-sync.yml

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ concurrency:
1818
permissions:
1919
contents: read
2020

21+
env:
22+
BRANCH_NAME: chore/crowdin
23+
2124
jobs:
2225
synchronize-with-crowdin:
2326
runs-on: ubuntu-latest
24-
outputs:
25-
pull_request_number: ${{ steps.crowdin_pr.outputs.pull_request_number }}
26-
2727
steps:
2828
- name: Harden Runner
2929
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
@@ -38,14 +38,13 @@ jobs:
3838
# see all the options at https://github.com/crowdin/github-action
3939
- name: Crowdin PR
4040
uses: crowdin/github-action@b8012bd5491b8aa8578b73ab5b5f5e7c94aaa6e2 # v2.7.0
41-
id: crowdin_pr
4241
with:
4342
# do not upload anything - this is a one-way operation download
4443
upload_sources: false
4544
upload_translations: false
4645
# the rest of this controls how the PR comes in with new translations
4746
download_translations: true
48-
localization_branch_name: chore/crowdin
47+
localization_branch_name: ${{ env.BRANCH_NAME }}
4948
create_pull_request: true
5049
pull_request_title: '[automated]: crowdin sync'
5150
pull_request_body: 'New Crowdin translations from the [Node.js Crowdin project](https://crowdin.com/project/nodejs-web)'
@@ -74,8 +73,7 @@ jobs:
7473
- name: Git Checkout
7574
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
7675
with:
77-
# Use the number from the output of crowdin/github-action
78-
ref: refs/pull/${{ needs.synchronize-with-crowdin.outputs.pull_request_number }}/head
76+
ref: ${{ env.BRANCH_NAME }}
7977
token: ${{ secrets.CROWDIN_GITHUB_BOT_TOKEN }}
8078

8179
- name: Restore Lint Cache
@@ -109,15 +107,12 @@ jobs:
109107
- name: Install packages
110108
run: pnpm install --frozen-lockfile
111109

112-
- name: Run `lint:md --fix`
113-
# This runs a specific version of ESLint with only the Translation Pages Globbing
114-
# This avoid that unrelated changes get linted/modified within this PR
115-
run: pnpm exec eslint "apps/site/pages/**/*.md?(x)" --fix --cache --cache-strategy=metadata --cache-file=apps/site/.eslintmdcache --config=apps/site/eslint.config.js
110+
- name: Run ESLint
111+
working-directory: apps/site
112+
run: pnpm lint:md --fix
116113

117-
- name: Run `prettier --write`
118-
# This runs a specific version of Prettier with only the Translation Pages Globbing
119-
# This avoid that unrelated changes get prettied/modified within this PR
120-
run: pnpm exec prettier "apps/site/{pages,i18n}/**/*.{json,md,mdx}" --check --write --cache --cache-strategy=metadata --cache-location=apps/site/.prettiercache
114+
- name: Run Prettier
115+
run: pnpm prettier:fix
121116

122117
- name: Push Changes back to Pull Request
123118
uses: stefanzweifel/git-auto-commit-action@b863ae1933cb653a53c021fe36dbb774e1fb9403 # v5.2.0

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ cache
3333

3434
# TypeScript
3535
tsconfig.tsbuildinfo
36-
3736
dist/
3837

3938
# Ignore the blog-data json that we generate during dev and build
@@ -43,3 +42,7 @@ apps/site/public/blog-data.json
4342
apps/site/.open-next
4443
apps/site/.wrangler
4544

45+
46+
## Playwright
47+
test-results
48+
playwright-report

0 commit comments

Comments
 (0)