-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
1,832 additions
and
205 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[target.'cfg(target_os="macos")'] | ||
# Postgres symbols won't be available until runtime | ||
rustflags = ["-Clink-arg=-Wl,-undefined,dynamic_lookup"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,231 @@ | ||
name: build-and-test | ||
description: Build and test pg_idkit (meant to run inside pg_idkit/builder container) | ||
inputs: | ||
artifact-upload: | ||
type: boolean | ||
default: false | ||
description: | | ||
Desired artifact name (will replace the natural name) | ||
artifact-tarball-suffix: | ||
type: string | ||
default: "gnu" | ||
description: | | ||
Suffix that will be used on the tarball artifact (ex. '-gnu') | ||
rust-container-version: | ||
type: string | ||
default: 1.76 | ||
description: | | ||
Version of rust to use in the container | ||
apt-cache-dir: | ||
type: string | ||
default: /var/cache/apt | ||
cargo-home-dir: | ||
type: string | ||
default: /usr/local/cargo | ||
cargo-target-dir: | ||
type: string | ||
default: /usr/local/build/target | ||
sccache-dir: | ||
type: string | ||
default: /usr/local/sccache | ||
cargo-build-rustc-wrapper: | ||
type: string | ||
default: /usr/local/cargo/bin/sccache | ||
cargo-env-incremental: | ||
type: string | ||
default: "0" | ||
cargo-env-profile: | ||
type: string | ||
default: ci | ||
user: | ||
type: string | ||
default: idkit | ||
pgrx-pg-version: | ||
type: string | ||
default: pg16 | ||
decription: | | ||
PGRX version (ex. 'pg15', 'pg16') | ||
pg-version: | ||
type: string | ||
default: 16.2 | ||
decription: | | ||
Postgres version (ex. '15.6, '16.2') | ||
outputs: {} | ||
runs: | ||
using: "composite" | ||
steps: | ||
# Checkout the repo | ||
- uses: actions/checkout@v3 | ||
|
||
######### | ||
# Cache # | ||
######### | ||
|
||
- name: Cache CARGO_HOME | ||
uses: actions/cache@v3 | ||
continue-on-error: false | ||
with: | ||
path: | | ||
${{ inputs.cargo-home-dir }} | ||
key: pg_idkit-tests-rust-${{ inputs.rust-container-version }}-cargo-${{ runner.os }} | ||
|
||
- name: Cache apt install | ||
uses: actions/cache@v3 | ||
continue-on-error: false | ||
with: | ||
path: | | ||
${{ inputs.apt-cache-dir }} | ||
key: pg_idkit-tests-apt-cache-${{ inputs.rust-container-version }}-cargo-${{ runner.os }} | ||
|
||
- name: Cache sccache | ||
uses: actions/cache@v3 | ||
continue-on-error: false | ||
with: | ||
path: | | ||
${{ inputs.sccache-dir }} | ||
key: pg_idkit-tests-sccache-${{ inputs.rust-container-version }}-cargo-${{ runner.os }} | ||
|
||
- name: Cache pgrx init | ||
uses: actions/cache@v3 | ||
continue-on-error: false | ||
with: | ||
path: | | ||
/home/${{ inputs.user }}/.pgrx | ||
key: pg_idkit-tests-pgrx-init-${{ inputs.rust-container-version }}-cargo-${{ runner.os }} | ||
|
||
######### | ||
# Setup # | ||
######### | ||
|
||
- name: Add idkit to group | ||
shell: bash | ||
run: | | ||
chgrp -R idkit $HOME && | ||
chgrp -R idkit /__w/pg_idkit && | ||
chmod g+w -R /__w/pg_idkit | ||
# Add directory used by worker as safe dir for git | ||
- name: Add git safe dir | ||
shell: bash | ||
run: | | ||
git config --global --add safe.directory /__w/pg_idkit/pg_idkit | ||
su idkit -c "git config --global --add safe.directory /__w/pg_idkit/pg_idkit" | ||
- name: Reinstall deps due to GLIBC issue | ||
if: ${{ inputs.artifact-upload }} | ||
shell: bash | ||
env: | ||
CARGO_BUILD_RUSTC_WRAPPER: ${{ inputs.cargo-build-rustc-wrapper }} | ||
CARGO_HOME: ${{ inputs.cargo-home-dir }} | ||
CARGO_INCREMENTAL: ${{ inputs.cargo-env-incrmental }} | ||
CARGO_PROFILE: ${{ inputs.cargo-profile }} | ||
CARGO_TARGET_DIR: ${{ inputs.cargo-target-dir }} | ||
PGRX_PG_VERSION: ${{ inputs.pgrx-pg-version }} | ||
PGRX_PKG_PATH_PREFIX: ${{ inputs.cargo-target-dir }} | ||
PKG_PG_VERSION: ${{ inputs.pg-version }} | ||
SCCACHE_DIR: ${{ inputs.sccache-dir }} | ||
DOCKER_BUILD_USER: ${{ inputs.user }} | ||
run: | | ||
su idkit -c "cargo install --locked --force cargo-get cargo-edit" | ||
############### | ||
# Build/Tests # | ||
############### | ||
|
||
# Initialize cargo-pgrx if necessary | ||
- name: Initialize cargo-pgrx | ||
shell: bash | ||
env: | ||
CARGO_BUILD_RUSTC_WRAPPER: ${{ inputs.cargo-build-rustc-wrapper }} | ||
CARGO_HOME: ${{ inputs.cargo-home-dir }} | ||
CARGO_INCREMENTAL: ${{ inputs.cargo-env-incrmental }} | ||
CARGO_PROFILE: ${{ inputs.cargo-profile }} | ||
CARGO_TARGET_DIR: ${{ inputs.cargo-target-dir }} | ||
PGRX_PG_VERSION: ${{ inputs.pgrx-pg-version }} | ||
PGRX_PKG_PATH_PREFIX: ${{ inputs.cargo-target-dir }} | ||
PKG_PG_VERSION: ${{ inputs.pg-version }} | ||
SCCACHE_DIR: ${{ inputs.sccache-dir }} | ||
DOCKER_BUILD_USER: ${{ inputs.user }} | ||
run: | | ||
su idkit -c "just pgrx-init" | ||
# Run cargo check | ||
- name: Run cargo check | ||
shell: bash | ||
env: | ||
CARGO_BUILD_RUSTC_WRAPPER: ${{ inputs.cargo-build-rustc-wrapper }} | ||
CARGO_HOME: ${{ inputs.cargo-home-dir }} | ||
CARGO_INCREMENTAL: ${{ inputs.cargo-env-incrmental }} | ||
CARGO_PROFILE: ${{ inputs.cargo-profile }} | ||
CARGO_TARGET_DIR: ${{ inputs.cargo-target-dir }} | ||
PGRX_PG_VERSION: ${{ inputs.pgrx-pg-version }} | ||
PGRX_PKG_PATH_PREFIX: ${{ inputs.cargo-target-dir }} | ||
PKG_PG_VERSION: ${{ inputs.pg-version }} | ||
SCCACHE_DIR: ${{ inputs.sccache-dir }} | ||
DOCKER_BUILD_USER: ${{ inputs.user }} | ||
run: | | ||
su idkit -c "cargo check" | ||
# Run cargo build | ||
- name: Run cargo test | ||
shell: bash | ||
env: | ||
CARGO_BUILD_RUSTC_WRAPPER: ${{ inputs.cargo-build-rustc-wrapper }} | ||
CARGO_HOME: ${{ inputs.cargo-home-dir }} | ||
CARGO_INCREMENTAL: ${{ inputs.cargo-env-incrmental }} | ||
CARGO_PROFILE: ${{ inputs.cargo-profile }} | ||
CARGO_TARGET_DIR: ${{ inputs.cargo-target-dir }} | ||
PGRX_PG_VERSION: ${{ inputs.pgrx-pg-version }} | ||
PGRX_PKG_PATH_PREFIX: ${{ inputs.cargo-target-dir }} | ||
PKG_PG_VERSION: ${{ inputs.pg-version }} | ||
SCCACHE_DIR: ${{ inputs.sccache-dir }} | ||
DOCKER_BUILD_USER: ${{ inputs.user }} | ||
run: | | ||
su idkit -c "cargo build" | ||
# Run cargo test | ||
- name: Run cargo test | ||
shell: bash | ||
env: | ||
CARGO_BUILD_RUSTC_WRAPPER: ${{ inputs.cargo-build-rustc-wrapper }} | ||
CARGO_HOME: ${{ inputs.cargo-home-dir }} | ||
CARGO_INCREMENTAL: ${{ inputs.cargo-env-incrmental }} | ||
CARGO_PROFILE: ${{ inputs.cargo-profile }} | ||
CARGO_TARGET_DIR: ${{ inputs.cargo-target-dir }} | ||
PGRX_PG_VERSION: ${{ inputs.pgrx-pg-version }} | ||
PKG_PG_VERSION: ${{ inputs.pg-version }} | ||
SCCACHE_DIR: ${{ inputs.sccache-dir }} | ||
DOCKER_BUILD_USER: ${{ inputs.user }} | ||
run: | | ||
su idkit -c "cargo test" | ||
############# | ||
# Artifacts # | ||
############# | ||
|
||
# Run cargo test | ||
- name: Build a package | ||
if: ${{ inputs.artifact-upload }} | ||
shell: bash | ||
env: | ||
CARGO_BUILD_RUSTC_WRAPPER: ${{ inputs.cargo-build-rustc-wrapper }} | ||
CARGO_HOME: ${{ inputs.cargo-home-dir }} | ||
CARGO_INCREMENTAL: ${{ inputs.cargo-env-incrmental }} | ||
CARGO_PROFILE: ${{ inputs.cargo-profile }} | ||
CARGO_TARGET_DIR: ${{ inputs.cargo-target-dir }} | ||
PGRX_PG_VERSION: ${{ inputs.pgrx-pg-version }} | ||
PGRX_PKG_PATH_PREFIX: ${{ inputs.cargo-target-dir }} | ||
PKG_PG_VERSION: ${{ inputs.pg-version }} | ||
PKG_TARBALL_SUFFIX: ${{ inputs.artifact-tarball-suffix }} | ||
SCCACHE_DIR: ${{ inputs.sccache-dir }} | ||
DOCKER_BUILD_USER: ${{ inputs.user }} | ||
run: | | ||
su idkit -c "just package" | ||
# Upload artifact | ||
- name: Upload artifact | ||
if: ${{ inputs.artifact-upload }} | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
path: pg_idkit-*.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
name: build-rpm | ||
description: Build an RPM for pg_idkit | ||
inputs: | ||
artifact-upload: | ||
type: boolean | ||
description: | | ||
Whether to upload an artifact or not | ||
artifact-name: | ||
type: string | ||
description: | | ||
Desired artifact name (will replace the natural name) | ||
gh-runner: | ||
type: string | ||
default: ubuntu-latest | ||
decription: | | ||
GitHub runner to use | ||
rpm-arch: | ||
type: string | ||
default: x86_64 | ||
decription: | | ||
Architecture to use while building the RPM | ||
pgrx-pg-version: | ||
type: string | ||
default: pg16 | ||
decription: | | ||
PGRX version (ex. 'pg15', 'pg16') | ||
pg-version: | ||
type: string | ||
default: 16.2 | ||
decription: | | ||
Postgres version (ex. '15.6, '16.2') | ||
cargo-pgrx-version: | ||
type: string | ||
default: 0.11.3 | ||
decription: | | ||
cargo-pgrx version (ex. '0.11.3') | ||
user: | ||
type: string | ||
default: runner | ||
outputs: {} | ||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Cache default PGRX_HOME | ||
uses: actions/cache@v3 | ||
continue-on-error: false | ||
with: | ||
path: | | ||
/home/runner/.pgrx | ||
key: pg_idkit-pkg-rpm-pgrx-${{ inputs.rpm-arch }}-${{ inputs.gh-runner }} | ||
|
||
- name: Install Rust deps | ||
uses: taiki-e/install-action@v2 | ||
with: | ||
tool: cargo-get,just,cargo-generate-rpm,cargo-pgrx@${{ inputs.cargo-pgrx-version }} | ||
|
||
- name: Initialize cargo-pgrx | ||
shell: bash | ||
env: | ||
PGRX_PG_VERSION: ${{ inputs.pgrx-pg-version }} | ||
PKG_PG_VERSION: ${{ inputs.pg-version }} | ||
run: | | ||
[[ -d /home/runner/.pgrx ]] || cargo pgrx init | ||
- name: Build RPM | ||
shell: bash | ||
env: | ||
DOCKER_BUILD_USER: ${{ inputs.user }} | ||
PGRX_PG_VERSION: ${{ inputs.pgrx-pg-version }} | ||
PKG_PG_VERSION: ${{ inputs.pg-version }} | ||
run: just package build-rpm | ||
|
||
- name: Get RPM output path | ||
id: rpm-output | ||
shell: bash | ||
env: | ||
DOCKER_BUILD_USER: ${{ inputs.user }} | ||
PGRX_PG_VERSION: ${{ inputs.pgrx-pg-version }} | ||
PKG_PG_VERSION: ${{ inputs.pg-version }} | ||
run: | | ||
echo path=$(just print-rpm-output-path) >> $GITHUB_OUTPUT | ||
echo filename=$(just print-rpm-output-file-name) >> $GITHUB_OUTPUT | ||
- name: Upload artifact | ||
if: ${{ inputs.artifact-upload }} | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ steps.rpm-output.outputs.filename }} | ||
path: ${{ steps.rpm-output.outputs.path }} |
Oops, something went wrong.