Skip to content

Commit

Permalink
use pgrx docker image to accelerate the dev-build/clippy/test
Browse files Browse the repository at this point in the history
Signed-off-by: Keming <[email protected]>
  • Loading branch information
kemingy committed Nov 1, 2024
1 parent 5f58f23 commit 6116646
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 23 deletions.
33 changes: 10 additions & 23 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,41 +40,28 @@ jobs:
strategy:
matrix:
arch: ["x86_64", "aarch64"]
env:
PGRX_IMAGE: "kemingy/pgrx:0.12.6"

steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Set up dev 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 clang
sudo apt-get install -y libreadline-dev zlib1g-dev flex bison libxml2-dev libxslt-dev libssl-dev libxml2-utils xsltproc ccache pkg-config
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
rustup target add x86_64-unknown-linux-gnu
rustup target add aarch64-unknown-linux-gnu
- name: Cache
uses: mozilla-actions/[email protected]
- name: Set up pgrx
- name: Set up docker images
run: |
cargo install cargo-pgrx --locked
cargo pgrx init
docker pull $PGRX_IMAGE
- name: Clippy
run: |
for v in {12..17}; do
cargo clippy --target ${{ matrix.arch }}-unknown-linux-gnu --features "pg$v" -- -D warnings
for v in {14..17}; do
docker run --rm -v .:/workspace $PGRX_IMAGE clippy --target ${{ matrix.arch }}-unknown-linux-gnu --features "pg$v" -- -D warnings
done
- name: Build
run: |
for v in {12..17}; do
cargo build --lib --target ${{ matrix.arch }}-unknown-linux-gnu --features "pg$v"
for v in {14..17}; do
docker run --rm -v .:/workspace $PGRX_IMAGE build --lib --target ${{ matrix.arch }}-unknown-linux-gnu --features "pg$v"
done
- name: Test
run: |
# pg agnostic tests
cargo test --no-fail-fast --target $ARCH-unknown-linux-gnu --features pg17
docker run --rm -v .:/workspace $PGRX_IMAGE test --no-fail-fast --target $ARCH-unknown-linux-gnu --features pg17
34 changes: 34 additions & 0 deletions docker/pgrx.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM ubuntu:22.04

ARG PGRX_VERSION=0.12.6
ARG RUSTC_WRAPPER=sccache

ENV DEBIAN_FRONTEND=noninteractive \
LANG=en_US.UTF-8 \
LC_ALL=en_US.UTF-8 \
RUSTC_WRAPPER=${RUSTC_WRAPPER} \
RUSTFLAGS="-Dwarnings"

RUN apt update && \
apt install -y --no-install-recommends \
curl \
ca-certificates \
build-essential \
crossbuild-essential-arm64 \
qemu-user-static \
libreadline-dev zlib1g-dev flex bison libxml2-dev libxslt-dev libssl-dev libxml2-utils xsltproc ccache pkg-config \
clang && \
rm -rf /var/lib/apt/lists/*

USER ubuntu
ENV PATH="$PATH:/home/ubuntu/.cargo/bin"
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain=none -y

WORKDIR /workspace
COPY rust-toolchain.toml /workspace/rust-toolchain.toml
RUN rustup target add x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu

RUN cargo install cargo-pgrx --locked --version=${PGRX_VERSION} && \
cargo pgrx init

ENTRYPOINT [ "cargo" ]

0 comments on commit 6116646

Please sign in to comment.