From 048e2f46b212faea4f30edd3f2fe27a427cbb09f Mon Sep 17 00:00:00 2001 From: Daniel von Atzigen Date: Fri, 19 Jul 2024 14:27:21 +0200 Subject: [PATCH] Re-add missing code quality steps --- .github/workflows/code-quality.yml | 100 ++++++++++++++++++- e2e/cypress/e2e/create-elastic-index.feature | 2 +- 2 files changed, 100 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index db8e4f6c..40800116 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -15,6 +15,14 @@ env: DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres?schema=public jobs: + dependency-review: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Review Dependencies + uses: actions/dependency-review-action@v4 + install: runs-on: ubuntu-latest steps: @@ -55,10 +63,100 @@ jobs: - name: Install e2e node dependencies run: cd e2e && npm ci + test: + runs-on: ubuntu-latest + needs: install + services: + db: + image: postgis/postgis + ports: + - "5432:5432" + env: + POSTGRES_USER: ${{ env.DB_USERNAME }} + POSTGRES_PASSWORD: ${{ env.DB_PASSWORD }} + POSTGRES_DB: ${{ env.DB_DATABASE }} + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + elasticsearch: + image: docker.elastic.co/elasticsearch/elasticsearch:8.12.1 + ports: + - "9200:9200" + env: + ES_JAVA_OPTS: -Xms512m -Xmx512m + xpack.security.enabled: false + discovery.type: single-node + cluster.routing.allocation.disk.threshold_enabled: false + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Setup node + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + - name: Restore cached node modules + uses: actions/cache/restore@v4 + with: + path: ./node_modules + key: "${{ runner.os }}-node_modules-${{ hashFiles('package-lock.json') }}-${{ hashFiles('**/schema.prisma') }}" + - name: Migrate database + run: npm run prisma -- migrate deploy + - name: Run tests + run: npm run test + + lint: + runs-on: ubuntu-latest + needs: install + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Setup node + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + - name: Restore cached node modules + uses: actions/cache/restore@v4 + with: + path: ./node_modules + key: "${{ runner.os }}-node_modules-${{ hashFiles('package-lock.json') }}-${{ hashFiles('**/schema.prisma') }}" + - name: Run lint + run: npm run lint + - name: Run prettier + run: npx prettier --check . + + # It would be cleaner and probably more performant to replace this build step + # with either a non-emitting build or a simple type check. + # We only have `build` available for now, + # since the project is currently split across a multitude of small packages, + # all of which have to specify their own commands. + # (Daniel von Atzigen, 2024-04-12) + build: + runs-on: ubuntu-latest + needs: + - test + - lint + - dependency-review + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Setup node + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + - name: Restore cached node modules + uses: actions/cache/restore@v4 + with: + path: ./node_modules + key: "${{ runner.os }}-node_modules-${{ hashFiles('package-lock.json') }}-${{ hashFiles('**/schema.prisma') }}" + - name: Reset nx + run: npx nx reset + - name: Run build + run: npm run build + cypress: runs-on: ubuntu-latest needs: - - install + - test + - lint + - dependency-review strategy: # https://github.com/cypress-io/github-action/issues/48 fail-fast: false diff --git a/e2e/cypress/e2e/create-elastic-index.feature b/e2e/cypress/e2e/create-elastic-index.feature index 082738ed..493e7e57 100644 --- a/e2e/cypress/e2e/create-elastic-index.feature +++ b/e2e/cypress/e2e/create-elastic-index.feature @@ -2,7 +2,7 @@ Feature: Elastic index Background: Given The user is logged in - Given User has admin permissions + And User has admin permissions Scenario: User creates elastic index When A user clicks administration menu button