Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

New patch release for v4 #907

New patch release for v4

New patch release for v4 #907

Workflow file for this run

name: Check
on:
pull_request: ~
push:
branches:
- main
- v4
permissions: read-all
jobs:
action-types:
name: Action Types
runs-on: ubuntu-latest
steps:
- name: Harden runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
github.com:443
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Validate Action Types
uses: krzema12/github-actions-typing@c1af3441a3e80d0010be36aa0874f157a15f6a7f # v1.0.2
build:
name: Build
runs-on: ubuntu-22.04
steps:
- name: Harden runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.github.com:443
artifactcache.actions.githubusercontent.com:443
github.com:443
nodejs.org:443
objects.githubusercontent.com:443
registry.npmjs.org:443
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
cache: npm
node-version-file: .nvmrc
- name: Install dependencies
run: npm clean-install
- name: Build standalone JavaScript file
run: npm run build
codeql:
name: CodeQL
runs-on: ubuntu-22.04
permissions:
security-events: write # To upload CodeQL results
steps:
- name: Harden runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
actions-results-receiver-production.githubapp.com:443
api.github.com:443
ghcr.io:443
github.com:443
objects.githubusercontent.com:443
pkg-containers.githubusercontent.com:443
uploads.github.com:443
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Initialize CodeQL
uses: github/codeql-action/init@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9
with:
config-file: ./.github/codeql-config.yml
languages: javascript
- name: Perform CodeQL analysis
uses: github/codeql-action/analyze@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9
licenses:
name: Licenses
runs-on: ubuntu-22.04
steps:
- name: Harden runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.github.com:443
artifactcache.actions.githubusercontent.com:443
github.com:443
nodejs.org:443
objects.githubusercontent.com:443
registry.npmjs.org:443
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
cache: npm
node-version-file: .nvmrc
- name: Install dependencies
run: npm clean-install
- name: Check licenses
run: npm run license-check
lint:
name: Lint
runs-on: ubuntu-22.04
steps:
- name: Harden runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.github.com:443
artifactcache.actions.githubusercontent.com:443
auth.docker.io:443
docker.io:443
fulcio.sigstore.dev:443
github.com:443
gitlab.com:443
nodejs.org:443
objects.githubusercontent.com:443
production.cloudflare.docker.com:443
registry-1.docker.io:443
registry.npmjs.org:443
rekor.sigstore.dev:443
sigstore-tuf-root.storage.googleapis.com:443
tuf-repo-cdn.sigstore.dev:443
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
cache: npm
node-version-file: .nvmrc
- name: Install tooling
uses: asdf-vm/actions/install@05e0d2ed97b598bfce82fd30daf324ae0c4570e6 # v3.0.2
- name: Install dependencies
run: npm clean-install
- name: Lint
run: npm run lint
reproducible:
name: Reproducible build
runs-on: ubuntu-22.04
needs:
- build
steps:
- name: Harden runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.github.com:443
artifactcache.actions.githubusercontent.com:443
github.com:443
nodejs.org:443
objects.githubusercontent.com:443
registry.npmjs.org:443
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
cache: npm
node-version-file: .nvmrc
- name: Install dependencies
run: npm clean-install
- name: Build
run: npm run build
- name: Compute checksum
run: shasum lib/index.cjs | tee checksums.txt
- name: Reset to a clean state
run: |
npm run clean
git restore lib/index.cjs
- name: Rebuild
run: npm run build
- name: Verify checksum
run: shasum --check checksums.txt --strict
test:
name: Test - ${{ matrix.type }}
runs-on: ubuntu-22.04
needs:
- build
strategy:
fail-fast: false
matrix:
type:
- integration
- unit
steps:
- name: Harden runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.codecov.io:443
api.github.com:443
artifactcache.actions.githubusercontent.com:443
codecov.io:443
cli.codecov.io:443
github.com:443
nodejs.org:443
objects.githubusercontent.com:443
registry.npmjs.org:443
storage.googleapis.com:443
uploader.codecov.io:443
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
cache: npm
node-version-file: .nvmrc
- name: Cache Jest
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: .cache/jest
key: ${{ runner.os }}-jest-${{ matrix.type }}-${{ hashFiles('package-lock.json') }}-${{ github.run_number }}
restore-keys: |
${{ runner.os }}-jest-${{ matrix.type }}-${{ hashFiles('package-lock.json') }}-
${{ runner.os }}-jest-${{ matrix.type }}-
- name: Install dependencies
run: npm clean-install
- name: Run ${{ matrix.type }} tests
env:
TYPE: ${{ matrix.type }}
run: npm run "coverage:${TYPE}"
- name: Upload code coverage
uses: codecov/codecov-action@c16abc29c95fcf9174b58eb7e1abf4c866893bc8 # v4.1.1
if: ${{ failure() || success() }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
file: ./_reports/coverage/${{ matrix.type }}/lcov.info
flags: ${{ matrix.type }}
test-compatibility:
name: Test - compatibility (${{ matrix.runs-on }})
runs-on: ${{ matrix.runs-on }}
needs:
- build
- test-e2e
strategy:
fail-fast: false
matrix:
runs-on:
- ubuntu-20.04
- ubuntu-22.04
steps:
- name: Harden runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.github.com:443
artifactcache.actions.githubusercontent.com:443
github.com:443
nodejs.org:443
objects.githubusercontent.com:443
registry.npmjs.org:443
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
cache: npm
node-version-file: .nvmrc
- name: Install dependencies
run: npm clean-install
- name: Build SVGO Action
run: npm run build
- name: Run SVGO Action
uses: ./
id: svgo
env:
SVGO_ACTION_CI_TEST: true
test-e2e:
name: Test - end-to-end (${{ matrix.test.description }})
runs-on: ubuntu-22.04
needs:
- build
- test
strategy:
fail-fast: false
matrix:
test:
- description: built-in, v2
svgo-version: 2
svgo-config: test/end-to-end/svgo.config.cjs
- description: built-in, v3
svgo-version: 3
svgo-config: test/end-to-end/svgo.config.cjs
project-svgo-version: ^1.0.0
- description: project, v2
svgo-version: project
svgo-config: test/end-to-end/svgo.config.cjs
project-svgo-version: ^2.0.0
- description: project, v3
svgo-version: project
svgo-config: test/end-to-end/svgo.config.cjs
project-svgo-version: ^3.0.0
steps:
- name: Harden runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.github.com:443
artifactcache.actions.githubusercontent.com:443
github.com:443
nodejs.org:443
objects.githubusercontent.com:443
registry.npmjs.org:443
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
cache: npm
node-version-file: .nvmrc
- name: Install dependencies
run: npm clean-install
- name: Install package-local SVGO
if: ${{ matrix.test.svgo-version == 'project' }}
env:
SVGO_VERSION: ${{ matrix.test.project-svgo-version }}
run: npm install --no-save "svgo@${SVGO_VERSION}"
- name: Build SVGO Action
run: npm run build
- name: Get the content of SVGs
id: original-svgs
run: |
{
echo 'svg-one<<EOF'
cat test/end-to-end/not-optimized-1.svg
echo 'EOF'
echo 'svg-two<<EOF'
cat test/end-to-end/not-optimized-2.svg
echo 'EOF'
echo 'ignored-svg-one<<EOF'
cat test/end-to-end/ignore/ignored-1.svg
echo 'EOF'
echo "optimized-svg-one=$(cat test/end-to-end/optimized-1.svg)"
} >>"${GITHUB_OUTPUT}"
- name: Run SVGO Action
uses: ./
id: svgo
env:
SVGO_ACTION_CI_TEST: true
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
svgo-config: ${{ matrix.test.svgo-config }}
svgo-version: ${{ matrix.test.svgo-version }}
ignore: |
test/end-to-end/ignore/*
- name: Check the output value
env:
DID_OPTIMIZE: ${{ steps.svgo.outputs.DID_OPTIMIZE }}
OPTIMIZED_COUNT: ${{ steps.svgo.outputs.OPTIMIZED_COUNT }}
SVG_COUNT: ${{ steps.svgo.outputs.SVG_COUNT }}
run: |
if [ "${DID_OPTIMIZE}" != 'true' ]; then
exit 1
fi
if [ "${SVG_COUNT}" != '3' ]; then
exit 2
fi
if [ "${OPTIMIZED_COUNT}" != '2' ]; then
exit 3
fi
- name: Check the content of newly optimized SVGs
env:
SVG_ONE: ${{ steps.original-svgs.outputs.svg-one }}
SVG_TWO: ${{ steps.original-svgs.outputs.svg-two }}
run: |
SVG=$(cat test/end-to-end/not-optimized-1.svg)
if [ "${SVG_ONE}" = "${SVG}" ]; then
echo '=== BEFORE ==='
echo "${SVG_ONE}"
echo '=== AFTER ==='
echo "${SVG}"
exit 4
fi
SVG=$(cat test/end-to-end/not-optimized-2.svg)
if [ "${SVG_TWO}" = "${SVG}" ]; then
echo '=== BEFORE ==='
echo "${SVG_TWO}"
echo '=== AFTER ==='
echo "${SVG}"
exit 5
fi
- name: Check the content of already optimized SVGs
env:
SVG_ONE: ${{ steps.original-svgs.outputs.optimized-svg-one }}
run: |
SVG=$(cat test/end-to-end/optimized-1.svg)
if [ "${SVG_ONE}" != "${SVG}" ]; then
echo '=== BEFORE ==='
echo "${SVG_ONE}"
echo '=== AFTER ==='
echo "${SVG}"
exit 6
fi
- name: Check the content of ignored SVGs
env:
SVG_ONE: ${{ steps.original-svgs.outputs.ignored-svg-one }}
run: |
SVG=$(cat test/end-to-end/ignore/ignored-1.svg)
if [ "${SVG_ONE}" != "${SVG}" ]; then
echo '=== BEFORE ==='
echo "${SVG_ONE}"
echo '=== AFTER ==='
echo "${SVG}"
exit 7
fi
test-mutation:
name: Test - mutation
runs-on: ubuntu-22.04
needs:
- test
steps:
- name: Harden runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.github.com:443
artifactcache.actions.githubusercontent.com:443
github.com:443
nodejs.org:443
objects.githubusercontent.com:443
registry.npmjs.org:443
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
cache: npm
node-version-file: .nvmrc
- name: Cache Stryker incremental report
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: .cache/stryker/incremental.json
key: mutation-${{ github.run_number }}
restore-keys: |
mutation-
- name: Install dependencies
run: npm clean-install
- name: Run mutation tests
run: npm run test:mutation
vet:
name: Vet
runs-on: ubuntu-22.04
steps:
- name: Harden runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.github.com:443
artifactcache.actions.githubusercontent.com:443
github.com:443
nodejs.org:443
objects.githubusercontent.com:443
registry.npmjs.org:443
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
cache: npm
node-version-file: .nvmrc
- name: Install dependencies
run: npm clean-install
- name: Vet dependencies
if: ${{ failure() || success() }}
run: npm run vet:deps
- name: Vet lockfile
if: ${{ failure() || success() }}
run: npm run vet:package-lock.json
- name: Vet types
if: ${{ failure() || success() }}
run: npm run vet:types