Skip to content

Commit

Permalink
Enable CI
Browse files Browse the repository at this point in the history
  • Loading branch information
jakebailey committed May 10, 2024
1 parent 983a8e1 commit 423f584
Showing 1 changed file with 55 additions and 12 deletions.
67 changes: 55 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,12 @@ jobs:
- macos-14
node-version:
- '22'
- '20'
- '18'
- '16'
- '14'
bundle:
- 'true'
include:
- node-version: '*'
- node-version: '22'
bundle: false
os: ubuntu-latest
exclude:
# No Node 14 on ARM macOS
- node-version: '14'
os: macos-14

runs-on: ${{ matrix.os }}
name: Test Node ${{ matrix.node-version }} on ${{ matrix.os }}${{ (!matrix.bundle && ' with --no-bundle') || '' }}
Expand All @@ -55,19 +47,34 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
check-latest: true

- run: |
echo "value=--no-warnings=ExperimentalWarning --experimental-require-module --require $(node -e 'console.log(path.resolve("patchProcessGetBuiltin.cjs"))')" >> "$GITHUB_OUTPUT"
name: Enable require(ESM) and process.getBuiltinModule polyfill
id: node-options
- name: Verify that process.getBuiltinModule is available
run: node -e 'if (process.getBuiltinModule) { console.log(process.getBuiltinModule) } else { throw new Error("process.getBuiltinModule is not available") }'
env:
NODE_OPTIONS: ${{ steps.node-options.outputs.value }}

- run: npm ci

- name: Tests
id: test
# run tests, but lint separately
run: npm run test -- --no-lint --bundle=${{ matrix.bundle }}
env:
NODE_OPTIONS: ${{ steps.node-options.outputs.value }}

- name: Print baseline diff on failure
if: ${{ failure() && steps.test.conclusion == 'failure' }}
run: |
npx hereby baseline-accept
git add tests/baselines/reference
git diff --staged --exit-code
env:
NODE_OPTIONS: ${{ steps.node-options.outputs.value }}

lint:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -145,6 +152,12 @@ jobs:
with:
node-version: '*'
check-latest: true

- run: |
echo "value=--no-warnings=ExperimentalWarning --experimental-require-module --require $(node -e 'console.log(path.resolve("patchProcessGetBuiltin.cjs"))')" >> "$GITHUB_OUTPUT"
name: Enable require(ESM) and process.getBuiltinModule polyfill
id: node-options
- run: |
npm --version
# corepack enable npm
Expand All @@ -154,12 +167,16 @@ jobs:
- run: npm ci

- run: npx hereby lkg
env:
NODE_OPTIONS: ${{ steps.node-options.outputs.value }}
- run: |
node ./scripts/addPackageJsonGitHead.mjs package.json
npm pack
mv typescript*.tgz typescript.tgz
echo "package=$PWD/typescript.tgz" >> "$GITHUB_OUTPUT"
echo "package=$(pwd)/typescript.tgz" >> "$GITHUB_OUTPUT"
id: pack
env:
NODE_OPTIONS: ${{ steps.node-options.outputs.value }}
- name: Smoke test
run: |
Expand All @@ -175,6 +192,8 @@ jobs:
node $GITHUB_WORKSPACE/scripts/checkModuleFormat.mjs typescript
node $GITHUB_WORKSPACE/scripts/checkModuleFormat.mjs typescript/lib/tsserverlibrary
env:
NODE_OPTIONS: ${{ steps.node-options.outputs.value }}

package-size:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -243,18 +262,30 @@ jobs:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: '*'
node-version: '22'
check-latest: true

- run: |
echo "value=--no-warnings=ExperimentalWarning --experimental-require-module --require $(node -e 'console.log(path.resolve("patchProcessGetBuiltin.cjs"))')" >> "$GITHUB_OUTPUT"
name: Enable require(ESM) and process.getBuiltinModule polyfill
id: node-options
- run: npm ci

- name: Build tsc
run: npx hereby tsc
env:
NODE_OPTIONS: ${{ steps.node-options.outputs.value }}

- name: Clean
run: npx hereby clean-src
env:
NODE_OPTIONS: ${{ steps.node-options.outputs.value }}

- name: Self build
run: npx hereby build-src --built
env:
NODE_OPTIONS: ${{ steps.node-options.outputs.value }}

baselines:
runs-on: ubuntu-latest
Expand All @@ -263,20 +294,30 @@ jobs:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: '*'
node-version: '22'
check-latest: true

- run: |
echo "value=--no-warnings=ExperimentalWarning --experimental-require-module --require $(node -e 'console.log(path.resolve("patchProcessGetBuiltin.cjs"))')" >> "$GITHUB_OUTPUT"
name: Enable require(ESM) and process.getBuiltinModule polyfill
id: node-options
- run: npm ci

- name: Remove all baselines
run: rm -rf tests/baselines/reference

- name: Run tests
run: npm test &> /dev/null || exit 0
env:
NODE_OPTIONS: ${{ steps.node-options.outputs.value }}

- name: Accept baselines
run: |
npx hereby baseline-accept
git add tests/baselines/reference
env:
NODE_OPTIONS: ${{ steps.node-options.outputs.value }}

- name: Check baselines
id: check-baselines
Expand All @@ -295,6 +336,8 @@ jobs:
git diff --staged > fix_baselines.patch
exit 1
fi
env:
NODE_OPTIONS: ${{ steps.node-options.outputs.value }}

- name: Upload baseline diff artifact
if: ${{ failure() && steps.check-baselines.conclusion == 'failure' }}
Expand Down

0 comments on commit 423f584

Please sign in to comment.