Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: Upgrade to Postgres 15 #10534

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ jobs:
run: npm run build

test:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04

timeout-minutes: 30

Expand All @@ -209,7 +209,7 @@ jobs:
- 6379:6379
options: --entrypoint redis-server
postgres:
image: postgres:14.15
image: postgres:15.10
env:
POSTGRES_USER: postgres
POSTGRES_DB: postgres
Expand Down Expand Up @@ -242,7 +242,9 @@ jobs:
- run: npm run db:restore
- run: npm run db:migrate

- run: npm run test -- --ignore "test/server/graphql/**"
# We have to specify OPENSSL_CONF=/dev/null for html-pdf to work
# We can remove it once we tackle https://github.com/opencollective/opencollective/issues/7622
- run: OPENSSL_CONF=/dev/null npm run test -- --ignore "test/server/graphql/**"

- name: Report coverage
uses: codecov/codecov-action@v4
Expand All @@ -251,7 +253,7 @@ jobs:
flags: Unit

test-graphql:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
timeout-minutes: 30

services:
Expand All @@ -261,7 +263,7 @@ jobs:
- 6379:6379
options: --entrypoint redis-server
postgres:
image: postgres:14.15
image: postgres:15.10
env:
POSTGRES_USER: postgres
POSTGRES_DB: postgres
Expand Down Expand Up @@ -324,7 +326,7 @@ jobs:
- 6379:6379
options: --entrypoint redis-server
postgres:
image: postgres:14.15
image: postgres:15.10
env:
POSTGRES_USER: postgres
POSTGRES_DB: postgres
Expand Down Expand Up @@ -366,7 +368,7 @@ jobs:
- 6379:6379
options: --entrypoint redis-server
postgres:
image: postgres:14.15
image: postgres:15.10
env:
POSTGRES_USER: postgres
POSTGRES_DB: postgres
Expand Down
25 changes: 13 additions & 12 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ env:

E2E_TEST: 1
PGHOST: localhost
PGUSER: postgres
PGUSER: opencollective
CYPRESS_RECORD: false
CYPRESS_VIDEO: false
CYPRESS_VIDEO_UPLOAD_ON_PASSES: false
Expand All @@ -34,7 +34,7 @@ env:

jobs:
e2e:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
timeout-minutes: 30

strategy:
Expand All @@ -48,7 +48,7 @@ jobs:
- 6379:6379
options: --entrypoint redis-server
postgres:
image: postgres:14.15
image: postgres:15.10
env:
POSTGRES_USER: postgres
POSTGRES_DB: postgres
Expand All @@ -62,14 +62,15 @@ jobs:
- name: Update apt
run: sudo apt-get update || exit 0

- name: Install Cypress dependencies
run: sudo apt-get install --no-install-recommends -y libgtk2.0-0 libgtk-3-0 libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb fonts-arphic-bkai00mp fonts-arphic-bsmi00lp fonts-arphic-gbsn00lp fonts-arphic-gkai00mp fonts-arphic-ukai fonts-arphic-uming ttf-wqy-zenhei ttf-wqy-microhei xfonts-wqy

- name: Install postgresql-client
run: sudo apt-get install -y postgresql-client

- name: Install graphicsmagick
run: sudo apt-get install -y graphicsmagick
- name: Install dependencies
run: |
sudo apt-get install \
`# Cypress dependencies - see https://docs.cypress.io/app/get-started/install-cypress#UbuntuDebian` \
libgtk2.0-0t64 libgtk-3-0t64 libgbm-dev libnotify-dev libnss3 libxss1 libasound2t64 libxtst6 xauth xvfb \
`# Postgres client` \
postgresql-client-16 \
`# GraphicsMagick (not sure if needed)` \
graphicsmagick
Comment on lines +65 to +73
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Single command for faster install


- name: Install stripe-cli
run: |
Expand Down Expand Up @@ -228,7 +229,7 @@ jobs:

