mirror of
https://github.com/lovell/sharp.git
synced 2025-12-06 03:51:40 +01:00
Uses the recommended rules apart from complexity/useArrowFunction, which would affect about 1700 lines of code with little benefit right now. This is something that can be addressed over time.
346 lines
12 KiB
YAML
346 lines
12 KiB
YAML
name: CI
|
|
on:
|
|
- push
|
|
- 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
|
|
- 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 }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- os: ubuntu-24.04
|
|
container: rockylinux:8
|
|
nodejs_arch: x64
|
|
nodejs_version: "^18.17.0"
|
|
nodejs_version_major: 18
|
|
platform: linux-x64
|
|
package: true
|
|
- os: ubuntu-24.04
|
|
container: rockylinux:8
|
|
nodejs_arch: x64
|
|
nodejs_version: "^20.3.0"
|
|
nodejs_version_major: 20
|
|
platform: linux-x64
|
|
- os: ubuntu-24.04
|
|
container: rockylinux:8
|
|
nodejs_arch: x64
|
|
nodejs_version: "^22.9.0"
|
|
nodejs_version_major: 22
|
|
platform: linux-x64
|
|
- os: ubuntu-24.04
|
|
container: node:18-alpine3.17
|
|
nodejs_version_major: 18
|
|
platform: linuxmusl-x64
|
|
package: true
|
|
- os: ubuntu-24.04
|
|
container: node:20-alpine3.18
|
|
nodejs_version_major: 20
|
|
platform: linuxmusl-x64
|
|
- os: ubuntu-24.04
|
|
container: node:22-alpine3.20
|
|
nodejs_version_major: 22
|
|
platform: linuxmusl-x64
|
|
- os: ubuntu-24.04-arm
|
|
container: arm64v8/rockylinux:8
|
|
nodejs_arch: arm64
|
|
nodejs_version: "^18.17.0"
|
|
nodejs_version_major: 18
|
|
platform: linux-arm64
|
|
package: true
|
|
- os: ubuntu-24.04-arm
|
|
container: arm64v8/rockylinux:8
|
|
nodejs_arch: arm64
|
|
nodejs_version: "^20.3.0"
|
|
nodejs_version_major: 20
|
|
platform: linux-arm64
|
|
- os: macos-13
|
|
nodejs_arch: x64
|
|
nodejs_version: "^18.17.0"
|
|
nodejs_version_major: 18
|
|
platform: darwin-x64
|
|
package: true
|
|
- os: macos-13
|
|
nodejs_arch: x64
|
|
nodejs_version: "^20.3.0"
|
|
nodejs_version_major: 20
|
|
platform: darwin-x64
|
|
- os: macos-13
|
|
nodejs_arch: x64
|
|
nodejs_version: "^22.9.0"
|
|
nodejs_version_major: 22
|
|
platform: darwin-x64
|
|
- os: macos-14
|
|
nodejs_arch: arm64
|
|
nodejs_version: "^18.17.0"
|
|
nodejs_version_major: 18
|
|
platform: darwin-arm64
|
|
package: true
|
|
- os: macos-14
|
|
nodejs_arch: arm64
|
|
nodejs_version: "^20.3.0"
|
|
nodejs_version_major: 20
|
|
platform: darwin-arm64
|
|
- os: macos-14
|
|
nodejs_arch: arm64
|
|
nodejs_version: "^22.9.0"
|
|
nodejs_version_major: 22
|
|
platform: darwin-arm64
|
|
- os: windows-2022
|
|
nodejs_arch: x86
|
|
nodejs_version: "18.18.2" # pinned to avoid 18.19.0 and npm 10
|
|
nodejs_version_major: 18
|
|
platform: win32-ia32
|
|
package: true
|
|
- os: windows-2022
|
|
nodejs_arch: x86
|
|
nodejs_version: "^20.3.0"
|
|
nodejs_version_major: 20
|
|
platform: win32-ia32
|
|
- os: windows-2022
|
|
nodejs_arch: x86
|
|
nodejs_version: "^22.9.0"
|
|
nodejs_version_major: 22
|
|
platform: win32-ia32
|
|
- os: windows-2022
|
|
nodejs_arch: x64
|
|
nodejs_version: "^18.17.0"
|
|
nodejs_version_major: 18
|
|
platform: win32-x64
|
|
package: true
|
|
- os: windows-2022
|
|
nodejs_arch: x64
|
|
nodejs_version: "^20.3.0"
|
|
nodejs_version_major: 20
|
|
platform: win32-x64
|
|
- os: windows-2022
|
|
nodejs_arch: x64
|
|
nodejs_version: "^22.9.0"
|
|
nodejs_version_major: 22
|
|
platform: win32-x64
|
|
- os: windows-11-arm
|
|
nodejs_arch: arm64
|
|
nodejs_version: "^20.3.0"
|
|
nodejs_version_major: 20
|
|
platform: win32-arm64
|
|
package: true
|
|
- os: windows-11-arm
|
|
nodejs_arch: arm64
|
|
nodejs_version: "^22.9.0"
|
|
nodejs_version_major: 22
|
|
platform: win32-arm64
|
|
steps:
|
|
- name: Dependencies (Rocky Linux glibc)
|
|
if: contains(matrix.container, 'rockylinux')
|
|
run: |
|
|
dnf install -y gcc-toolset-14-gcc-c++ make git python3.12 fontconfig google-noto-sans-fonts
|
|
echo "/opt/rh/gcc-toolset-14/root/usr/bin" >> $GITHUB_PATH
|
|
- name: Dependencies (Linux musl)
|
|
if: contains(matrix.container, 'alpine')
|
|
run: apk add build-base git python3 font-noto --update-cache
|
|
- name: Dependencies (Python 3.11 - macOS, Windows)
|
|
if: contains(matrix.os, 'macos') || contains(matrix.os, 'windows')
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
- name: Dependencies (Node.js)
|
|
if: "!contains(matrix.platform, 'linuxmusl')"
|
|
uses: actions/setup-node@v5
|
|
with:
|
|
node-version: ${{ matrix.nodejs_version }}
|
|
architecture: ${{ matrix.nodejs_arch }}
|
|
- uses: actions/checkout@v4
|
|
- 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
|
|
with:
|
|
name: ${{ matrix.platform }}
|
|
path: npm/${{ matrix.platform }}
|
|
retention-days: 1
|
|
if-no-files-found: error
|
|
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:
|
|
image: ${{ matrix.container }}
|
|
volumes:
|
|
- /opt:/opt:rw,rshared
|
|
- /opt:/__e/node20:ro,rshared
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- container: node:18-alpine3.17
|
|
nodejs_version_major: 18
|
|
package: true
|
|
- container: node:20-alpine3.18
|
|
nodejs_version_major: 20
|
|
steps:
|
|
- name: Allow Linux musl containers on ARM64 runners # https://github.com/actions/runner/issues/801#issuecomment-2394425757
|
|
shell: sh
|
|
run: |
|
|
sed -i "/^ID=/s/alpine/NotpineForGHA/" /etc/os-release
|
|
apk add nodejs --update-cache
|
|
mkdir /opt/bin
|
|
ln -s /usr/bin/node /opt/bin/node
|
|
- name: Dependencies
|
|
run: apk add build-base git python3 font-noto --update-cache
|
|
- uses: actions/checkout@v4
|
|
- 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
|
|
with:
|
|
name: linuxmusl-arm64
|
|
path: npm/linuxmusl-arm64
|
|
retention-days: 1
|
|
if-no-files-found: error
|
|
build-qemu:
|
|
permissions:
|
|
contents: read
|
|
needs: lint
|
|
name: "build-${{ matrix.platform }} [Node.js ${{ matrix.nodejs_version_major }}] [package]"
|
|
runs-on: ubuntu-24.04
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- platform: linux-arm
|
|
distro: bullseye
|
|
run_on_arch: armv6
|
|
nodejs_arch: armv6l
|
|
nodejs_hostname: unofficial-builds.nodejs.org
|
|
nodejs_version: "18.17.0"
|
|
nodejs_version_major: 18
|
|
- platform: linux-s390x
|
|
distro: bookworm
|
|
run_on_arch: s390x
|
|
nodejs_arch: s390x
|
|
nodejs_hostname: nodejs.org
|
|
nodejs_version: "18.17.0"
|
|
nodejs_version_major: 18
|
|
- platform: linux-ppc64
|
|
distro: bookworm
|
|
run_on_arch: ppc64le
|
|
nodejs_arch: ppc64le
|
|
nodejs_hostname: nodejs.org
|
|
nodejs_version: "18.17.0"
|
|
nodejs_version_major: 18
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: uraimo/run-on-arch-action@v3
|
|
with:
|
|
arch: ${{ matrix.run_on_arch }}
|
|
distro: ${{ matrix.distro }}
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y curl g++ git libatomic1 make python3 xz-utils
|
|
mkdir /opt/nodejs
|
|
curl --silent https://${{ matrix.nodejs_hostname }}/download/release/v${{ matrix.nodejs_version}}/node-v${{ matrix.nodejs_version}}-linux-${{ matrix.nodejs_arch }}.tar.xz | tar xJC /opt/nodejs --strip-components=1
|
|
export PATH=$PATH:/opt/nodejs/bin
|
|
npm install --build-from-source
|
|
npx mocha --no-config --spec=test/unit/io.js --timeout=30000
|
|
npm run package-from-local-build
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ matrix.platform }}
|
|
path: npm/${{ matrix.platform }}
|
|
retention-days: 1
|
|
if-no-files-found: error
|
|
build-emscripten:
|
|
permissions:
|
|
contents: read
|
|
needs: lint
|
|
name: "build-wasm32 [package]"
|
|
runs-on: ubuntu-24.04
|
|
container: "emscripten/emsdk:4.0.14"
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Dependencies
|
|
run: apt-get update && apt-get install -y pkg-config
|
|
- name: Dependencies (Node.js)
|
|
uses: actions/setup-node@v5
|
|
with:
|
|
node-version: "20"
|
|
- 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")
|
|
EMSCRIPTEN_VERSION_SHARP=$(emcc -dumpversion)
|
|
echo "libvips built with emscripten $EMSCRIPTEN_VERSION_LIBVIPS"
|
|
echo "sharp built with emscripten $EMSCRIPTEN_VERSION_SHARP"
|
|
test "$EMSCRIPTEN_VERSION_LIBVIPS" = "$EMSCRIPTEN_VERSION_SHARP"
|
|
- run: emmake npm run test-unit
|
|
- run: emmake npm run package-from-local-build
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: wasm32
|
|
path: npm/wasm32
|
|
retention-days: 1
|
|
if-no-files-found: error
|
|
release:
|
|
permissions:
|
|
contents: write
|
|
id-token: write
|
|
runs-on: ubuntu-24.04
|
|
needs:
|
|
- build-native
|
|
- build-linuxmusl-arm64
|
|
- build-qemu
|
|
- build-emscripten
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
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@v5
|
|
with:
|
|
node-version: '24'
|
|
- name: Create release notes
|
|
run: npm run package-release-notes
|
|
- name: Create GitHub release for tag
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
uses: ncipollo/release-action@v1
|
|
with:
|
|
artifacts: npm-workspace.tar.xz
|
|
artifactContentType: application/x-xz
|
|
prerelease: ${{ contains(github.ref, '-rc') }}
|
|
makeLatest: ${{ !contains(github.ref, '-rc') }}
|
|
bodyFile: release-notes.md
|
|
- name: Publish platform-specific npm packages
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
run: cd npm && npm publish --workspaces --tag=${{ contains(github.ref, '-rc') && 'next' || 'latest' }}
|
|
- name: Publish sharp npm package
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
run: npm publish --tag=${{ contains(github.ref, '-rc') && 'next' || 'latest' }}
|