Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
working-directory: ./website

steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v6
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 22
cache: "npm"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ jobs:
cache: npm

- name: Download release package
uses: actions/download-artifact@v7
uses: actions/download-artifact@v8
with:
name: npm-package
path: ./release-package
Expand Down
98 changes: 81 additions & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
name: Node.js CI

on: [push, pull_request]
on:
push:
branches:
- master
pull_request:

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [22.x, 24.x]

steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v7

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
- name: Use Node.js 24
uses: actions/setup-node@v7
with:
node-version: ${{ matrix.node-version }}
node-version: 24.x
cache: "npm"

- name: Install dependencies
Expand All @@ -30,18 +30,82 @@ jobs:
- name: Run test with coverage
run: npm run coverage

- name: Build package
run: npm run build

- name: Pack package
run: npm pack --ignore-scripts

- name: Upload package artifact
uses: actions/upload-artifact@v7
with:
name: npm-package
path: "*.tgz"
if-no-files-found: error

- name: Coveralls
uses: coverallsapp/github-action@v2
with:
parallel: true
flag-name: run-${{ matrix.node-version }}

finish:
compatibility:
name: Package compatibility (Node.js ${{ matrix.node-version }})
needs: build
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
node-version: [20.x, 22.x, 24.x, 26.x]

steps:
- name: Close parallel build
uses: coverallsapp/github-action@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v7
with:
node-version: ${{ matrix.node-version }}
package-manager-cache: false

- name: Download package artifact
uses: actions/download-artifact@v8
with:
parallel-finished: true
carryforward: "run-22.x,run-24.x"
name: npm-package
path: ${{ runner.temp }}/npm-package

- name: Install package in consumer environment
env:
CONSUMER_DIR: ${{ runner.temp }}/x509-shadow-consumer
PACKAGE_DIR: ${{ runner.temp }}/npm-package
run: |
PACKAGE_TGZ=$(find "$PACKAGE_DIR" -maxdepth 1 -name '*.tgz' -print -quit)
test -n "$PACKAGE_TGZ"

mkdir -p "$CONSUMER_DIR"
cd "$CONSUMER_DIR"
npm init --yes
npm install --ignore-scripts --no-save --no-audit --no-fund "$PACKAGE_TGZ" reflect-metadata

- name: Check CommonJS consumer
working-directory: ${{ runner.temp }}/x509-shadow-consumer
run: |
node - <<'NODE'
require("reflect-metadata");
const x509 = require("@peculiar/x509");

if (typeof x509.X509Certificate !== "function") {
throw new Error("CommonJS consumer failed to load @peculiar/x509");
}

console.log("CommonJS consumer OK");
NODE

- name: Check ESM consumer
working-directory: ${{ runner.temp }}/x509-shadow-consumer
run: |
node --input-type=module - <<'NODE'
import "reflect-metadata";
const x509 = await import("@peculiar/x509");

if (typeof x509.X509Certificate !== "function") {
throw new Error("ESM consumer failed to load @peculiar/x509");
}

console.log("ESM consumer OK");
NODE