- name: Build (pdf)
working-directory: opencollective-pdf
run: npm run build
run: OPENSSL_CONF=/dev/null npm run build

# Setup Cypress

Expand Down
4 changes: 2 additions & 2 deletions docs/postgres.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PostgreSQL Database

You need to have PostgreSQL > 14.x.
You need to have PostgreSQL > 15.x.

In production, we're currently running 16.4.

Expand Down Expand Up @@ -57,7 +57,7 @@ If you don't want to run a local instance of PostgreSQL in your computer, you ca
Create and run the container:

```
docker run -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust -d --name opencollective-postgres --shm-size=1g --memory=4g --cpus=2 postgres:14
docker run -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust -d --name opencollective-postgres --shm-size=1g --memory=4g --cpus=2 postgres:15
```

Set the necessary environment variables:
Expand Down
42 changes: 24 additions & 18 deletions scripts/db_restore.sh
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
#!/bin/bash

usage() {
echo "Usage: db_restore.sh -d DBNAME -U DBUSER --use-postgis -f DBDUMP_FILE";
echo "e.g.";
echo "Usage: db_restore.sh -d DBNAME -U DBUSER --use-postgis -f DBDUMP_FILE"
echo "e.g."
echo "> db_restore.sh -d opencollective_dvl -U opencollective -f test/dbdumps/opencollective_dvl.pgsql"
exit 0;
exit 0
}

while [[ $# -gt 0 ]]
do
key="$1"
while [[ $# -gt 0 ]]; do
key="$1"

case $key in
-d|--dbname)
case $key in
-d | --dbname)
LOCALDBNAME="$2"
shift # past argument
;;
-U|--username)
-U | --username)
LOCALDBUSER="$2"
shift # past argument
;;
--use-postgis)
--use-postgis)
USE_POSTGIS=1
;;
-f|--file)
-f | --file)
DBDUMP_FILE="$2"
shift # past argument
;;
*)
# unknown option
*)
# unknown option
;;
esac
shift # past argument or value
esac
shift # past argument or value
done

LOCALDBUSER=${LOCALDBUSER:-"opencollective"}
Expand All @@ -42,7 +41,7 @@ echo "LOCALDBUSER=$LOCALDBUSER"
echo "LOCALDBNAME=$LOCALDBNAME"
echo "DBDUMP_FILE=$DBDUMP_FILE"

if [ -z "$LOCALDBNAME" ]; then usage; fi;
if [ -z "$LOCALDBNAME" ]; then usage; fi

# kill all connections to the postgres server
# echo "Killing all connections to database '$LOCALDBNAME'"
Expand All @@ -53,8 +52,11 @@ if [ -z "$LOCALDBNAME" ]; then usage; fi;
# where pg_stat_activity.datname = '$LOCALDBNAME'
# EOF

dropdb -U postgres -h localhost --if-exists $LOCALDBNAME;
createdb -U postgres -h localhost $LOCALDBNAME 2> /dev/null
echo "Dropping '$LOCALDBNAME'"
dropdb -U postgres -h localhost --if-exists $LOCALDBNAME

echo "Creating '$LOCALDBNAME'"
createdb -U postgres -h localhost $LOCALDBNAME 2>/dev/null

# When restoring old backups, you may need to enable Postgis
if [ "$USE_POSTGIS" = "1" ]; then
Expand All @@ -72,6 +74,10 @@ fi
set -e
} | tee >/dev/null

# Update table permissions
echo "Updating table permissions"
psql -U postgres -h localhost $LOCALDBNAME -c "GRANT ALL ON SCHEMA public TO ${LOCALDBUSER};"

Comment on lines +77 to +80
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# The first time we run it, we will trigger FK constraints errors
set +e
pg_restore -U postgres -h localhost --no-acl --no-owner --role=${LOCALDBUSER} -n public -O -c -d "${LOCALDBNAME}" "${DBDUMP_FILE}" 2>/dev/null
Expand Down
Binary file modified test/dbdumps/opencollective_dvl.pgsql
Binary file not shown.
Loading