Skip to content

Commit a67f0d0

Browse files
committed
[wip] more comparisons
1 parent 9ddf8f9 commit a67f0d0

File tree

6 files changed

+258
-345
lines changed

6 files changed

+258
-345
lines changed

.github/workflows/compare-builds.yml

Lines changed: 0 additions & 130 deletions
This file was deleted.
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
name: Generate Docs
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
prepare:
19+
runs-on: ubuntu-latest
20+
outputs:
21+
sha: ${{ steps.push.outputs.sha || steps.pr.outputs.sha }}
22+
base-run: ${{ steps.main.outputs.run_id }}
23+
steps:
24+
- name: Harden Runner
25+
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
26+
with:
27+
egress-policy: audit
28+
29+
# If we are running from the main branch (a non-pull_request event), we
30+
# want the latest SHA from nodejs/node
31+
- id: push
32+
if: ${{ github.event_name != 'pull_request' }}
33+
run: |
34+
SHA=$(git ls-remote https://github.com/nodejs/node. git HEAD | awk '{print $1}')
35+
echo "$SHA" > commit
36+
echo "sha=$SHA" >> "$GITHUB_OUTPUT"
37+
38+
- name: Upload metadata artifact
39+
if: ${{ github.event_name != 'pull_request' }}
40+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
41+
with:
42+
name: commit
43+
path: commit
44+
45+
# If we are running from a PR (a pull_request event), we
46+
# want the SHA used by the most recent `push` run
47+
- name: Get latest `main` run
48+
if: ${{ github.event_name == 'pull_request' }}
49+
id: main
50+
env:
51+
WORKFLOW_ID: ${{ github.workflow_ref }}
52+
BASE_SHA: ${{ github.event.pull_request.base.sha }}
53+
GH_TOKEN: ${{ github.token }}
54+
run: |
55+
ID=$(gh run list -c $GITHUB_SHA -w $WORKFLOW_ID -L 1 --json databaseId --jq ".[]. databaseId")
56+
echo "run_id=$ID" >> $GITHUB_OUTPUT
57+
58+
- name: Download metadata artifact
59+
if: ${{ github.event_name == 'pull_request' }}
60+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
61+
with:
62+
name: commit
63+
run-id: ${{ steps.main.outputs.run_id }}
64+
github-token: ${{ secrets.GITHUB_TOKEN }}
65+
66+
- id: pr
67+
if: ${{ github.event_name == 'pull_request' }}
68+
run: |
69+
SHA=$(cat commit)
70+
echo "sha=$SHA" >> "$GITHUB_OUTPUT"
71+
72+
generate:
73+
runs-on: ubuntu-latest
74+
needs: prepare
75+
strategy:
76+
matrix:
77+
include:
78+
- target: man-page
79+
input: './node/doc/api/cli.md'
80+
- target: addon-verify
81+
input: './node/doc/api/addons.md'
82+
- target: api-links
83+
input: './node/lib/*.js'
84+
- target: orama-db
85+
input: './node/doc/api/*.md'
86+
- target: json-simple
87+
input: './node/doc/api/*.md'
88+
- target: legacy-json
89+
input: './node/doc/api/*.md'
90+
compare: true
91+
- target: legacy-html
92+
input: './node/doc/api/*.md'
93+
- target: web
94+
input: './node/doc/api/*.md'
95+
compare: true
96+
- target: llms-txt
97+
input: './node/doc/api/*.md'
98+
fail-fast: false
99+
100+
steps:
101+
- name: Harden Runner
102+
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
103+
with:
104+
egress-policy: audit
105+
106+
- name: Git Checkout
107+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
108+
with:
109+
persist-credentials: false
110+
111+
- name: Git Checkout
112+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
113+
with:
114+
persist-credentials: false
115+
repository: nodejs/node
116+
ref: ${{ needs.prepare.outputs.sha }}
117+
sparse-checkout: |
118+
doc/api
119+
lib
120+
.
121+
path: node
122+
123+
- name: Setup Node.js
124+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
125+
with:
126+
node-version-file: '.nvmrc'
127+
cache: 'npm'
128+
129+
- name: Install dependencies
130+
run: npm ci
131+
132+
- name: Create output directory
133+
run: mkdir -p out/${{ matrix.target }}
134+
135+
- name: Generate ${{ matrix.target }}
136+
run: |
137+
node bin/cli.mjs generate \
138+
-t ${{ matrix.target }} \
139+
-i "${{ matrix.input }}" \
140+
-o out \
141+
-c ./node/CHANGELOG.md \
142+
--index ./node/doc/api/index.md \
143+
--log-level debug
144+
145+
- name: Download base branch artifact
146+
if: ${{ matrix.compare && needs.prepare.outputs.base-run }}
147+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
148+
with:
149+
name: ${{ matrix.target }}
150+
path: base
151+
run-id: ${{ needs.prepare.outputs.base-run }}
152+
github-token: ${{ secrets.GITHUB_TOKEN }}
153+
154+
- name: Compare to base branch
155+
if: ${{ matrix.compare && needs.prepare.outputs.base-run }}
156+
run: |
157+
node scripts/compare-builds/${{ matrix.target }}.mjs > out/comparison.txt
158+
159+
- name: Upload ${{ matrix.target }} artifacts
160+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
161+
with:
162+
name: ${{ matrix.target }}
163+
path: out

.github/workflows/generate.yml

Lines changed: 0 additions & 91 deletions
This file was deleted.

0 commit comments

Comments
 (0)