-
Notifications
You must be signed in to change notification settings - Fork 1
100 lines (85 loc) · 3.42 KB
/
test_postgresql_OS.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Setup PostgreSQL on Multiple OS
on: [push]
jobs:
postgresql-setup:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download PostgreSQL Portable for macOS
if: matrix.os == 'macos-latest'
run: wget https://get.enterprisedb.com/postgresql/postgresql-16.4-1-osx-binaries.zip -O postgresql.zip
- name: Download PostgreSQL source for Ubuntu
if: matrix.os == 'ubuntu-latest'
run: wget https://ftp.postgresql.org/pub/source/v14.1/postgresql-14.1.tar.gz -O postgresql.tar.gz
- name: Build PostgreSQL from source on Ubuntu
if: matrix.os == 'ubuntu-latest'
run: |
WORKSPACE_ABS_PATH=$(realpath "$GITHUB_WORKSPACE")
tar -xzf postgresql.tar.gz -C $WORKSPACE_ABS_PATH
cd $WORKSPACE_ABS_PATH/postgresql-14.1
./configure --prefix=$WORKSPACE_ABS_PATH/postgresql
make
make install
- name: Download PostgreSQL Portable for Windows
if: matrix.os == 'windows-latest'
run: |
Invoke-WebRequest -Uri https://get.enterprisedb.com/postgresql/postgresql-16.4-1-windows-x64-binaries.zip -OutFile postgresql.zip
shell: pwsh
- name: Unpack PostgreSQL archive on macOS or Windows
if: matrix.os == 'macos-latest' || matrix.os == 'windows-latest'
run: |
unzip postgresql.zip -d .
mv ./pgsql ./postgresql
- name: Setup PostgreSQL environment variables
run: |
echo 'POSTGRESQL_HOME=./postgresql' >> $GITHUB_ENV
echo 'PATH=$POSTGRESQL_HOME/bin:$PATH' >> $GITHUB_ENV
source $GITHUB_ENV
shell: bash
- name: Initialize PostgreSQL data directory
run: |
./postgresql/bin/initdb -D ./postgresql_data
shell: bash
- name: Start PostgreSQL server
run: |
./postgresql/bin/pg_ctl -D ./postgresql_data -l logfile start
shell: bash
- name: Wait for PostgreSQL to start
run: |
for i in {30..0}; do
if ./postgresql/bin/pg_isready &>/dev/null; then
break
fi
echo 'Waiting for PostgreSQL to start...'
sleep 1
done
shell: bash
- name: Set up PostgreSQL user and database on MacOS
if: matrix.os == 'macos-latest'
run: |
./postgresql/bin/createdb -U runner "runner"
./postgresql/bin/psql -U runner -c "CREATE USER msnoise WITH PASSWORD 'msnoise';"
./postgresql/bin/psql -U runner -c "ALTER USER msnoise WITH SUPERUSER;"
shell: bash
- name: Set up PostgreSQL user and database on Windows
if: matrix.os == 'windows-latest'
run: |
./postgresql/bin/createdb -U runneradmin "runneradmin"
./postgresql/bin/psql -U runneradmin -c "CREATE USER msnoise WITH PASSWORD 'msnoise';"
./postgresql/bin/psql -U runneradmin -c "ALTER USER msnoise WITH SUPERUSER;"
shell: bash
- name: Verify PostgreSQL setup on MacOS
if: matrix.os == 'macos-latest'
run: |
./postgresql/bin/psql -U runner -c "\l"
shell: bash
- name: Verify PostgreSQL setup on Windows
if: matrix.os == 'windows-latest'
run: |
./postgresql/bin/psql -U runneradmin -c "\l"
shell: bash