Skip to content

Commit

Permalink
ci: update ci to pgrx docker image
Browse files Browse the repository at this point in the history
Signed-off-by: Mingzhuo Yin <[email protected]>
  • Loading branch information
silver-ymz committed Nov 18, 2024
1 parent 6b7bbe8 commit f207792
Show file tree
Hide file tree
Showing 20 changed files with 50 additions and 480,793 deletions.
125 changes: 48 additions & 77 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,98 +1,69 @@
name: Rust

on:
push:
branches: ["main"]
paths:
- ".cargo/**"
- ".github/**"
- "src/**"
- "Cargo.lock"
- "Cargo.toml"
- "pg_bm25.control"
- "vendor/**"
pull_request:
branches: ["main"]
paths:
- ".cargo/**"
- ".github/**"
- "src/**"
- "Cargo.lock"
- "Cargo.toml"
- "pg_bm25.control"
- "vendor/**"
- '.github/workflows/rust.yml'
- 'src/**'
- 'Cargo.lock'
- 'Cargo.toml'
- '*.control'
- 'rust-toolchain.toml'
push:
branches:
- main
paths:
- '.github/workflows/rust.yml'
- 'src/**'
- 'Cargo.lock'
- 'Cargo.toml'
- '*.control'
- 'rust-toolchain.toml'
merge_group:
workflow_dispatch:

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
SCCACHE_GHA_ENABLED: true
RUSTC_WRAPPER: sccache
RUSTFLAGS: "-Dwarnings"

jobs:
check:
test:
runs-on: ubuntu-latest
strategy:
matrix:
version: [14, 15, 16, 17]
arch: ["x86_64"]
runs-on: ubuntu-latest
arch: ["x86_64", "aarch64"]
env:
SEMVER: "0.0.0"
VERSION: ${{ matrix.version }}
ARCH: ${{ matrix.arch }}
PGRX_IMAGE: "kemingy/pgrx:0.12.8"

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Environment
run: |
sudo apt-get remove -y '^postgres.*' '^libpq.*' '^clang.*' '^llvm.*' '^libclang.*' '^libllvm.*' '^mono-llvm.*'
sudo apt-get purge -y '^postgres.*' '^libpq.*' '^clang.*' '^llvm.*' '^libclang.*' '^libllvm.*' '^mono-llvm.*'
sudo apt-get update
sudo apt-get install -y build-essential crossbuild-essential-arm64
sudo apt-get install -y qemu-user-static
touch ~/.cargo/config.toml
echo 'target.aarch64-unknown-linux-gnu.linker = "aarch64-linux-gnu-gcc"' >> ~/.cargo/config.toml
echo 'target.aarch64-unknown-linux-gnu.runner = ["qemu-aarch64-static", "-L", "/usr/aarch64-linux-gnu"]' >> ~/.cargo/config.toml
- name: Set up Sccache
uses: mozilla-actions/[email protected]
- name: Set up Cache
uses: actions/cache/restore@v4
id: cache
- uses: actions/checkout@v4
- name: Configure sccache
uses: actions/github-script@v7
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ github.job }}-${{ hashFiles('./Cargo.lock') }}-${{ matrix.version }}-${{ matrix.arch }}
- name: Set up Pgrx
script: |
const url = process.env.ACTIONS_CACHE_URL || '';
const token = process.env.ACTIONS_RUNTIME_TOKEN || '';
core.exportVariable(
'CACHE_ENVS',
`-e CARGO_INCREMENTAL=0 -e SCCACHE_GHA_ENABLED=true -e RUSTC_WRAPPER=sccache -e ACTIONS_CACHE_URL=${url} -e ACTIONS_RUNTIME_TOKEN=${token}`,
);
- name: Set up docker images and permissions
run: |
# pg_config
mkdir -p ~/.pg_config
touch ~/.pg_config/pg_config
chmod 777 ~/.pg_config/pg_config
echo "#!/usr/bin/env bash" >> ~/.pg_config/pg_config
echo "$(pwd)/tools/pg_config.sh \"\$@\" < $(pwd)/vendor/pg_config/pg${VERSION}_${ARCH}-unknown-linux-gnu.txt" >> ~/.pg_config/pg_config
mkdir -p ~/.pgrx && echo "configs.pg$VERSION=\"$HOME/.pg_config/pg_config\"" > ~/.pgrx/config.toml
# pgrx_binding
mkdir -p ~/.pgrx_binding
cp ./vendor/pgrx_binding/pg${VERSION}_$(uname --machine)-unknown-linux-gnu.rs ~/.pgrx_binding/pg${VERSION}_raw_bindings.rs
echo PGRX_TARGET_INFO_PATH_PG$VERSION=$HOME/.pgrx_binding >> "$GITHUB_ENV"
docker pull $PGRX_IMAGE
echo "Default user: $(id -u):$(id -g)"
sudo chown -R 1000:1000 .
- name: Clippy
run: cargo clippy --features "pg$VERSION" --target $ARCH-unknown-linux-gnu
run: |
for v in {14..17}; do
docker run --rm -v .:/workspace $CACHE_ENVS $PGRX_IMAGE clippy --target ${{ matrix.arch }}-unknown-linux-gnu --features "pg$v" -- -D warnings
done
- name: Build
run: cargo build --lib --features "pg$VERSION" --target $ARCH-unknown-linux-gnu
- name: Post Set up Cache
uses: actions/cache/save@v4
if: ${{ !steps.cache.outputs.cache-hit }}
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ github.job }}-${{ hashFiles('./Cargo.lock') }}-${{ matrix.version }}-${{ matrix.arch }}
run: |
for v in {14..17}; do
docker run --rm -v .:/workspace $CACHE_ENVS $PGRX_IMAGE build --lib --target ${{ matrix.arch }}-unknown-linux-gnu --features "pg$v"
done
- name: Test
run: |
# pg agnostic tests
docker run --rm -v .:/workspace $CACHE_ENVS $PGRX_IMAGE test --no-fail-fast --target ${{ matrix.arch }}-unknown-linux-gnu --features pg17
52 changes: 0 additions & 52 deletions .github/workflows/update_vendor.yml

This file was deleted.

26 changes: 0 additions & 26 deletions scripts/update_vendor.sh

This file was deleted.

4 changes: 2 additions & 2 deletions src/page/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,8 @@ pub fn page_get_item<T>(page: &PageData, item_id: pgrx::pg_sys::ItemIdData) -> &
pub fn page_append_item(page: &mut PageData, item: &[u8]) -> bool {
let offset_number = unsafe {
pgrx::pg_sys::PageAddItemExtended(
page as *mut _ as *mut i8,
item.as_ptr() as *const i8 as *mut i8,
page as *mut _ as _,
item.as_ptr() as *const _ as _,
item.len(),
pgrx::pg_sys::InvalidOffsetNumber,
0,
Expand Down
23 changes: 0 additions & 23 deletions vendor/pg_config/pg14_aarch64-unknown-linux-gnu.txt

This file was deleted.

23 changes: 0 additions & 23 deletions vendor/pg_config/pg14_x86_64-unknown-linux-gnu.txt

This file was deleted.

23 changes: 0 additions & 23 deletions vendor/pg_config/pg15_aarch64-unknown-linux-gnu.txt

This file was deleted.

Loading

0 comments on commit f207792

Please sign in to comment.