From f61e1fed4de79f33d214e0dd65a984ba870e86d9 Mon Sep 17 00:00:00 2001 From: Josephat-S Date: Mon, 25 May 2026 21:08:40 +0200 Subject: [PATCH] add automated template testing in CI --- .github/workflows/templates.yml | 34 +++++++++ package.json | 2 + scripts/test-single-template.js | 114 ++++++++++++++++++++++++++++ scripts/test-templates.js | 127 ++++++++++++++++++++++++++++++++ 4 files changed, 277 insertions(+) create mode 100644 .github/workflows/templates.yml create mode 100644 scripts/test-single-template.js create mode 100644 scripts/test-templates.js diff --git a/.github/workflows/templates.yml b/.github/workflows/templates.yml new file mode 100644 index 0000000..2433bc6 --- /dev/null +++ b/.github/workflows/templates.yml @@ -0,0 +1,34 @@ +name: Template Tests + +on: + pull_request: + branches: [main, dev] + paths: + - 'templates/**' + - 'src/generate.js' + - 'src/dependencies.js' + - 'scripts/test-templates.js' + +jobs: + test-templates: + runs-on: ubuntu-latest + timeout-minutes: 30 + + strategy: + fail-fast: false + matrix: + template: [portfolio, ecommerce, school, saas, blog] + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + + - name: Install CLI dependencies + run: npm ci + + - name: Test ${{ matrix.template }} template + run: node scripts/test-single-template.js ${{ matrix.template }} diff --git a/package.json b/package.json index 35d7b8b..b503a83 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,8 @@ }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", + "test:templates": "node scripts/test-templates.js", + "test:templates:quick": "node scripts/test-templates.js --quick", "lint": "eslint index.js src/", "format": "prettier --write .", "prepare": "husky install" diff --git a/scripts/test-single-template.js b/scripts/test-single-template.js new file mode 100644 index 0000000..4b4024e --- /dev/null +++ b/scripts/test-single-template.js @@ -0,0 +1,114 @@ +/** + * Test a single template across all its architectures, designs, and sidebar options. + * Used by the CI matrix strategy to parallelize template testing. + * + * Usage: node scripts/test-single-template.js