Fix pipeline related errors

This commit is contained in:
Miika Holmlund
2025-11-03 18:26:53 +02:00
parent 7ca34beeb6
commit 4dc54839a0
3 changed files with 35 additions and 25 deletions
+32 -19
View File
@@ -9,23 +9,29 @@ on:
jobs: jobs:
lint-format-test: lint-format-test:
runs-on: ubuntu-latest 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: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v5
- 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"
- name: Install dependencies - name: Install dependencies
run: npm install run: npm install
- name: Install client dependencies - name: Install client dependencies
@@ -35,7 +41,7 @@ jobs:
run: npm run format:check run: npm run format:check
- name: Download pgmigrate - name: Download pgmigrate
run: | 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 chmod +x pgmigrate
mkdir -p "$HOME/bin" mkdir -p "$HOME/bin"
mv pgmigrate "$HOME/bin/" mv pgmigrate "$HOME/bin/"
@@ -43,18 +49,25 @@ jobs:
- name: Run migrations - name: Run migrations
run: | run: |
npm run db:migrate 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: | 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 --no-pager diff
git status git status
[[ -z $(git status -s) ]] || (exit 1) [[ -z $(git status -s) ]] || (exit 1)
- name: Run tests - name: Run tests
working-directory: ./gradesa working-directory: ./gradesa
run: | run: |
npm run test npm run test
- name: Run e2e tests - name: Run e2e tests
working-directory: ./gradesa working-directory: ./gradesa
env:
HOME: /root # required in order to make Playwright Firefox tests work with GitHub actions
run: | run: |
npx playwright install --with-deps npx playwright install --with-deps
npm run test:e2e npm run test:e2e
+2 -2
View File
@@ -1,5 +1,5 @@
DB_HOST=localhost DB_HOST=pgtestdb
DB_PORT=7741 DB_PORT=5432
DB_USER=postgres DB_USER=postgres
DB_PASSWORD=password DB_PASSWORD=password
DB_NAME=postgres DB_NAME=postgres
+1 -4
View File
@@ -31,9 +31,6 @@ fi
# a difference between the schema file and the actual schema in the database # a difference between the schema file and the actual schema in the database
# Create a temporary schema file inside the container # 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" echo "Dumping done"