From b139068d4e3c9d5bb6cb34c60ab17ec260b473f7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 13 Dec 2025 16:41:00 +0000 Subject: [PATCH 1/4] Initial plan From 78e632f090d06a1d316d28ce937f2d49454a9aa1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 13 Dec 2025 16:43:19 +0000 Subject: [PATCH 2/4] Add CI workflow for testing with Node.js 18.x and 20.x Co-authored-by: Andrew112 <12086319+Andrew112@users.noreply.github.com> --- .github/workflows/ci-tests.yml | 75 ++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 .github/workflows/ci-tests.yml diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml new file mode 100644 index 0000000..ae337e0 --- /dev/null +++ b/.github/workflows/ci-tests.yml @@ -0,0 +1,75 @@ +# GitHub Actions workflow: CI - run tests for Node/React app +# Triggers on push to main/develop and on pull requests. Detects package manager (npm/yarn/pnpm), +# caches dependencies, installs, and runs tests once (non-watch). +name: CI - Tests + +on: + push: + branches: [ "main", "develop" ] + pull_request: + branches: [ "main", "develop" ] + workflow_dispatch: + +jobs: + test: + name: Test on Node.js ${{ matrix.node-version }} + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [18.x, 20.x] + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Detect package manager and lockfile + id: detect + shell: bash + run: | + # default to npm if nothing is found + if [ -f pnpm-lock.yaml ]; then + echo "manager=pnpm" >> $GITHUB_OUTPUT + echo "lockfile=pnpm-lock.yaml" >> $GITHUB_OUTPUT + echo "install=pnpm install --frozen-lockfile" >> $GITHUB_OUTPUT + elif [ -f yarn.lock ]; then + echo "manager=yarn" >> $GITHUB_OUTPUT + echo "lockfile=yarn.lock" >> $GITHUB_OUTPUT + echo "install=yarn install --frozen-lockfile" >> $GITHUB_OUTPUT + elif [ -f package-lock.json ]; then + echo "manager=npm" >> $GITHUB_OUTPUT + echo "lockfile=package-lock.json" >> $GITHUB_OUTPUT + echo "install=npm ci" >> $GITHUB_OUTPUT + else + # fallback + echo "manager=npm" >> $GITHUB_OUTPUT + echo "lockfile=package-lock.json" >> $GITHUB_OUTPUT + echo "install=npm install" >> $GITHUB_OUTPUT + fi + + - name: Setup Node.js and dependency cache + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: ${{ steps.detect.outputs.manager }} + cache-dependency-path: ${{ steps.detect.outputs.lockfile }} + + - name: Install dependencies + shell: bash + run: | + echo "Using package manager: ${{ steps.detect.outputs.manager }}" + echo "Running install command: ${{ steps.detect.outputs.install }}" + eval "${{ steps.detect.outputs.install }}" + + - name: Run tests + env: + CI: true + shell: bash + run: | + echo "Running test script using ${{ steps.detect.outputs.manager }}" + if [ "${{ steps.detect.outputs.manager }}" = "npm" ]; then + npm test -- --watchAll=false + elif [ "${{ steps.detect.outputs.manager }}" = "yarn" ]; then + yarn test --watchAll=false + else + pnpm test -- --watchAll=false + fi From 8413d45a3a1f063daef8e55a57f14bb3265c7b29 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 13 Dec 2025 16:44:40 +0000 Subject: [PATCH 3/4] Fix test command to use package.json script without duplicate flags Co-authored-by: Andrew112 <12086319+Andrew112@users.noreply.github.com> --- .github/workflows/ci-tests.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index ae337e0..74891f6 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -26,7 +26,7 @@ jobs: id: detect shell: bash run: | - # default to npm if nothing is found + # Default to npm if nothing is found if [ -f pnpm-lock.yaml ]; then echo "manager=pnpm" >> $GITHUB_OUTPUT echo "lockfile=pnpm-lock.yaml" >> $GITHUB_OUTPUT @@ -40,7 +40,7 @@ jobs: echo "lockfile=package-lock.json" >> $GITHUB_OUTPUT echo "install=npm ci" >> $GITHUB_OUTPUT else - # fallback + # Fallback to npm if no lockfile found echo "manager=npm" >> $GITHUB_OUTPUT echo "lockfile=package-lock.json" >> $GITHUB_OUTPUT echo "install=npm install" >> $GITHUB_OUTPUT @@ -67,9 +67,9 @@ jobs: run: | echo "Running test script using ${{ steps.detect.outputs.manager }}" if [ "${{ steps.detect.outputs.manager }}" = "npm" ]; then - npm test -- --watchAll=false + npm test elif [ "${{ steps.detect.outputs.manager }}" = "yarn" ]; then - yarn test --watchAll=false + yarn test else - pnpm test -- --watchAll=false + pnpm test fi From 78355e5bccd3dcc808a3ac1709d4956ef2210e24 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 13 Dec 2025 16:45:41 +0000 Subject: [PATCH 4/4] Add explicit GITHUB_TOKEN permissions for security Co-authored-by: Andrew112 <12086319+Andrew112@users.noreply.github.com> --- .github/workflows/ci-tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 74891f6..870b258 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -14,6 +14,8 @@ jobs: test: name: Test on Node.js ${{ matrix.node-version }} runs-on: ubuntu-latest + permissions: + contents: read strategy: matrix: node-version: [18.x, 20.x]