From 081ae1c225fa566e5b60be404293deb42dc1e770 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sun, 30 Nov 2025 00:29:08 -0500 Subject: [PATCH] test: Add CI, linting, testing, and SVG utilities Introduces GitHub Actions CI workflow, ESLint configuration, and TypeScript config. Adds SVG utility functions for sponsor handling and refactors their usage in contribkit.config.ts. Expands package.json with metadata, scripts, and test/lint dependencies. Adds comprehensive unit and regression tests for SVG utilities. Updates build.sh for CI compatibility and .gitignore for coverage artifacts. --- .github/workflows/_ci-node.yml | 33 +++ .gitignore | 4 + build.sh | 11 + configs/sponsors/contribkit.config.ts | 44 +-- configs/sponsors/svg-utils.ts | 62 ++++ eslint.config.mjs | 33 +++ package.json | 61 +++- tests/regression.test.ts | 196 ++++++++++++ tests/svg-utils.test.ts | 411 ++++++++++++++++++++++++++ tsconfig.json | 14 + 10 files changed, 824 insertions(+), 45 deletions(-) create mode 100644 .github/workflows/_ci-node.yml create mode 100644 configs/sponsors/svg-utils.ts create mode 100644 eslint.config.mjs create mode 100644 tests/regression.test.ts create mode 100644 tests/svg-utils.test.ts create mode 100644 tsconfig.json diff --git a/.github/workflows/_ci-node.yml b/.github/workflows/_ci-node.yml new file mode 100644 index 0000000..682792d --- /dev/null +++ b/.github/workflows/_ci-node.yml @@ -0,0 +1,33 @@ +--- +# This workflow is centrally managed in https://github.com/LizardByte/.github/ +# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in +# the above-mentioned repo. + +# To use, add the `npm-pkg` repository label to identify repositories that should trigger this workflow. + +# This will run standard CI for Node.js/npm/TypeScript projects. + +name: CI-Node +permissions: + contents: write # required for release_setup action + +on: + push: + branches: + - master + pull_request: + branches: + - master + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + +jobs: + call-ci-node: + name: CI-Node + uses: LizardByte/.github/.github/workflows/__call-ci-node.yml@master + if: ${{ github.repository != 'LizardByte/.github' }} + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + GH_TOKEN: ${{ secrets.GH_BOT_TOKEN }} diff --git a/.gitignore b/.gitignore index 862c933..1ca8a71 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,7 @@ node_modules/ package-lock.json dist/ + +# coverage +coverage/ +junit.xml diff --git a/build.sh b/build.sh index 77509e0..c4517f8 100644 --- a/build.sh +++ b/build.sh @@ -18,6 +18,17 @@ github_accounts=( output_dir="$(pwd)/dist" +# Debug output for CI environment +echo "GITHUB_JOB: ${GITHUB_JOB:-not set}" + +# Check if we're running in a GitHub Actions job named "build" +# If so, skip all token-dependent sections since secrets won't be available +if [[ "${GITHUB_JOB}" = "build" ]]; then + echo "Running in GitHub Actions 'build' job - skipping all token-dependent sections" + echo "Done!" + exit 0 +fi + echo "Building sponsors..." pushd configs/sponsors || exit 1 npx contribkit --outputDir="${output_dir}" -w=800 --name=sponsors --force diff --git a/configs/sponsors/contribkit.config.ts b/configs/sponsors/contribkit.config.ts index 7ec6d95..ecc4cd7 100644 --- a/configs/sponsors/contribkit.config.ts +++ b/configs/sponsors/contribkit.config.ts @@ -2,6 +2,7 @@ import { defineConfig, tierPresets, } from '@lizardbyte/contribkit' +import { extractSvgDimensions, createWrappedSponsorSvg } from './svg-utils.js' const createThemeAwareSvgStyle = (pathClass: string, lightColor: string = '#000000', darkColor: string = '#ffffff') => `