Skip to content

Commit

Permalink
Add CI
Browse files Browse the repository at this point in the history
  • Loading branch information
philippemnoel committed Jul 30, 2024
1 parent 3f7901e commit b979f62
Show file tree
Hide file tree
Showing 10 changed files with 648 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ body:
- ParadeDB Docker Image
- ParadeDB Helm Chart
- ParadeDB pg_search Extension
- ParadeDB pg_lakehouse Extension
- ParadeDB pg_analytics Extension
validations:
required: true

Expand Down
84 changes: 84 additions & 0 deletions .github/workflows/benchmark-pg_analytics.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# workflows/benchmark-pg_analytics.yml
#
# Benchmark pg_analytics
# Benchmark ParadeDB's pg_analytics performance on a nightly basis. This workflow can also be triggered
# manually to benchmark other systems on one-off basis, to compare against ParadeDB.

name: Benchmark pg_analytics

on:
schedule:
- cron: "1 0 * * 1,2,3,4,5" # Run once per day on weekdays (days of the week 1-5) at 00:01 UTC
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches:
- dev
- main
paths:
- ".github/workflows/benchmark-pg_analytics.yml"
- "cargo-paradedb/**"
- "docker/Dockerfile"
- "pg_analytics/**"
- "!pg_analytics/README.md"
- "shared/Cargo.toml"
workflow_dispatch:

concurrency:
group: benchmark-pg_analytics-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
benchmark-pg_analytics:
name: Benchmark pg_analytics on ${{ matrix.name }}
runs-on: depot-ubuntu-latest-8
if: github.event.pull_request.draft == false
strategy:
matrix:
include:
- name: ClickBench (Parquet, single)
flags: -w single
pg_version: 16
- name: ClickBench (Parquet, partitioned)
flags: -w partitioned
pg_version: 16

steps:
- name: Checkout Git Repository
uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Install & Configure Supported PostgreSQL Version
run: |
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
sudo apt-get update && sudo apt-get install -y postgresql-${{ matrix.pg_version }} postgresql-server-dev-${{ matrix.pg_version }}
sudo chown -R $(whoami) /usr/share/postgresql/${{ matrix.pg_version }}/ /usr/lib/postgresql/${{ matrix.pg_version }}/ /var/lib/postgresql/${{ matrix.pg_version }}/
echo "/usr/lib/postgresql/${{ matrix.pg_version }}/bin" >> $GITHUB_PATH
- name: Install pgrx & pg_analytics
working-directory: pg_analytics/
run: |
cargo install -j $(nproc) --locked cargo-pgrx --version 0.11.3
cargo pgrx init --pg${{ matrix.pg_version }}=/usr/lib/postgresql/${{ matrix.pg_version }}/bin/pg_config
cargo pgrx install --pg-config="/usr/lib/postgresql/${{ matrix.pg_version }}/bin/pg_config" --release
- name: Add pg_analytics to shared_preload_libraries
working-directory: /home/runner/.pgrx/data-${{ matrix.pg_version }}/
run: sed -i "s/^#shared_preload_libraries = .*/shared_preload_libraries = 'pg_analytics'/" postgresql.conf

- name: Install the ParadeDB Benchmarking Tool
working-directory: cargo-paradedb/
run: cargo run install

