Skip to content

feat: add github workflow #2

feat: add github workflow

feat: add github workflow #2

Workflow file for this run

name: CI
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, macos-latest ]
pg: [ "12", "13", "14", "15", "16" ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
path: typeid
- name: Install cargo-pgrx
run: |
PGRX_VERSION=$(cargo metadata --format-version 1 | jq -r '.packages[]|select(.name=="pgrx")|.version')
cargo install --locked --version=$PGRX_VERSION cargo-pgrx --debug --force
cargo pgrx init --pg${{ matrix.pg }} download
- name: Run tests
run: echo "\q" | cargo pgrx run pg${{ matrix.pg }} && cargo test --no-default-features --features pg${{ matrix.pg }}
Install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
path: typeid
- name: Install PostgreSQL headers
run: |
sudo apt-get update
sudo apt-get install postgresql-server-dev-14
- name: Install cargo-pgrx
run: |
PGRX_VERSION=$(cargo metadata --format-version 1 | jq -r '.packages[]|select(.name=="pgrx")|.version')
cargo install --locked --version=$PGRX_VERSION cargo-pgrx --debug --force
cargo pgrx init --pg14 $(which pg_config)
- name: Install TypeID/PRQL
run: |
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 typeid;"
psql -U runner -c "select typeid_generate('user');"
rustfmt:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
path: typeid
- name: Run rustfmt
run: cargo fmt -- --check
rust-clippy:
runs-on: ubuntu-latest
strategy:
matrix:
pg: [ "16" ]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
path: typeid
- name: Install cargo-pgrx
run: |
PGRX_VERSION=$(cargo metadata --format-version 1 | jq -r '.packages[]|select(.name=="pgrx")|.version')
cargo install --locked --version=$PGRX_VERSION cargo-pgrx --debug --force
cargo pgrx init --pg${{ matrix.pg }} download
- name: Run clippy
run: cargo clippy --all-targets --no-default-features --features pg${{ matrix.pg }} -- -D warnings