-
Notifications
You must be signed in to change notification settings - Fork 77
156 lines (136 loc) · 4.92 KB
/
build.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: Test
on:
push:
branches:
- master
- REL_16_STABLE
- REL_15_STABLE
- REL_14_STABLE
- REL_13_STABLE
- REL_12_STABLE
- REL_11_STABLE
pull_request:
branches:
- master
- REL_16_STABLE
- REL_15_STABLE
- REL_14_STABLE
- REL_13_STABLE
- REL_12_STABLE
- REL_11_STABLE
schedule:
- cron: "0 1 * * SUN" # only master
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 30
env:
CACHE_VERSION: 20210426 # to identify cache version
steps:
- name: get current branch name
shell: bash -xe {0}
run: |
if [ ${{ github.event_name }} = "pull_request" ]; then
echo "BRANCH=${{ github.base_ref }}" >> $GITHUB_ENV
else # push
echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
fi
- name: set build postgresql version
shell: bash -xe {0}
run: |
declare -A versions=(
["master"]="16.1"
["REL_15_STABLE"]="15.5"
["REL_14_STABLE"]="14.10"
["REL_13_STABLE"]="13.13"
["REL_12_STABLE"]="12.17"
["REL_11_STABLE"]="11.18"
)
[ -z "${versions[${{ env.BRANCH }}]}" ] && exit 1 # check if the key exists
echo "PGVERSION=${versions[${{ env.BRANCH }}]}" >> $GITHUB_ENV
- name: cache builded resources
id: cache-postgresql-core
uses: actions/cache@v2
with:
path: "~/pgsql/${{ env.PGVERSION }}"
key: ${{ env.PGVERSION }}-${{ env.CACHE_VERSION }}
- name: build postgresql
if: steps.cache-postgresql-core.outputs.cache-hit != 'true'
shell: bash -xe {0}
run: |
# set environment variables
export PGHOME=~/pgsql/${{ env.PGVERSION }}
# install
sudo apt-get update -qq
sudo apt-get -y install bc libpam-dev libedit-dev
wget -q https://ftp.postgresql.org/pub/source/v${{ env.PGVERSION }}/postgresql-${{ env.PGVERSION }}.tar.gz
tar xzf postgresql-${{ env.PGVERSION }}.tar.gz
# TODO: if test with master branch
# git clone --single-branch --branch ${{ env.PGVERSION }} \
# https://github.com/postgres/postgres.git ${{ env.PGVERSION }}
cd postgresql-${{ env.PGVERSION }}
./configure --prefix=$PGHOME --enable-cassert
gcc -v
LOGFILE=~/make.log
make -j 4 2>&1 | tee $LOGFILE
make install 2>&1 | tee -a $LOGFILE
- name: show build warning
if: steps.cache-postgresql-core.outputs.cache-hit != 'true'
shell: bash -xe {0}
run: |
LOGFILE=~/make.log # TODO: though I want to remove duplicated vars...
grep -C 1 warning $LOGFILE || exit 0 # ok if warning doesn't exists (= status code is 1)
- name: create database directory
shell: bash -xe {0}
run: |
export PGHOME=~/pgsql/${{ env.PGVERSION }}
export PGDATA=~/pgdata/${{ env.PGVERSION }}
export ARCHIVEDIR=~/pgdata/arc
export PATH=$PGHOME/bin:$PATH:
mkdir -p $PGDATA
initdb --no-locale -D $PGDATA
echo "local all postgres trust" > $PGDATA/pg_hba.conf
echo "local all all trust" >> $PGDATA/pg_hba.conf
echo "host all all 127.0.0.1/32 trust" >> $PGDATA/pg_hba.conf
echo "host all all ::1/128 trust" >> $PGDATA/pg_hba.conf
echo "wal_level = replica" >> $PGDATA/postgresql.conf
echo "archive_mode = on" >> $PGDATA/postgresql.conf
echo "archive_command = 'cp %p $ARCHIVEDIR/%f'" >> $PGDATA/postgresql.conf
pg_ctl -V
pg_ctl -D $PGDATA start
- name: show postgresql configuration
shell: bash -xe {0}
run: |
export PGHOME=~/pgsql/${{ env.PGVERSION }}
export PGDATA=~/pgdata/${{ env.PGVERSION }}
export PATH=$PGHOME/bin:$PATH:
pg_config --version
cat $PGDATA/postgresql.conf
- uses: actions/checkout@v2
- name: make install
shell: bash -xe {0}
run: |
export PGHOME=~/pgsql/${{ env.PGVERSION }}
export PATH=$PGHOME/bin:$PATH:
LOGFILE=~/make.log
make install 2>&1 | tee $LOGFILE
- name: show build warning
shell: bash -xe {0}
run: |
LOGFILE=~/make.log
grep -C 1 warning $LOGFILE || exit 0 # ok if warning doesn't exists (= status code is 1)
- name: make a .psqlrc file because there is a possibility that make installcheck may fail
shell: bash -xe {0}
run: echo '\\timing' > ~/.psqlrc
- name: make installcheck
shell: bash -xe {0}
run: |
export PGHOME=~/pgsql/${{ env.PGVERSION }}
export PATH=$PGHOME/bin:$PATH:
make installcheck
- name: show the result if the regression test failed
if: failure()
shell: bash -xe {0}
run: |
cat regression.diffs \
&& exit 1 # notify fail