99run :
1010working-directory :pgml-extension
1111steps :
12- -uses :actions/checkout@v3
12+ -uses :actions/checkout@v4
1313with :
14- fetch-depth :2
14+ submodules :' recursive'
15+ -name :Fetch master
16+ run :|
17+ git fetch origin master --depth 1
1518 -name :Changed files in pgml-extension
1619id :pgml_extension_changed
1720run :|
18- echo "PGML_EXTENSION_CHANGED_FILES=$(git diff --name-only HEADHEAD~1 . | wc -l)" >> $GITHUB_OUTPUT
19- -name :Install dependencies
21+ echo "PGML_EXTENSION_CHANGED_FILES=$(git diff --name-only HEADorigin/master . | wc -l)" >> $GITHUB_OUTPUT
22+ -name :System dependencies
2023if :steps.pgml_extension_changed.outputs.PGML_EXTENSION_CHANGED_FILES != '0'
2124run :|
2225 sudo apt-get update && \
4245 ~/.cargo
4346 pgml-extension/target
4447 ~/.pgrx
45- key :${{ runner.os }}-rust-1.74-${{ hashFiles('pgml-extension/Cargo.lock') }}
46- -name :Submodules
47- if :steps.pgml_extension_changed.outputs.PGML_EXTENSION_CHANGED_FILES != '0'
48- run :|
49- git submodule update --init --recursive
50- -name :Get current version
51- id :current-version
52- run :echo "CI_BRANCH=$(git name-rev --name-only HEAD)" >> $GITHUB_OUTPUT
53- -name :Run tests
54- env :
55- CI_BRANCH :${{ steps.current-version.outputs.CI_BRANCH }}
48+ key :${{ runner.os }}-rust-1.74-${{ hashFiles('pgml-extension/Cargo.lock') }}-bust2
49+ -name :Install pgrx
5650if :steps.pgml_extension_changed.outputs.PGML_EXTENSION_CHANGED_FILES != '0'
5751run :|
5852 curl https://sh.rustup.rs -sSf | sh -s -- -y
@@ -61,15 +55,23 @@ jobs:
6155
6256 if [[ ! -d ~/.pgrx ]]; then
6357 cargo pgrx init
58+ echo "shared_preload_libraries = 'pgml'" >> ~/.pgrx/data-16/postgresql.conf
6459 fi
65-
66- git checkout master
60+ -name :Update extension test
61+ if :steps.pgml_extension_changed.outputs.PGML_EXTENSION_CHANGED_FILES != '0'
62+ run :|
63+ git checkout origin/master
6764 echo "\q" | cargo pgrx run
68- psql -p 28816 -h localhost -d pgml -P pager -c "CREATE EXTENSION pgml;"
69- git checkout $CI_BRANCH
65+ psql -p 28816 -h localhost -d pgml -P pager -c "DROP EXTENSION IF EXISTS pgml CASCADE; DROP SCHEMA IF EXISTS pgml CASCADE; CREATE EXTENSION pgml;"
66+ git checkout $GITHUB_SHA
7067 echo "\q" | cargo pgrx run
7168 psql -p 28816 -h localhost -d pgml -P pager -c "ALTER EXTENSION pgml UPDATE;"
69+ -name :Unit tests
70+ if :steps.pgml_extension_changed.outputs.PGML_EXTENSION_CHANGED_FILES != '0'
71+ run :|
7272 cargo pgrx test
73- # cargo pgrx start
74- # psql -p 28815 -h 127.0.0.1 -d pgml -P pager -f tests/test.sql
75- # cargo pgrx stop
73+ -name :Integration tests
74+ if :steps.pgml_extension_changed.outputs.PGML_EXTENSION_CHANGED_FILES != '0'
75+ run :|
76+ echo "\q" | cargo pgrx run
77+ psql -p 28816 -h 127.0.0.1 -d pgml -P pager -f tests/test.sql