From a0af662d783466c8354e5555011934e8b05c7035 Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Thu, 18 Sep 2025 12:51:22 +0100 Subject: [PATCH] CI: Separate platform-independent linter tasks Run these before platform-specific build/testing tasks --- .github/workflows/ci.yml | 51 +++++++++++++++++++++++----------------- package.json | 12 ++++++---- 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f126419..b777acb9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,9 +4,24 @@ on: - pull_request permissions: {} jobs: + lint: + permissions: + contents: read + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v5 + with: + node-version: "24" + - run: npm install --ignore-scripts --omit=optional + - run: npm run lint-cpp + - run: npm run lint-js + - run: npm run lint-licensing + - run: npm run lint-types build-native: permissions: contents: read + needs: lint name: "build-${{ matrix.platform }} [Node.js ${{ matrix.nodejs_version_major }}] ${{ matrix.package && '[package]' }}" runs-on: ${{ matrix.os }} container: ${{ matrix.container }} @@ -150,17 +165,14 @@ jobs: python-version: "3.12" - name: Dependencies (Node.js) if: "!contains(matrix.platform, 'linuxmusl')" - uses: actions/setup-node@v4 + uses: actions/setup-node@v5 with: node-version: ${{ matrix.nodejs_version }} architecture: ${{ matrix.nodejs_arch }} - uses: actions/checkout@v4 - - name: Install - run: npm install --build-from-source - - name: Test - run: npm test - - name: Populate npm package - if: matrix.package + - run: npm install --build-from-source + - run: npm run test-unit + - if: matrix.package run: npm run package-from-local-build - uses: actions/upload-artifact@v4 if: matrix.package @@ -172,6 +184,7 @@ jobs: build-linuxmusl-arm64: permissions: contents: read + needs: lint name: "build-linuxmusl-arm64 [Node.js ${{ matrix.nodejs_version_major }}] ${{ matrix.package && '[package]' }}" runs-on: ubuntu-24.04-arm container: @@ -199,12 +212,9 @@ jobs: - name: Dependencies run: apk add build-base git python3 font-noto --update-cache - uses: actions/checkout@v4 - - name: Install - run: npm install --build-from-source - - name: Test - run: npm test - - name: Populate npm package - if: matrix.package + - run: npm install --build-from-source + - run: npm run test-unit + - if: matrix.package run: npm run package-from-local-build - uses: actions/upload-artifact@v4 if: matrix.package @@ -216,6 +226,7 @@ jobs: build-qemu: permissions: contents: read + needs: lint name: "build-${{ matrix.platform }} [Node.js ${{ matrix.nodejs_version_major }}] [package]" runs-on: ubuntu-24.04 strategy: @@ -267,6 +278,7 @@ jobs: build-emscripten: permissions: contents: read + needs: lint name: "build-wasm32 [package]" runs-on: ubuntu-24.04 container: "emscripten/emsdk:4.0.14" @@ -275,11 +287,10 @@ jobs: - name: Dependencies run: apt-get update && apt-get install -y pkg-config - name: Dependencies (Node.js) - uses: actions/setup-node@v4 + uses: actions/setup-node@v5 with: node-version: "20" - - name: Install - run: emmake npm install --build-from-source + - run: emmake npm install --build-from-source - name: Verify emscripten versions match run: | EMSCRIPTEN_VERSION_LIBVIPS=$(node -p "require('@img/sharp-libvips-dev-wasm32/versions').emscripten") @@ -287,10 +298,8 @@ jobs: echo "libvips built with emscripten $EMSCRIPTEN_VERSION_LIBVIPS" echo "sharp built with emscripten $EMSCRIPTEN_VERSION_SHARP" test "$EMSCRIPTEN_VERSION_LIBVIPS" = "$EMSCRIPTEN_VERSION_SHARP" - - name: Test - run: emmake npm test - - name: Populate npm package - run: emmake npm run package-from-local-build + - run: emmake npm run test-unit + - run: emmake npm run package-from-local-build - uses: actions/upload-artifact@v4 with: name: wasm32 @@ -314,7 +323,7 @@ jobs: path: npm - name: Create npm workspace tarball run: tar -vcaf npm-workspace.tar.xz --directory npm --exclude=from-local-build.js . - - uses: actions/setup-node@v4 + - uses: actions/setup-node@v5 with: node-version: '24' - name: Create release notes diff --git a/package.json b/package.json index 39547c80..82f92e04 100644 --- a/package.json +++ b/package.json @@ -94,12 +94,14 @@ "scripts": { "install": "node install/check.js", "clean": "rm -rf src/build/ .nyc_output/ coverage/ test/fixtures/output.*", - "test": "npm run test-lint && npm run test-unit && npm run test-licensing && npm run test-types", - "test-lint": "semistandard && cpplint", - "test-unit": "nyc --reporter=lcov --reporter=text --check-coverage --branches=100 mocha", - "test-licensing": "license-checker --production --summary --onlyAllow=\"Apache-2.0;BSD;ISC;LGPL-3.0-or-later;MIT\"", + "test": "npm run lint && npm run test-unit", + "lint": "npm run lint-cpp && npm run lint-js && npm run lint-licensing && npm run lint-types", + "lint-cpp": "cpplint", + "lint-js": "semistandard", + "lint-licensing": "license-checker --production --summary --onlyAllow=\"Apache-2.0;BSD;ISC;LGPL-3.0-or-later;MIT\"", + "lint-types": "tsd", "test-leak": "./test/leak/leak.sh", - "test-types": "tsd", + "test-unit": "nyc --reporter=lcov --reporter=text --check-coverage --branches=100 mocha", "package-from-local-build": "node npm/from-local-build.js", "package-release-notes": "node npm/release-notes.js", "docs-build": "node docs/build.mjs",