-
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 #35 from thedataquarry/rust-ci
Add Rust CI
- Loading branch information
Showing
8 changed files
with
109 additions
and
4 deletions.
There are no files selected for viewing
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,54 @@ | ||
name: Testing | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
env: | ||
CARGO_TERM_COLOR: always | ||
RUST_BACKTRACE: 1 | ||
RUSTFLAGS: "-D warnings" | ||
POSTGRES_PASSWORD: "test_password" | ||
DATABASE_URL: "postgresql://postgres:[email protected]:5432/etl" | ||
jobs: | ||
clippy: | ||
name: Clippy | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install Rust | ||
run: | | ||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | ||
- name: Cache dependencies | ||
uses: Swatinem/[email protected] | ||
- name: Prep data and sqlx # This prevents sqlx errors if the database isn't running | ||
run: sh ./scripts/prep_tests.sh | ||
- name: Run cargo clippy | ||
run: cargo clippy --all-targets -- --deny warnings | ||
fmt: | ||
name: Rustfmt | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install Rust | ||
run: | | ||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | ||
- name: Cache dependencies | ||
uses: Swatinem/[email protected] | ||
- name: Run cargo fmt | ||
run: cargo fmt --all -- --check | ||
test: | ||
name: Tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install Rust | ||
run: | | ||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | ||
- name: Cache dependencies | ||
uses: Swatinem/[email protected] | ||
- name: Prep data and sqlx # This prevents sqlx errors if the database isn't running | ||
run: sh ./scripts/prep_tests.sh | ||
- name: Run cargo test | ||
run: cargo test |
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 |
---|---|---|
|
@@ -164,3 +164,5 @@ cython_debug/ | |
|
||
# Rust | ||
/target | ||
|
||
/scripts/data/* |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,13 @@ | ||
version: "3.9" | ||
|
||
services: | ||
database: | ||
image: "postgres:latest" | ||
ports: | ||
- 5432:5432 | ||
environment: | ||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD} | ||
volumes: | ||
- ./pg/:/var/lib/postgresql/data/ | ||
- ./init.sql:/docker-entrypoint-initdb.d/init.sql | ||
- ./data:/data |
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,21 @@ | ||
SELECT 'CREATE DATABASE etl' | ||
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'etl')\gexec | ||
|
||
\connect etl | ||
|
||
CREATE TABLE IF NOT EXISTS persons( | ||
id integer PRIMARY KEY, | ||
name text, | ||
age smallint, | ||
isMarried boolean, | ||
city text, | ||
state text, | ||
country text | ||
)\gexec | ||
|
||
TRUNCATE TABLE persons\gexec | ||
|
||
COPY persons(id, name, age, isMarried, city, state, country) | ||
FROM '/data/persons.csv' | ||
DELIMITER ',' | ||
CSV HEADER\gexec |
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,5 @@ | ||
#!bin/bash | ||
|
||
mkdir scripts/data | ||
cp pieces/postgres_etl/data/persons.csv scripts/data | ||
docker compose -f scripts/docker-compose.yml up -d |