From 4dc54839a0f15fc9da41545499396acc60b6cc9a Mon Sep 17 00:00:00 2001 From: Miika Holmlund Date: Tue, 21 Oct 2025 12:53:09 +0300 Subject: [PATCH] Fix pipeline related errors --- .github/workflows/github-actions.yml | 51 +++++++++++++++++----------- gradesa/.env.test | 4 +-- gradesa/data/migrate.sh | 5 +-- 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 93fa2b0..4fb532c 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -9,23 +9,29 @@ on: jobs: lint-format-test: runs-on: ubuntu-latest + env: + DB_HOST: pgtestdb + DB_PORT: 5432 + DB_USER: postgres + DB_PASSWORD: password + DB_NAME: postgres + SESSION_SECRET: secret + services: + # Label used to access the service container + pgtestdb: + image: postgres:15 + env: + POSTGRES_PASSWORD: password + # Set health checks to wait until postgres has started + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + container: node:20 steps: - - uses: actions/checkout@v3 - - name: Start databases - run: docker compose up -d - - name: Cache Node.js modules - uses: actions/cache@v3 - with: - path: ./gradesa/node_modules - key: ${{ runner.os }}-node-${{ hashFiles('./gradesa/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-node- - - name: Install Node - uses: actions/setup-node@v4 - with: - cache-dependency-path: ./gradesa/package-lock.json - node-version: 22.6 - cache: "npm" + - uses: actions/checkout@v5 - name: Install dependencies run: npm install - name: Install client dependencies @@ -35,7 +41,7 @@ jobs: run: npm run format:check - name: Download pgmigrate run: | - wget --quiet https://github.com/peterldowns/pgmigrate/releases/download/v0.1.0%2Bcommit.2f6a72b/pgmigrate-linux-amd64 -O pgmigrate + wget --quiet https://github.com/peterldowns/pgmigrate/releases/download/v0.0.6%2Bcommit.4f90829/pgmigrate-linux-amd64 -O pgmigrate chmod +x pgmigrate mkdir -p "$HOME/bin" mv pgmigrate "$HOME/bin/" @@ -43,18 +49,25 @@ jobs: - name: Run migrations run: | npm run db:migrate - - name: Check for no uncommitted changes + + - name: Check that schema.sql is up to date + shell: bash + # For the git config step, see https://github.com/actions/checkout/issues/363#issuecomment-2624179541 run: | - echo "checking for uncommitted changes" + git config --global --add safe.directory $PWD + echo "Checking that schema.sql is up to date after migrations" git --no-pager diff git status [[ -z $(git status -s) ]] || (exit 1) + - name: Run tests working-directory: ./gradesa run: | npm run test - name: Run e2e tests working-directory: ./gradesa + env: + HOME: /root # required in order to make Playwright Firefox tests work with GitHub actions run: | npx playwright install --with-deps npm run test:e2e diff --git a/gradesa/.env.test b/gradesa/.env.test index 7bf2440..e6eb0ff 100644 --- a/gradesa/.env.test +++ b/gradesa/.env.test @@ -1,5 +1,5 @@ -DB_HOST=localhost -DB_PORT=7741 +DB_HOST=pgtestdb +DB_PORT=5432 DB_USER=postgres DB_PASSWORD=password DB_NAME=postgres diff --git a/gradesa/data/migrate.sh b/gradesa/data/migrate.sh index 0f4700b..c08e393 100755 --- a/gradesa/data/migrate.sh +++ b/gradesa/data/migrate.sh @@ -31,9 +31,6 @@ fi # a difference between the schema file and the actual schema in the database # Create a temporary schema file inside the container -docker exec gradesa-db sh -c "pgmigrate dump -d postgres://ohtu:password@localhost:5432/gradesa --out /tmp/schema.sql" +pgmigrate dump -d $DB_URL --out schema.sql -# Copy the schema file from the container to the local directory -docker cp gradesa-db:/tmp/schema.sql ./schema.sql echo "Dumping done" -