Skip to content

Commit 52c9bba

Browse files
committed
CI Refactoring: Unify code of all three CI workflows
1 parent 5addf94 commit 52c9bba

File tree

3 files changed

+190
-153
lines changed

3 files changed

+190
-153
lines changed

.github/workflows/c-cpp.yml

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
name: 'AQO basic CI'
22

3-
on:
4-
pull_request:
5-
63
env:
4+
# Use it just for a report
75
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
86

7+
# Trigger it each timeon push or pull request. Honestly, it will be redundant
8+
# most of the time, but external pull-request checks don't be missed out.
9+
on:
10+
push:
11+
pull_request:
12+
913
jobs:
1014
build:
1115

@@ -15,7 +19,11 @@ jobs:
1519
- uses: actions/checkout@v3
1620
- name: "Define PostreSQL major version"
1721
run: |
18-
echo "$(ls -la)"
22+
echo "The action workflow is triggered by the $BRANCH_NAME"
23+
sudo apt install libipc-run-perl
24+
git config --global user.email "[email protected]"
25+
git config --global user.name "CI PgPro admin"
26+
1927
patch_name=$(ls aqo_*.patch|tail -1)
2028
echo "CORE_PATCH_NAME=$patch_name" >> $GITHUB_ENV
2129
@@ -25,39 +33,43 @@ jobs:
2533
2634
branch_name="REL_${vers_number}_STABLE"
2735
echo "PG_BRANCH=$branch_name" >> $GITHUB_ENV
28-
29-
echo "COPT=-Werror" >> $GITHUB_ENV
30-
echo "CONFIGURE_OPTS=--prefix=`pwd`/tmp_install --enable-tap-tests --enable-cassert" >> $GITHUB_ENV
31-
3236
- name: "Set master branch name, if needed"
3337
if: env.PG_MAJOR_VERSION == ''
3438
run: |
3539
branch_name="master"
3640
echo "PG_BRANCH=$branch_name" >> $GITHUB_ENV
3741
38-
- name: "Environment (debug output)"
39-
if: ${{ always() }}
42+
# Create workspace directory and environment variable.
43+
# It is the second step because on the first we define versions and branches
44+
- name: "Initial dir"
4045
run: |
41-
echo "Use PostgreSQL branch $PG_BRANCH (patch: $CORE_PATCH_NAME)"
42-
echo "COPT: $COPT"
43-
echo "CONFIGURE_OPTS: $CONFIGURE_OPTS"
44-
echo "Deploying to production server on branch" $BRANCH_NAME "(PG $PG_BRANCH)"
45-
git config --global user.email "[email protected]"
46-
git config --global user.name "CI PgPro admin"
46+
git clone -b $PG_BRANCH --depth=1 --single-branch https://github.com/postgres/postgres.git $GITHUB_WORKSPACE/../pg
47+
48+
# Invent variable with full path to PG directory just because github
49+
# actions don't like relative paths ...
50+
cd $GITHUB_WORKSPACE/../pg
51+
echo PG_DIR=`pwd` >> $GITHUB_ENV
4752
4853
- name: "Prepare PG directory"
4954
run: |
50-
git clone -b $PG_BRANCH --depth=1 --single-branch https://github.com/postgres/postgres.git $GITHUB_WORKSPACE/../pg
51-
cd $GITHUB_WORKSPACE/../pg
52-
ls -la
55+
cd $PG_DIR
5356
cp -r ../aqo contrib/aqo
5457
patch -p1 --no-backup-if-mismatch < contrib/aqo/$CORE_PATCH_NAME
58+
echo "COPT=-Werror" >> $GITHUB_ENV
59+
echo "CONFIGURE_OPTS=--prefix=`pwd`/tmp_install --enable-tap-tests --enable-cassert" >> $GITHUB_ENV
5560
56-
- name: "make check"
61+
# Just for debug
62+
- name: "Environment (debug output)"
63+
if: ${{ always() }}
5764
run: |
58-
sudo apt install libipc-run-perl
65+
echo "PG_MAJOR_VERSION: $PG_MAJOR_VERSION"
66+
echo "PG_DIR: $PG_DIR"
67+
echo "PG_BRANCH: $PG_BRANCH"
68+
echo "CORE_PATCH_NAME: $CORE_PATCH_NAME"
5969
60-
cd $GITHUB_WORKSPACE/../pg
70+
- name: "make check"
71+
run: |
72+
cd $PG_DIR
6173
./configure $CONFIGURE_OPTS CFLAGS="-O2" > /dev/null
6274
make -j4 > /dev/null && make -j4 -C contrib > /dev/null
6375
env CLIENTS=50 THREADS=50 make -C contrib/aqo check
@@ -70,12 +82,12 @@ jobs:
7082
env CLIENTS=50 THREADS=50 make -C contrib/aqo check
7183
7284
- name: Archive artifacts
73-
if: ${{ always() }}
85+
if: ${{ failure() }}
7486
uses: actions/upload-artifact@v3
7587
with:
7688
name: make_check_logs
7789
path: |
78-
/home/runner/work/aqo/pg/contrib/aqo/regression.diffs
79-
/home/runner/work/aqo/pg/contrib/aqo/log
80-
/home/runner/work/aqo/pg/contrib/aqo/tmp_check/log
90+
${{ env.PG_DIR }}/contrib/aqo/regression.diffs
91+
${{ env.PG_DIR }}/contrib/aqo/log
92+
${{ env.PG_DIR }}/contrib/aqo/tmp_check/log
8193
retention-days: 7

