Skip to content

Commit

Permalink
ci: run ci when updating tests dir (#92)
Browse files Browse the repository at this point in the history
* ci: run ci when updating tests dir

Signed-off-by: silver-ymz <yinmingzhuo@gmail.com>

* change src

Signed-off-by: silver-ymz <yinmingzhuo@gmail.com>

* use sudo to install extension

Signed-off-by: silver-ymz <yinmingzhuo@gmail.com>

* update ci

Signed-off-by: silver-ymz <yinmingzhuo@gmail.com>

* Elevate permissions

Signed-off-by: silver-ymz <yinmingzhuo@gmail.com>

* update ci

Signed-off-by: silver-ymz <yinmingzhuo@gmail.com>

* fix wrong quotation marks in command

Signed-off-by: silver-ymz <yinmingzhuo@gmail.com>

* fix wrong quotation marks in command

Signed-off-by: silver-ymz <yinmingzhuo@gmail.com>

* use ankane/setup-postgres

Signed-off-by: silver-ymz <yinmingzhuo@gmail.com>

* chmod for postgres dir

Signed-off-by: silver-ymz <yinmingzhuo@gmail.com>

* fix indent

Signed-off-by: silver-ymz <yinmingzhuo@gmail.com>

* set testdb

Signed-off-by: silver-ymz <yinmingzhuo@gmail.com>

* add github cache

Signed-off-by: silver-ymz <yinmingzhuo@gmail.com>

* alter password

Signed-off-by: silver-ymz <yinmingzhuo@gmail.com>

* ignore if binary installed

Signed-off-by: silver-ymz <yinmingzhuo@gmail.com>

* update pg_config path

Signed-off-by: silver-ymz <yinmingzhuo@gmail.com>

* revert ankane/setup-postgres

Signed-off-by: silver-ymz <yinmingzhuo@gmail.com>

* use sccache

Signed-off-by: silver-ymz <yinmingzhuo@gmail.com>

* close previous postgres

Signed-off-by: silver-ymz <yinmingzhuo@gmail.com>

* fix wrong quotation marks

Signed-off-by: silver-ymz <yinmingzhuo@gmail.com>

---------

Signed-off-by: silver-ymz <yinmingzhuo@gmail.com>
  • Loading branch information
silver-ymz authored Oct 17, 2023
1 parent bdcb899 commit 4fb1dd5
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 11 deletions.
72 changes: 63 additions & 9 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@ on:
push:
branches: [ "main" ]
paths:
- '.github/workflows/check.yml'
- 'src/**'
- 'Cargo.toml'
- 'Cargo.lock'
- 'rust-toolchain.toml'
- 'tests/**'
pull_request:
branches: [ "main" ]
paths:
- '.github/workflows/check.yml'
- 'src/**'
- 'Cargo.toml'
- 'Cargo.lock'
- 'rust-toolchain.toml'
- 'tests/**'
merge_group:
workflow_dispatch:

Expand All @@ -24,6 +28,8 @@ concurrency:

env:
CARGO_TERM_COLOR: always
SCCACHE_GHA_ENABLED: true
RUSTC_WRAPPER: sccache

jobs:
lint:
Expand All @@ -33,13 +39,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache/restore@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: cargo-${{ runner.os }}-pg${{ matrix.version }}-${{ hashFiles('./Cargo.toml') }}
restore-keys: cargo-${{ runner.os }}-pg${{ matrix.version }}
- uses: mozilla-actions/sccache-action@v0.0.3
- name: Prepare
run: |
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install libpq-dev postgresql-${{ matrix.version }} postgresql-server-dev-${{ matrix.version }}
cargo install cargo-pgrx --git https://github.com/tensorchord/pgrx.git --rev $(cat Cargo.toml | grep "pgrx =" | awk -F'rev = "' '{print $2}' | cut -d'"' -f1)
cargo install cargo-pgrx --git https://github.com/tensorchord/pgrx.git --rev $(cat Cargo.toml | grep "pgrx =" | awk -F'rev = "' '{print $2}' | cut -d'"' -f1) || true
cargo pgrx init --pg${{ matrix.version }}=/usr/lib/postgresql/${{ matrix.version }}/bin/pg_config
- name: Format check
run: cargo fmt --check
Expand All @@ -53,13 +69,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache/restore@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: cargo-${{ runner.os }}-pg${{ matrix.version }}-${{ hashFiles('./Cargo.toml') }}
restore-keys: cargo-${{ runner.os }}-pg${{ matrix.version }}
- uses: mozilla-actions/sccache-action@v0.0.3
- name: Prepare
run: |
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install libpq-dev postgresql-${{ matrix.version }} postgresql-server-dev-${{ matrix.version }}
cargo install cargo-pgrx --git https://github.com/tensorchord/pgrx.git --rev $(cat Cargo.toml | grep "pgrx =" | awk -F'rev = "' '{print $2}' | cut -d'"' -f1)
cargo install cargo-pgrx --git https://github.com/tensorchord/pgrx.git --rev $(cat Cargo.toml | grep "pgrx =" | awk -F'rev = "' '{print $2}' | cut -d'"' -f1) || true
cargo pgrx init --pg${{ matrix.version }}=/usr/lib/postgresql/${{ matrix.version }}/bin/pg_config
- name: Build
run: cargo build --verbose
Expand All @@ -75,19 +101,47 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache/restore@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: cargo-${{ runner.os }}-pg${{ matrix.version }}-${{ hashFiles('./Cargo.toml') }}
restore-keys: cargo-${{ runner.os }}-pg${{ matrix.version }}
- uses: mozilla-actions/sccache-action@v0.0.3
- name: Prepare
run: |
sudo pg_dropcluster 14 main
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install libpq-dev postgresql-${{ matrix.version }} postgresql-server-dev-${{ matrix.version }}
cargo install cargo-pgrx --git https://github.com/tensorchord/pgrx.git --rev $(cat Cargo.toml | grep "pgrx =" | awk -F'rev = "' '{print $2}' | cut -d'"' -f1)
cargo install cargo-pgrx --git https://github.com/tensorchord/pgrx.git --rev $(cat Cargo.toml | grep "pgrx =" | awk -F'rev = "' '{print $2}' | cut -d'"' -f1) || true
cargo pgrx init --pg${{ matrix.version }}=/usr/lib/postgresql/${{ matrix.version }}/bin/pg_config
cargo install sqllogictest-bin
- name: Build && Install
run: cargo pgrx install --release
cargo install sqllogictest-bin || true
- uses: actions/cache/save@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: cargo-${{ runner.os }}-pg${{ matrix.version }}-${{ hashFiles('./Cargo.toml') }}
- name: Build
run: |
sudo chmod -R 777 /usr/share/postgresql/${{ matrix.version }}/extension
sudo chmod -R 777 /usr/lib/postgresql/${{ matrix.version }}/lib
cargo pgrx install --release
sudo systemctl start postgresql@${{ matrix.version }}-main
sudo -u postgres psql -c "CREATE USER $USER LOGIN SUPERUSER"
sudo -u postgres psql -c "CREATE DATABASE $USER OWNER $USER"
psql -c 'ALTER SYSTEM SET shared_preload_libraries = "vectors.so"'
sudo systemctl restart postgresql@${{ matrix.version }}-main
- name: Sqllogictest
run: |
sudo systemctl restart postgresql
sudo -u postgres psql -f tests/init.sql
sudo -u postgres sqllogictest './tests/**/*.slt'
export password=$(openssl rand -base64 32)
psql -c "ALTER USER $USER WITH PASSWORD '$password'"
psql -f ./tests/init.sql
sqllogictest -u "$USER" -w "$password" -d "$USER" './tests/**/*.slt'
14 changes: 13 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ permissions:

env:
CARGO_TERM_COLOR: always
SCCACHE_GHA_ENABLED: true
RUSTC_WRAPPER: sccache

jobs:
setup:
Expand Down Expand Up @@ -107,13 +109,23 @@ jobs:
uses: actions/checkout@v3
with:
ref: ${{ needs.setup.outputs.ref }}
- uses: actions/cache/restore@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: cargo-${{ runner.os }}-pg${{ matrix.version }}-${{ hashFiles('./Cargo.toml') }}
restore-keys: cargo-${{ runner.os }}-pg${{ matrix.version }}
- uses: mozilla-actions/sccache-action@v0.0.3
- name: Prepare
run: |
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install libpq-dev postgresql-${{ matrix.version }} postgresql-server-dev-${{ matrix.version }}
cargo install cargo-pgrx --git https://github.com/tensorchord/pgrx.git --rev $(cat Cargo.toml | grep "pgrx =" | awk -F'rev = "' '{print $2}' | cut -d'"' -f1)
cargo install cargo-pgrx --git https://github.com/tensorchord/pgrx.git --rev $(cat Cargo.toml | grep "pgrx =" | awk -F'rev = "' '{print $2}' | cut -d'"' -f1) || true
cargo pgrx init --pg${{ matrix.version }}=/usr/lib/postgresql/${{ matrix.version }}/bin/pg_config
- name: Build Release
id: build_release
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ mod postgres;
mod prelude;

pgrx::pg_module_magic!();

pgrx::extension_sql_file!("./sql/bootstrap.sql", bootstrap);
pgrx::extension_sql_file!("./sql/finalize.sql", finalize);

Expand Down

0 comments on commit 4fb1dd5

Please sign in to comment.