Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI refactoring, test install from source #3

Merged
merged 37 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
92d5203
Add package.yml
kaspermarstal Jan 16, 2024
a6ce0ff
Update package.yml
kaspermarstal Jan 16, 2024
d073e90
Update package.yml
kaspermarstal Jan 16, 2024
e14689c
Update package.yml
kaspermarstal Jan 16, 2024
b717221
Update package.yml
kaspermarstal Jan 16, 2024
729c739
Update package.yml
kaspermarstal Jan 16, 2024
080c736
Update package.yml
kaspermarstal Jan 16, 2024
359299f
Update package.yml
kaspermarstal Jan 16, 2024
1a175ab
Update package.yml
kaspermarstal Jan 16, 2024
2da26f3
Update package.yml
kaspermarstal Jan 16, 2024
1ad5aa2
Update package.yml
kaspermarstal Jan 16, 2024
5989da6
Install from source
kaspermarstal Jan 17, 2024
ebaa525
Update
kaspermarstal Jan 17, 2024
e3ed409
update
kaspermarstal Jan 17, 2024
f3a42c6
update
kaspermarstal Jan 17, 2024
b4888c7
Update
kaspermarstal Jan 17, 2024
3b16f32
update
kaspermarstal Jan 17, 2024
7f45fd0
update
kaspermarstal Jan 17, 2024
fc11ddf
update
kaspermarstal Jan 17, 2024
c0f22a4
update
kaspermarstal Jan 17, 2024
da0e865
update
kaspermarstal Jan 17, 2024
c3c854b
update
kaspermarstal Jan 17, 2024
cd59539
update
kaspermarstal Jan 18, 2024
2fa8daf
update
kaspermarstal Jan 18, 2024
7059e73
update
kaspermarstal Jan 18, 2024
fa10716
update
kaspermarstal Jan 18, 2024
5993219
update
kaspermarstal Jan 18, 2024
fd4a1a9
update
kaspermarstal Jan 18, 2024
f4a513b
update
kaspermarstal Jan 20, 2024
c48b1eb
update
kaspermarstal Jan 20, 2024
a227b23
update
kaspermarstal Jan 20, 2024
439f0eb
update
kaspermarstal Jan 20, 2024
06abbd1
update
kaspermarstal Jan 20, 2024
bad1832
update
kaspermarstal Jan 21, 2024
b4f7a33
update
kaspermarstal Jan 21, 2024
e8106bf
update
kaspermarstal Jan 21, 2024
bbcf395
update
kaspermarstal Jan 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
.idea/
/debug
/target
*.iml
**/*.rs.bk
Cargo.lock
*.pdb
21 changes: 21 additions & 0 deletions .github/docker/Dockerfile.debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM debian:bullseye

ARG PG_MAJOR_VER

RUN apt-get update
RUN apt-get install -y wget gnupg
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ bullseye-pgdg main" >> /etc/apt/sources.list.d/pgdg.list
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
RUN apt-get update
RUN apt-get install -y build-essential postgresql-server-dev-${PG_MAJOR_VER} postgresql-${PG_MAJOR_VER}

RUN apt-get install -y curl pkg-config
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"

RUN cargo install --locked cargo-pgrx --version 0.11.2
RUN cargo pgrx init --pg${PG_MAJOR_VER} /usr/bin/pg_config

COPY ./ /plprql
WORKDIR /plprql
RUN cargo pgrx install --release -c "/usr/bin/pg_config"
34 changes: 34 additions & 0 deletions .github/docker/run-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#! /usr/bin/env bash

# Environment variables:
# PG_MAJOR_VER: The major version of Postgres in which to build/run. E.g. 14, 12, 15
# DOCKERFILE_ID: The Dockerfile identifier to be built, included in this repo,
# e.g. debian:bullseye or amazon:2
# CARGO_LOCKED_OPTION: Set to '--locked' to use "cargo --locked", or set to
# blank '' to use "cargo" without "--locked"

# Examples of running this script in CI (currently Github Actions):
# ./.github/docker/run-docker.sh 14 debian_bullseye
# ./.github/docker/run-docker.sh 12 fedora

set -x

PG_MAJOR_VER=$1
DOCKERFILE_ID=$2

echo "Building docker container for Postgres version $PG_MAJOR_VER on $DOCKERFILE_ID"
echo "Cargo lock flag set to: '$CARGO_LOCKED_OPTION'"

docker build \
--build-arg PG_MAJOR_VER="$PG_MAJOR_VER" \
-t plprql \
-f ".github/docker/Dockerfile.$DOCKERFILE_ID" \
.

echo "Packaging PL/PRQL for Postgres version $PG_MAJOR_VER on $DOCKERFILE_ID"

docker run plprql \
cargo test \
--no-default-features \
--features "pg$PG_MAJOR_VER" \
"$CARGO_LOCKED_OPTION"
30 changes: 0 additions & 30 deletions .github/workflows/ci.yml

This file was deleted.

33 changes: 33 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: PL/PRQL

on:
# schedule:
# - cron: '0 7 * * MON-FRI'
workflow_dispatch:
# push:
# branches:
# - main
# pull_request:
# branches:
# - main

env:
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: "false"

jobs:
distro_tests:
name: Package
runs-on: ubuntu-latest
strategy:
fail-fast: false # We want all of them to run, even if one fails
matrix:
pg: [ "12" ] # ["12", "13", "14", "15", "16"]
container: [ "debian" ]
steps:
- uses: actions/checkout@v3
- name: Package PL/PRQL for PostgreSQL ${{ matrix.pg }} (${{ matrix.container }})
shell: bash
run: |
docker build --build-arg PG_MAJOR_VER="${{ matrix.pg }}" -t plprql -f ".github/docker/Dockerfile.${{ matrix.container }}" .
docker run plprql cargo test --no-default-features --features "pg${{ matrix.pg }}"
60 changes: 60 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: PL/PRQL

on:
push:
branches:
- main
pull_request:
branches:
- main

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: "false"

jobs:
Test:
strategy:
fail-fast: false # We want all of them to run, even if one fails
matrix:
os: [ ubuntu-latest ]
pg: [ "pg12", "pg13", "pg14", "pg15", "pg16" ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Install cargo-pgrx
run: |
cargo install --locked --version=0.11.2 cargo-pgrx --debug --force
cargo pgrx init --${{ matrix.pg }} download
- name: Run tests
run: cargo test --package plprql --lib plprql::tests --features ${{ matrix.pg }} --no-default-features
Install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install PostgreSQL headers
run: sudo apt-get install postgresql-server-dev-14
- name: Install cargo-pgrx
run: |
cargo install --locked --version=0.11.2 cargo-pgrx --debug --force
cargo pgrx init --pg14 $(which pg_config)
- name: Install PL/PRQL
run: |
# Touching these files is a workaround for std::canonicalize not working if file does not exist (v0.11.2 cargo-pgrx/src/command/sudo_install.rs#L72)
# This has been fixed on develop and can be removed when next version of pgrx is released
sudo touch /usr/share/postgresql/14/extension/plprql--0.0.1.sql
sudo touch /usr/share/postgresql/14/extension/plprql.control
sudo touch /usr/lib/postgresql/14/lib/plprql.so
cargo pgrx install --no-default-features --release --sudo
- name: Start PostgreSQL
run: |
sudo systemctl start postgresql.service
pg_isready
# superuser (-s), can create databases (-d) and roles (-r), no password prompt (-w) named runner
sudo -u postgres createuser -s -d -r -w runner
- name: Verify install
run: |
createdb -U runner runner
psql -U runner -c "create extension plprql;"
psql -U runner -c "select prql_to_sql('from table');"