.github/workflows/installchecks.yml

Lines changed: 71 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,92 @@
11
name: "InstallChecks"
22

3-
on:
4-
push:
5-
63
env:
4+
# Use it just for a report
75
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
86

7+
# Trigger it each timeon push or pull request. Honestly, it will be redundant
8+
# most of the time, but external pull-request checks don't be missed out.
9+
on:
10+
push:
11+
pull_request:
12+
913
jobs:
1014
build:
1115

1216
runs-on: ubuntu-latest
1317

1418
steps:
15-
16-
# Set major PostgreSQL version for all underlying steps
17-
- name: "Extract Postgres major version number"
19+
- uses: actions/checkout@v3
20+
- name: "Define PostreSQL major version and set basic environment"
1821
run: |
19-
PG_MAJOR_VERSION=$(echo "$BRANCH_NAME" | grep --only-matching 'stable[0-9].' | grep --only-matching '[0-9].')
22+
echo "The action workflow is triggered by the $BRANCH_NAME"
23+
sudo apt install libipc-run-perl
24+
git config --global user.email "[email protected]"
25+
git config --global user.name "CI PgPro admin"
26+
27+
patch_name=$(ls aqo_*.patch|tail -1)
28+
echo "CORE_PATCH_NAME=$patch_name" >> $GITHUB_ENV
29+
30+
# we can get number, otherwise set up master
31+
vers_number=$(echo "$patch_name"|tr -d -c 0-9)
32+
echo "PG_MAJOR_VERSION=$vers_number" >> $GITHUB_ENV
2033
21-
# Declare PG_MAJOR_VERSION as a environment variable
22-
echo "PG_MAJOR_VERSION=$PG_MAJOR_VERSION" >> $GITHUB_ENV
23-
echo "CORE_BRANCH_NAME=REL_${PG_MAJOR_VERSION}_STABLE" >> $GITHUB_ENV
24-
echo "AQO_PATCH_NAME=aqo_pg$PG_MAJOR_VERSION.patch" >> $GITHUB_ENV
25-
- name: "Set proper names for the master case"
34+
branch_name="REL_${vers_number}_STABLE"
35+
echo "PG_BRANCH=$branch_name" >> $GITHUB_ENV
36+
- name: "Set master branch name, if needed"
2637
if: env.PG_MAJOR_VERSION == ''
2738
run: |
28-
echo "PG_MAJOR_VERSION=master" >> $GITHUB_ENV
29-
echo "CORE_BRANCH_NAME=master" >> $GITHUB_ENV
30-
echo "AQO_PATCH_NAME=aqo_master.patch" >> $GITHUB_ENV
39+
branch_name="master"
40+
echo "PG_BRANCH=$branch_name" >> $GITHUB_ENV
3141
32-
- name: "Preparations"
42+
# Create workspace directory and environment variable.
43+
# It is the second step because on the first we define versions and branches
44+
- name: "Initial dir"
3345
run: |
34-
sudo apt install libipc-run-perl libxml2-utils libxml2-dev xsltproc libxslt1-dev
46+
git clone -b $PG_BRANCH --depth=1 --single-branch https://github.com/postgres/postgres.git $GITHUB_WORKSPACE/../pg
3547
36-
echo "Deploying to production server on branch" $BRANCH_NAME
37-
git config --global user.email "[email protected]"
38-
git config --global user.name "CI PgPro admin"
39-
git clone https://github.com/postgres/postgres.git pg
40-
cd pg
41-
git checkout $CORE_BRANCH_NAME
42-
git clone https://github.com/postgrespro/aqo.git contrib/aqo
43-
git -C contrib/aqo checkout $BRANCH_NAME
44-
patch -p1 --no-backup-if-mismatch < contrib/aqo/$AQO_PATCH_NAME
45-
COPT="-Werror"
46-
CONFIGURE_OPTS="--prefix=`pwd`/tmp_install --enable-tap-tests --enable-cassert"
47-
echo "CONFIGURE_OPTS=$CONFIGURE_OPTS" >> $GITHUB_ENV
48-
echo "COPT=$COPT" >> $GITHUB_ENV
49-
50-
- name: "Paths"
48+
# Invent variable with full path to PG directory just because github
49+
# actions don't like relative paths ...
50+
cd $GITHUB_WORKSPACE/../pg
51+
echo PG_DIR=`pwd` >> $GITHUB_ENV
52+
53+
- name: "Prepare PG directory"
5154
run: |
52-
echo "$GITHUB_WORKSPACE/pg/contrib/aqo/.github/scripts/job" >> $GITHUB_PATH
53-
ls -la pg/contrib/aqo/.github/scripts/job
54-
echo "$GITHUB_WORKSPACE/pg/tmp_install/bin" >> $GITHUB_PATH
55-
echo "LD_LIBRARY_PATH=$GITHUB_WORKSPACE/pg/tmp_install/lib" >> $GITHUB_ENV
56-
echo "PGDATABASE=`whoami`" >> $GITHUB_ENV
57-
echo "PGHOST=localhost" >> $GITHUB_ENV
58-
echo "PGDATA=PGDATA" >> $GITHUB_ENV
59-
echo "PGUSER=`whoami`" >> $GITHUB_ENV
60-
echo "PGPORT=5432" >> $GITHUB_ENV
61-
62-
- name: "Debug"
55+
cd $PG_DIR
56+
cp -r ../aqo contrib/aqo
57+
patch -p1 --no-backup-if-mismatch < contrib/aqo/$CORE_PATCH_NAME
58+
echo "COPT=-Werror" >> $GITHUB_ENV
59+
echo "CONFIGURE_OPTS=--prefix=`pwd`/tmp_install --enable-tap-tests --enable-cassert" >> $GITHUB_ENV
60+
61+
# Instance-related environment
62+
echo "$PG_DIR/tmp_install/bin" >> $GITHUB_PATH
63+
echo "LD_LIBRARY_PATH=$PG_DIR/tmp_install/lib" >> $GITHUB_ENV
64+
echo `pwd`/contrib/aqo/.github/scripts/job >> $GITHUB_PATH
65+
66+
# Just for debug
67+
- name: "Environment (debug output)"
68+
if: ${{ always() }}
6369
run: |
64-
echo "paths: $PATH"
65-
echo "PG_MAJOR_VERSION: $PG_MAJOR_VERSION, CORE_BRANCH_NAME: $CORE_BRANCH_NAME, AQO_PATCH_NAME: $AQO_PATCH_NAME, CONFIGURE_OPTS: $CONFIGURE_OPTS"
70+
echo "PG_MAJOR_VERSION: $PG_MAJOR_VERSION"
71+
echo "PG_DIR: $PG_DIR"
72+
echo "PG_BRANCH: $PG_BRANCH"
73+
echo "CORE_PATCH_NAME: $CORE_PATCH_NAME"
74+
# See these paths to understand correctness of the instance initialization
75+
echo "PATHs: $PATH"
76+
echo "PG Libs: $LD_LIBRARY_PATH"
6677
6778
- name: "Compilation"
6879
run: |
69-
cd pg
70-
./configure $CONFIGURE_OPTS CFLAGS="-O2"
80+
cd $PG_DIR
81+
echo "COPT: $COPT"
82+
echo "CONFIGURE_OPTS: $CONFIGURE_OPTS"
83+
./configure $CONFIGURE_OPTS CFLAGS="-O2" > /dev/null
7184
make -j4 > /dev/null && make -j4 -C contrib > /dev/null
7285
make install >> make.log && make -C contrib install > /dev/null
7386
7487
- name: "Launch AQO instance"
7588
run: |
76-
cd pg
89+
cd $PG_DIR
7790
7891
# Launch an instance with AQO extension
7992
aqo_instance_launch.sh
@@ -84,29 +97,29 @@ jobs:
8497
# Pass installcheck in disabled mode
8598
- name: installcheck_disabled
8699
run: |
87-
cd pg
100+
cd $PG_DIR
88101
psql -c "ALTER SYSTEM SET aqo.force_collect_stat = 'off'"
89102
psql -c "SELECT pg_reload_conf()"
90103
make installcheck-world
91104
92105
- name: installcheck_disabled_forced_stat
93106
run: |
94-
cd pg
107+
cd $PG_DIR
95108
psql -c "ALTER SYSTEM SET aqo.force_collect_stat = 'on'"
96109
psql -c "SELECT pg_reload_conf()"
97110
make installcheck-world
98111
99112
- name: installcheck_frozen
100113
run: |
101-
cd pg
114+
cd $PG_DIR
102115
psql -c "ALTER SYSTEM SET aqo.mode = 'frozen'"
103116
psql -c "ALTER SYSTEM SET aqo.force_collect_stat = 'on'"
104117
psql -c "SELECT pg_reload_conf()"
105118
make installcheck-world
106119
107120
- name: installcheck_controlled
108121
run: |
109-
cd pg
122+
cd $PG_DIR
110123
psql -c "ALTER SYSTEM SET aqo.mode = 'controlled'"
111124
psql -c "ALTER SYSTEM SET aqo.force_collect_stat = 'on'"
112125
psql -c "SELECT pg_reload_conf()"
@@ -115,7 +128,7 @@ jobs:
115128
- name: installcheck_learn
116129
continue-on-error: true
117130
run: |
118-
cd pg
131+
cd $PG_DIR
119132
psql -c "ALTER SYSTEM SET aqo.mode = 'learn'"
120133
psql -c "ALTER SYSTEM SET aqo.force_collect_stat = 'on'"
121134
psql -c "SELECT pg_reload_conf()"
@@ -124,7 +137,7 @@ jobs:
124137
- name: installcheck_intelligent
125138
continue-on-error: true
126139
run: |
127-
cd pg
140+
cd $PG_DIR
128141
psql -c "ALTER SYSTEM SET aqo.mode = 'intelligent'"
129142
psql -c "ALTER SYSTEM SET aqo.force_collect_stat = 'on'"
130143
psql -c "SELECT pg_reload_conf()"
@@ -133,7 +146,7 @@ jobs:
133146
- name: installcheck_forced
134147
continue-on-error: true
135148
run: |
136-
cd pg
149+
cd $PG_DIR
137150
psql -c "ALTER SYSTEM SET aqo.mode = 'forced'"
138151
psql -c "ALTER SYSTEM SET aqo.force_collect_stat = 'on'"
139152
psql -c "SELECT pg_reload_conf()"
@@ -146,8 +159,8 @@ jobs:
146159
with:
147160
name: ${{ env.AQO_VERSION }}-${{ env.CORE_BRANCH_NAME }}-${{ env.BRANCH_NAME }}-artifacts
148161
path: |
149-
pg/src/test/regress/regression.diffs
150-
pg/logfile.log
151-
pg/contrib/aqo/tmp_check/log
162+
${{ env.PG_DIR }}/src/test/regress/regression.diffs
163+
${{ env.PG_DIR }}/logfile.log
164+
${{ env.PG_DIR }}/contrib/aqo/tmp_check/log
152165
retention-days: 2
153166

0 commit comments

Comments
 (0)