From 4e96a3f421d51f1a289d510e8cb3dc7d0cc22b84 Mon Sep 17 00:00:00 2001 From: Lucas Date: Tue, 19 Nov 2024 18:35:50 +0100 Subject: [PATCH] chore(ci): Configure eslint in CI * Run `next lint` on pull requests --- .github/workflows/test.yaml | 41 +++++++++++++++++++++++++++++++++++++ next/.eslintrc.json | 3 +++ next/Dockerfile.prod | 3 ++- next/package.json | 1 + 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/test.yaml create mode 100644 next/.eslintrc.json diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..40accd1 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,41 @@ +name: Test + +on: + pull_request: + +env: + IMAGES_HOSTNAME: "*" + +jobs: + next-lint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup node + uses: actions/setup-node@v2 + with: + node-version: 22 + cache: yarn + cache-dependency-path: next/yarn.lock + + - name: Install eslint (for easier rebasing, could be added to packages.json later) + working-directory: ./next + run: yarn add --dev eslint-config-next 'eslint@^8' + + - name: Install dependencies + working-directory: ./next + run: yarn install --frozen-lockfile + + - name: Running linter + working-directory: ./next + run: yarn run next lint --output-file ../next-eslint_report.json --format json + continue-on-error: true + + - name: Annotate Code Linting Results + uses: ataylorme/eslint-annotate-action@v3 + with: + report-json: "next-eslint_report.json" + only-pr-files: false + continue-on-error: true diff --git a/next/.eslintrc.json b/next/.eslintrc.json new file mode 100644 index 0000000..408e9bf --- /dev/null +++ b/next/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": ["next", "next/typescript"] +} diff --git a/next/Dockerfile.prod b/next/Dockerfile.prod index 6cd3e21..f9a85dc 100644 --- a/next/Dockerfile.prod +++ b/next/Dockerfile.prod @@ -20,6 +20,7 @@ RUN \ # Rebuild the source code only when needed FROM base AS builder + WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . . @@ -70,4 +71,4 @@ ENV HOSTNAME="0.0.0.0" CMD ["node", "server.js"] COPY healthcheck.mjs ./healthcheck.mjs -HEALTHCHECK --interval=12s --timeout=12s --start-period=30s CMD node healthcheck.mjs \ No newline at end of file +HEALTHCHECK --interval=12s --timeout=12s --start-period=30s CMD node healthcheck.mjs diff --git a/next/package.json b/next/package.json index 51b1744..3634ad2 100644 --- a/next/package.json +++ b/next/package.json @@ -2,6 +2,7 @@ "private": true, "scripts": { "dev": "next dev", + "lint": "next lint", "build": "next build", "start": "node .next/standalone/server.js", "syncDataModel": "node bin/syncDataModel.js",