Skip to content

Commit a777d64

Browse files
authored
Montana/workflow (#1340)
1 parent 5905b57 commit a777d64

File tree

4 files changed

+29
-25
lines changed

4 files changed

+29
-25
lines changed

.github/workflows/ci.yml

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,17 @@ jobs:
99
run:
1010
working-directory: pgml-extension
1111
steps:
12-
- uses: actions/checkout@v3
12+
- uses: actions/checkout@v4
1313
with:
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
1619
id: pgml_extension_changed
1720
run: |
18-
echo "PGML_EXTENSION_CHANGED_FILES=$(git diff --name-only HEAD HEAD~1 . | wc -l)" >> $GITHUB_OUTPUT
19-
- name: Install dependencies
21+
echo "PGML_EXTENSION_CHANGED_FILES=$(git diff --name-only HEAD origin/master . | wc -l)" >> $GITHUB_OUTPUT
22+
- name: System dependencies
2023
if: steps.pgml_extension_changed.outputs.PGML_EXTENSION_CHANGED_FILES != '0'
2124
run: |
2225
sudo apt-get update && \
@@ -42,17 +45,8 @@ jobs:
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
5650
if: steps.pgml_extension_changed.outputs.PGML_EXTENSION_CHANGED_FILES != '0'
5751
run: |
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

pgml-extension/sql/setup_examples.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
--- Usage:
55
---
66
--- $ cargo pgrx run --release
7-
--- $ psql -P pager-off -h localhost -p 28813 -d pgml -f sql/setup_examples.sql
7+
--- $ psql -P pager-off -h localhost -p 28816 -d pgml -f sql/setup_examples.sql
88
---
99
-- \set ON_ERROR_STOP true
1010
\timing on

pgml-extension/src/orm/snapshot.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,9 @@ impl Snapshot {
749749
self.relation_name_quoted()
750750
)
751751
}
752-
false => self.test_sampling.get_sql(&self.relation_name_quoted(), self.columns.clone()),
752+
false => self
753+
.test_sampling
754+
.get_sql(&self.relation_name_quoted(), self.columns.clone()),
753755
}
754756
}
755757

pgml-extension/tests/test.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
--- Usage:
55
---
66
--- $ cargo pgrx run --release
7-
--- $ psql -h localhost -p 28815 -d pgml -f tests/test.sql -P pager
7+
--- $ psql -h localhost -p 28816 -d pgml -f tests/test.sql -P pager
88
---
99
\set ON_ERROR_STOP true
1010
\timing on

0 commit comments

Comments
 (0)