- name: Run Official ${{ matrix.name }} Benchmark
working-directory: pg_analytics/
run: |
cargo pgrx start pg${{ matrix.pg_version }}
cargo paradedb bench hits run ${{ matrix.flags }} --url postgresql://localhost:288${{ matrix.pg_version }}/postgres
- name: Notify Slack on Failure
if: failure() && (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main')
run: |
curl -X POST -H 'Content-type: application/json' --data '{"text":"Benchmark pg_analytics on ${{ matrix.name }} workflow failed in `paradedb/paradedb` -- investigate immediately!"}' ${{ secrets.SLACK_WEBHOOK_URL }}
90 changes: 90 additions & 0 deletions .github/workflows/lint-bash.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# workflows/lint-bash.yml
#
# Lint Bash
# Lint and enforce good practices for Bash scripts.

name: Lint Bash

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- "**/*.sh"
- ".github/workflows/lint-bash.yml"
workflow_dispatch:

concurrency:
group: lint-bash-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
lint-bash:
name: Lint Bash Scripts
runs-on: depot-ubuntu-latest-2
if: github.event.pull_request.draft == false

steps:
- name: Checkout Git Repository
uses: actions/checkout@v4

- name: Set up Python Environment
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install Beautysh
run: pip install beautysh

- name: Run Beautysh
run: |
shopt -s globstar nullglob
if compgen -G "**/*.sh" > /dev/null; then
beautysh **/*.sh --indent-size 2 --check
fi
shopt -u globstar nullglob
- name: Check Bash Scripts for "#!/bin/bash"
run: |
while read -r file
do
if [[ "$(head -c 11 "$file")" = "#!/bin/bash" ]]
then
echo "[#!/bin/bash -> Present] $file"
else
echo "[#!/bin/bash -> NOT FOUND] $file" && exit 1
fi
done < <(find . -name '*.sh')
- name: Check Bash Scripts for "set -Eeuo pipefail"
run: |
while read -r file
do
if grep -q \
-e "^set -Eeuo pipefail$" \
-e "^# @paradedb-skip-check-pipefail$" \
"$file"
then
echo "[set -Eeuo pipefail -> Present] $file"
else
echo "[set -Eeuo pipefail -> NOT FOUND] $file" && exit 1
fi
done < <(find . -name '*.sh')
- name: Run ShellCheck
shell: python {0}
run: |
import argparse
import glob
import subprocess
import sys
sh_files = set(glob.glob("**/*.sh", recursive=True))
for file in sh_files:
p = subprocess.run(
f"shellcheck {file}", shell=True, capture_output=True, check=False
)
print(p.stdout.decode())
if p.returncode != 0:
print(f"[Shellcheck did not pass] {file}")
sys.exit(1)
print(f"[Shellcheck passed] {file}")
34 changes: 34 additions & 0 deletions .github/workflows/lint-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# workflows/lint-docker.yml
#
# Lint Docker
# Lint Dockerfiles using Hadolint.

name: Lint Docker

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- ".github/workflows/lint-docker.yml"
- "docker/**"
workflow_dispatch:

concurrency:
group: lint-docker-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
lint-docker:
name: Lint Dockerfiles
runs-on: depot-ubuntu-latest-2
if: github.event.pull_request.draft == false

steps:
- name: Checkout Git Repository
uses: actions/checkout@v4

- name: Run Hadolint
uses: jbergstroem/hadolint-gh-action@v1
with:
dockerfile: "**/Dockerfile*"
error_level: 2 # Treat INFO as error
64 changes: 64 additions & 0 deletions .github/workflows/lint-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# workflows/lint-format.yml
#
# Lint Format
# Lint the project's file trailing spaces, line endings, and format.

name: Lint Format

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
workflow_dispatch:

concurrency:
group: lint-format-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
lint-format:
name: Lint File Endings & Trailing Whitespaces
runs-on: depot-ubuntu-latest-2
if: github.event.pull_request.draft == false

steps:
- name: Checkout Git Repository
uses: actions/checkout@v4

- name: Install fd Search Tool
run: |
sudo apt-get update
sudo apt-get install -y fd-find
mkdir -p "$HOME/.local/bin"
sudo ln -s $(which fdfind) "$HOME/.local/bin/fd"
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Check for CRLF Files
run: |
FILES=$(git ls-files --eol | grep crlf || true)
if [[ ! -z "$FILES" ]]; then
echo "The following files have incorrect line endings:"
echo "$FILES"
false
fi
# We ignore .out and .sql files, which are used by pg_regress for testing
# and need a very specific format
- name: Check for Trailing Whitespaces
run: |
FILES=$(git grep -Ilr '[[:blank:]]$' -- ':(exclude)*.out' ':(exclude)*.sql' ':(exclude)*.rs' || true)
if [[ ! -z "$FILES" ]]; then
echo "The following files have trailing whitespaces:"
echo "$FILES"
exit 1
fi
- name: Print Modified Files
run: |
FILES=$(git ls-files --modified)
if [[ ! -z "$FILES" ]]; then
echo "The following files have incorrect trailing newlines:"
echo "$FILES"
echo "Please fix them using:"
echo -e 'if [[ -f "$1" ]]; then\n echo -n "$1"\n if (diff /dev/null "$1" || true) | tail -1 | grep -q "^\\ No newline"; then\n echo >> "$1"\n echo "...fixed"\n else\n echo ""\n fi\nfi'
false
fi
41 changes: 41 additions & 0 deletions .github/workflows/lint-markdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# workflows/lint-markdown.yml
#
# Lint Markdown
# Lint Markdown files using Prettier.

name: Lint Markdown

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- "**/*.md"
- "**/*.mdx"
- ".github/workflows/lint-markdown.yml"
workflow_dispatch:

concurrency:
group: lint-markdown-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
lint-markdown:
name: Lint Markdown Files
runs-on: depot-ubuntu-latest-2
if: github.event.pull_request.draft == false

steps:
- name: Checkout Git Repository
uses: actions/checkout@v4

- name: Set up NodeJS Environment
uses: actions/setup-node@v4

- name: Install Prettier
run: npm install -g prettier markdownlint-cli

- name: Run Markdown Lint
run: markdownlint '**/*.md'

- name: Run Prettier
run: prettier --check '{**/*.md,**/*.mdx}'
29 changes: 29 additions & 0 deletions .github/workflows/lint-pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# workflows/lint-pr-title.yml
#
# Lint PR Title
# Lint and enforce proper PR title format.

name: Lint PR Title

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

permissions:
pull-requests: read

concurrency:
group: lint-pr-title-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
lint-pr-title:
name: Validate PR Title
runs-on: depot-ubuntu-latest-2
if: github.event.pull_request.draft == false

steps:
- name: Checkout Git Repository
uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading

0 comments on commit b979f62

Please sign in to comment.