-
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.
Merge pull request #2 from spa5k/rewrite
- Loading branch information
Showing
23 changed files
with
1,330 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,8 @@ | ||
.git | ||
.github | ||
.gitignore | ||
*.md | ||
*.yml | ||
|
||
target | ||
Cargo.lock |
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,58 @@ | ||
name: CI | ||
on: | ||
pull_request: | ||
branches: [main, rewrite] | ||
types: [opened, reopened, synchronize] | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
jobs: | ||
ci: | ||
name: CI | ||
needs: [test, lint, lockfile] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Done | ||
run: exit 0 | ||
test: | ||
name: Tests | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
postgres: [14, 15, 16] | ||
runner: | ||
- ubuntu-22.04 | ||
- buildjet-8vcpu-ubuntu-2204-arm | ||
runs-on: ${{ matrix.runner }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Build | ||
run: docker buildx build --build-arg PG_MAJOR=${{ matrix.postgres }} -t test . | ||
- name: Test | ||
run: docker run test cargo pgrx test pg${{ matrix.postgres }} | ||
lint: | ||
name: Linting (fmt + clippy) | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install rust | ||
uses: dtolnay/rust-toolchain@1.74.0 | ||
with: | ||
components: rustfmt, clippy | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Format check | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: fmt | ||
args: -- --check | ||
|
||
lockfile: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Install rust | ||
uses: dtolnay/rust-toolchain@1.74.0 | ||
- name: Lockfile check | ||
run: cargo update -w --locked |
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,120 @@ | ||
env: | ||
NAME: uids_postgres | ||
EXT_NAME: ulid | ||
PKG_NAME: uids_postgres | ||
name: Release | ||
on: | ||
push: | ||
tags: [v*] | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
jobs: | ||
create-release: | ||
name: Create release | ||
runs-on: ubuntu-latest | ||
outputs: | ||
upload_url: ${{ steps.create-release.outputs.upload_url }} | ||
steps: | ||
- name: Create Release | ||
id: create-release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: ${{ github.ref }} | ||
build-linux-gnu: | ||
name: Build & Release for linux | ||
needs: | ||
- create-release | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
postgres: [14, 15, 16] | ||
box: | ||
- runner: ubuntu-22.04 | ||
arch: amd64 | ||
- runner: buildjet-8vcpu-ubuntu-2204-arm | ||
arch: arm64 | ||
runs-on: ${{ matrix.box.runner }} | ||
timeout-minutes: 45 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Install rust | ||
uses: dtolnay/rust-toolchain@1.74.0 | ||
- name: Install dependencies | ||
run: | | ||
# Add postgres package repo | ||
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 -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo tee /etc/apt/trusted.gpg.d/pgdg.asc &>/dev/null | ||
sudo apt-get update | ||
sudo apt-get install -y --no-install-recommends git build-essential libpq-dev curl libreadline6-dev zlib1g-dev pkg-config cmake | ||
sudo apt-get install -y --no-install-recommends libreadline-dev zlib1g-dev flex bison libxml2-dev libxslt-dev libssl-dev libxml2-utils xsltproc ccache | ||
sudo apt-get install -y --no-install-recommends clang libclang-dev llvm-dev gcc tree | ||
# Install requested postgres version | ||
sudo apt-get install -y postgresql-${{ matrix.postgres }} postgresql-server-dev-${{ matrix.postgres }} -y | ||
# Ensure installed pg_config is first on path | ||
export PATH=$PATH:/usr/lib/postgresql/${{ matrix.postgres }}/bin | ||
cargo install cargo-pgrx --version 0.11.2 --locked | ||
cargo pgrx init --pg${{ matrix.postgres }}=/usr/lib/postgresql/${{ matrix.postgres }}/bin/pg_config | ||
- name: Build artifacts | ||
run: | | ||
# selects the pgVer from pg_config on path | ||
# https://github.com/tcdi/pgrx/issues/288 | ||
cargo pgrx package --no-default-features --features pg${{ matrix.postgres }} | ||
# Create installable package | ||
mkdir archive | ||
cp `find target/release -type f -name "${{ env.EXT_NAME }}*"` archive | ||
# Copy files into directory structure | ||
mkdir -p package/usr/lib/postgresql/lib | ||
mkdir -p package/var/lib/postgresql/extension | ||
cp archive/*.so package/usr/lib/postgresql/lib | ||
cp archive/*.control package/var/lib/postgresql/extension | ||
cp archive/*.sql package/var/lib/postgresql/extension | ||
# symlinks to Copy files into directory structure | ||
mkdir -p package/usr/lib/postgresql/${{ matrix.postgres }}/lib | ||
cd package/usr/lib/postgresql/${{ matrix.postgres }}/lib | ||
cp -s ../../lib/*.so . | ||
cd ../../../../../.. | ||
mkdir -p package/usr/share/postgresql/${{ matrix.postgres }}/extension | ||
cd package/usr/share/postgresql/${{ matrix.postgres }}/extension | ||
cp -s ../../../../../var/lib/postgresql/extension/${{ env.EXT_NAME }}.control . | ||
cp -s ../../../../../var/lib/postgresql/extension/${{ env.EXT_NAME }}*.sql . | ||
cd ../../../../../.. | ||
# Create install control file | ||
extension_version=${{ github.ref_name }} | ||
# strip the leading v | ||
deb_version=${extension_version:1} | ||
mkdir -p package/DEBIAN | ||
touch package/DEBIAN/control | ||
echo 'Package: ${{ env.PKG_NAME }}' >> package/DEBIAN/control | ||
echo 'Version:' ${deb_version} >> package/DEBIAN/control | ||
echo 'Architecture: ${{ matrix.box.arch }}' >> package/DEBIAN/control | ||
echo 'Maintainer: Pavan Sunkara' >> package/DEBIAN/control | ||
echo 'Description: A PostgreSQL extension for ULID' >> package/DEBIAN/control | ||
# Create deb package | ||
sudo chown -R root:root package | ||
sudo chmod -R 00755 package | ||
sudo dpkg-deb -Zxz --build --root-owner-group package | ||
- name: Upload artifacts | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
with: | ||
upload_url: ${{ needs.create-release.outputs.upload_url }} | ||
asset_path: ./package.deb | ||
asset_name: ${{ env.NAME }}-${{ github.ref_name }}-pg${{ matrix.postgres }}-${{ matrix.box.arch }}-linux-gnu.deb | ||
asset_content_type: application/vnd.debian.binary-package |
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
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,51 @@ | ||
ARG PG_MAJOR | ||
|
||
FROM postgres:${PG_MAJOR} | ||
|
||
RUN apt-get update | ||
|
||
ENV build_deps ca-certificates \ | ||
git \ | ||
build-essential \ | ||
libpq-dev \ | ||
postgresql-server-dev-${PG_MAJOR} \ | ||
curl \ | ||
libreadline6-dev \ | ||
zlib1g-dev | ||
|
||
RUN apt-get install -y --no-install-recommends $build_deps pkg-config cmake | ||
|
||
WORKDIR /home/postgres | ||
|
||
ENV HOME=/home/postgres | ||
ENV PATH=/home/postgres/.cargo/bin:$PATH | ||
|
||
RUN chown postgres:postgres /home/postgres | ||
|
||
USER postgres | ||
|
||
RUN \ | ||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal --default-toolchain 1.74.0 && \ | ||
rustup --version && \ | ||
rustc --version && \ | ||
cargo --version | ||
|
||
# pgrx | ||
RUN cargo install cargo-pgrx --version 0.11.2 --locked | ||
|
||
RUN cargo pgrx init --pg${PG_MAJOR} $(which pg_config) | ||
|
||
USER root | ||
|
||
COPY . . | ||
|
||
RUN cargo pgrx install | ||
|
||
RUN chown -R postgres:postgres /home/postgres | ||
RUN chown -R postgres:postgres /usr/share/postgresql/${PG_MAJOR}/extension | ||
RUN chown -R postgres:postgres /usr/lib/postgresql/${PG_MAJOR}/lib | ||
|
||
USER postgres | ||
|
||
ENV POSTGRES_HOST_AUTH_METHOD=trust | ||
ENV USER=postgres |
Oops, something went wrong.