Skip to content

refactor(ci): use commit lint action #2241

refactor(ci): use commit lint action

refactor(ci): use commit lint action #2241

Workflow file for this run

name: test
on:
merge_group:
push:
branches:
- main
pull_request:
branches:
- main
defaults:
run:
shell: bash
concurrency:
group: pr-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
build:
name: Jco Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: "latest"
- name: Install Rust
run: rustup update stable --no-self-update
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
with:
shared-key: jco-${{ hashFiles('Cargo.lock') }}
- name: Cache npm install
id: cache-node-modules
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package.json') }}
path: |
node_modules
- name: Install NPM packages
run: npm install
- name: Build
run: npm run build
- name: Upload Jco Build
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: jco-build
path: |
packages/jco/obj
test-jco:
name: Jco Test Suite
strategy:
matrix:
os:
- ubuntu-22.04 # https://github.com/puppeteer/puppeteer/issues/12818#issuecomment-2593659514
- windows-latest
- macos-latest
node:
- 18.x
- 20.x
- latest
include:
- os: windows-latest
weval-bin-path: .weval-bin/weval.exe
- os: ubuntu-22.04
weval-bin-path: .weval-bin/weval
- os: macos-latest
weval-bin-path: .weval-bin/weval
exclude:
- os: macos-latest
node: 20.x
- os: macos-latest
node: 18.x
- os: windows-latest
node: latest
- os: windows-latest
node: 18.x
runs-on: ${{ matrix.os }}
needs:
- build
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: ${{ matrix.node }}
# Determine weval version
- name: Determine weval version
id: weval-meta
shell: bash
run: |
export WEVAL_LATEST_URL=`curl -Ls -o /dev/null -w %{url_effective} https://github.com/bytecodealliance/weval/releases/latest`
export WEVAL_VERSION=${WEVAL_LATEST_URL#https://github.com/bytecodealliance/weval/releases/tag/}
echo -e "version=$WEVAL_VERSION" >> $GITHUB_OUTPUT
# Use cached weval bin if present
- name: Cache weval bin
id: cache-weval-bin
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: .weval-bin
key: weval-bin-${{ steps.weval-meta.outputs.version }}-${{ matrix.os }}
# (no cached weval bin) download weval release
- if: ${{ steps.cache-weval-bin.outputs.cache-hit != 'true' && matrix.os == 'ubuntu-latest' }}
run: |
curl -LO https://github.com/bytecodealliance/weval/releases/download/${{ steps.weval-meta.outputs.version }}/weval-${{ steps.weval-meta.outputs.version }}-x86_64-linux.tar.xz
tar -xvJf weval-${{ steps.weval-meta.outputs.version }}-x86_64-linux.tar.xz
mv weval-${{ steps.weval-meta.outputs.version }}-x86_64-linux/weval .weval-bin
- if: ${{ steps.cache-weval-bin.outputs.cache-hit != 'true' && matrix.os == 'windows-latest' }}
run: |
curl -LO https://github.com/bytecodealliance/weval/releases/download/${{ steps.weval-meta.outputs.version }}/weval-${{ steps.weval-meta.outputs.version }}-x86_64-windows.zip
unzip weval-${{ steps.weval-meta.outputs.version }}-x86_64-windows.zip
mv weval-${{ steps.weval-meta.outputs.version }}-x86_64-windows .weval-bin
- if: ${{ steps.cache-weval-bin.outputs.cache-hit != 'true' && matrix.os == 'macos-latest' }}
run: |
curl -LO https://github.com/bytecodealliance/weval/releases/download/${{ steps.weval-meta.outputs.version }}/weval-${{ steps.weval-meta.outputs.version }}-aarch64-macos.tar.xz
tar -xvJf weval-${{ steps.weval-meta.outputs.version }}-aarch64-macos.tar.xz
mkdir .weval-bin
mv weval-${{ steps.weval-meta.outputs.version }}-aarch64-macos/weval .weval-bin/
- name: Cache npm install
id: cache-npm
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package.json') }}
path: |
node_modules
- name: Install NPM packages
run: |
npm install
- name: Cache puppeteer install
id: cache-puppeteer
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
key: puppeteer-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pacakges/jco/package.json') }}
path: |
/home/runner/.cache/puppeteer
- name: Install puppeteer
if: steps.cache-puppeteer.outputs.cache-hit != 'true'
run: |
npx puppeteer browsers install chrome
- name: Download Build
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: jco-build
path: |
packages/jco/obj
- name: Test LTS Node.js
if: matrix.node == '18.x' || matrix.node == '20.x'
working-directory: packages/jco
run: |
npm run test:lts -- --maxWorkers 4 --minWorkers 2 --maxConcurrency 2
- name: Test Latest Node.js
if: matrix.node == 'latest'
working-directory: packages/jco
env:
WEVAL_BIN_PATH: ${{ matrix.weval-bin-path }}
run: |
npm run test -- --maxWorkers 4 --minWorkers 2 --maxConcurrency 2
build-wasi-tests:
name: WASI Test Generation
runs-on: ubuntu-latest
outputs:
cache-key: ${{ steps.cache-wasi-tests.outputs.cache-primary-key }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: recursive
- name: Cache WASI Tests
id: cache-wasi-tests
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: crates/jco/tests/gen
key: wasi-${{ hashFiles('xtask/src/generate/preview2_tests.rs', 'submodules/wasmtime/Cargo.lock') }}
- name: Install Rust
if: steps.cache-wasi-tests.outputs.cache-hit != 'true'
run: rustup update stable --no-self-update && rustup default stable
- name: Install wasm32-unknown-unknown target
if: steps.cache-wasi-tests.outputs.cache-hit != 'true'
run: rustup target add wasm32-unknown-unknown
- name: Install wasm32-wasip1 target
if: steps.cache-wasi-tests.outputs.cache-hit != 'true'
run: rustup target add wasm32-wasip1
- name: Install wasm-tools
if: steps.cache-wasi-tests.outputs.cache-hit != 'true'
run: cargo install wasm-tools
- name: Generate WASI Tests
if: steps.cache-wasi-tests.outputs.cache-hit != 'true'
run: cargo xtask generate preview2-tests
- name: Upload Generated WASI Tests
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: wasi-tests
path: crates/jco/tests/gen
test-wasi-deno:
name: Jco Deno WASI Conformance Tests
runs-on: "ubuntu-latest"
needs:
- build
- build-wasi-tests
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: "latest"
- uses: denoland/setup-deno@e95548e56dfa95d4e1a28d6f422fafe75c4c26fb # v2.0.3
with:
deno-version: v1.x
- name: Cache npm install
id: cache-npm
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('packages/jco/package.json') }}
path: |
node_modules
- name: Install NPM packages
run: npm install
- name: Download Build
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: jco-build
path: |
packages/jco/obj
- name: Download WASI Tests
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: wasi-tests
path: crates/jco/tests/gen
- name: WASI Preview 2 Conformance
run: cargo test deno_
test-wasi:
name: Jco Node.js WASI Conformance Tests
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
node:
- 18.x
- 20.x
- latest
exclude:
- os: macos-latest
node: 20.x
- os: macos-latest
node: 18.x
- os: windows-latest
node: 20.x
- os: windows-latest
node: 18.x
fail-fast: false
runs-on: ${{ matrix.os }}
needs:
- build
- build-wasi-tests
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: ${{ matrix.node }}
- name: Cache npm install
id: cache-npm
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package.json') }}
path: |
node_modules
- name: Install NPM packages
run: npm install
- name: Download Build
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: jco-build
path: |
packages/jco/obj
- name: Download WASI Tests
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: wasi-tests
path: crates/jco/tests/gen
- name: WASI Preview 2 Conformance
run: cargo test node_
test-preview2-shims:
name: Test Preview2 Shims
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Cache npm install
id: cache-npm
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package.json') }}
path: |
node_modules
- name: Install NPM packages
run: npm install
- name: Test Workspaces
run: npm run test --workspace packages/preview2-shim
eslint:
name: ESLint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Cache npm install
id: cache-npm
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package.json') }}
path: |
node_modules
- name: Install NPM packages
run: npm install
- name: Lint
run: npm run lint
rustfmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Rust
run: rustup update stable && rustup default stable && rustup component add rustfmt
- name: Remove tests mod
run: rm -r crates/jco/tests/mod.rs
- name: Format source code
run: cargo fmt -- --check
examples:
name: Example ${{ matrix.project.name }}
needs:
- build
runs-on: ubuntu-latest
strategy:
matrix:
wac:
- version: 0.6.0
node:
- version: 22.5.1
project:
- name: add
workspace: examples/components/add
- name: adder
workspace: examples/components/adder
- name: string-reverse
workspace: examples/components/string-reverse
- name: string-reverse-upper
workspace: examples/components/string-reverse-upper
is-composed: true
- name: webidl-book-library
workspace: examples/components/webidl-book-library
requires-crates:
- webidl2wit-cli
- name: node-fetch
workspace: examples/components/node-fetch
- name: http-hello-world
workspace: examples/components/http-hello-world
- name: http-server-fetch-handler
workspace: examples/components/http-server-fetch-handler
- name: http-server-hono
workspace: examples/components/http-server-hono
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: ${{ matrix.node.version }}
- name: Download Build
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: jco-build
path: |
packages/jco/obj
- name: Install Rust
if: ${{ matrix.project.requires-crates != '[]' }}
run: rustup update stable --no-self-update && rustup default stable
- name: Install required rust crates
if: ${{ matrix.project.requires-crates != '[]' }}
uses: taiki-e/install-action@84c20235bedc3797c7e1ddf685c574a4a6c666da # v2
with:
tool: ${{ join(matrix.project.requires-crates, ',') }}
- name: Install wac
if: ${{ matrix.project.is-composed }}
uses: jaxxstorm/action-install-gh-release@6096f2a2bbfee498ced520b6922ac2c06e990ed2 # v2.1.0
with:
repo: bytecodealliance/wac
tag: v${{ matrix.wac.version }}
extension-matching: disable
rename-to: wac
chmod: 0755
- name: Cache npm install
id: cache-npm
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package.json') }}
path: |
node_modules
- run: npm install
- name: Run all script for (${{ matrix.project.name }})
working-directory: ${{ matrix.project.dir }}
run: npm run all --workspace ${{ matrix.project.workspace }}