Skip to content

Add database conversion scripts #1005

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
55 changes: 38 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ jobs:
- name: Check benchmarks
run: sh -x -c "ci/check-profiling.sh"

database-check-postgres:
name: Database Check (postgres)
database-check:
name: Database Check
runs-on: ubuntu-latest
services:
postgres:
Expand All @@ -156,27 +156,48 @@ jobs:
with:
toolchain: stable

- name: Build site
run: cargo build --bin site

- name: Connect to PostgreSQL
run: |
cargo build --bin site
timeout 5s ./target/debug/site 'postgresql://postgres:postgres@localhost:5432/postgres' 2>&1 | tee -a log || true
grep -Fxq "Loading complete but no data identified; exiting." log

database-check-sqlite:
name: Database Check (sqlite)
runs-on: ubuntu-latest

steps:
- name: Check out repository code
uses: actions/checkout@v2

- name: Install stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable

- name: Connect to SQLite
run: |
cargo build --bin site
timeout 5s ./target/debug/site 2>&1 | tee -a log || true
grep -Fxq "Loading complete but no data identified; exiting." log

- name: Build Postgres to SQLite exporter
run: cargo build --bin postgres-to-sqlite

- name: Export empty Postgres DB to SQLite
run: ./target/debug/postgres-to-sqlite 'postgresql://postgres:postgres@localhost:5432/postgres' "$(mktemp)"

- name: Export empty Postgres DB to SQLite with date filter
run: ./target/debug/postgres-to-sqlite --since-weeks-ago=1 'postgresql://postgres:postgres@localhost:5432/postgres' "$(mktemp)"

- name: Build SQLite to Postgres exporter
run: cargo build --bin sqlite-to-postgres

- name: Export empty SQLite DB to Postgres
run: ./target/debug/sqlite-to-postgres "$(mktemp)" 'postgresql://postgres:postgres@localhost:5432/postgres'

- name: Roundtrip export
run: |
sudo apt-get update
sudo apt-get install -y wget python3-snappy sqlite3

wget -q 'http://perf-data.rust-lang.org/export.db.sz'
python3 -m snappy -d export.db.sz > before.db

./target/debug/sqlite-to-postgres before.db 'postgresql://postgres:postgres@localhost:5432/postgres'
sqlite3 before.db .dump > before.dump

rm before.db

./target/debug/postgres-to-sqlite 'postgresql://postgres:postgres@localhost:5432/postgres' after.db
sqlite3 after.db .dump > after.dump

diff -w before.dump after.dump
43 changes: 43 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ COPY ./database ./database
COPY ./intern ./intern

RUN bash -c 'source $HOME/.cargo/env && cargo build --release -p site'
RUN bash -c 'source $HOME/.cargo/env && cargo build --release --bin export-to-sqlite'
RUN bash -c 'source $HOME/.cargo/env && cargo build --release --bin postgres-to-sqlite'

FROM ubuntu:20.04 as binary

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
ca-certificates \
git

COPY --from=build /target/release/export-to-sqlite /usr/local/bin/rustc-perf-export-to-sqlite
COPY --from=build /target/release/postgres-to-sqlite /usr/local/bin/rustc-perf-postgres-to-sqlite
COPY --from=build /target/release/site /usr/local/bin/rustc-perf-site
COPY --from=build site/static /site/static

Expand Down
5 changes: 4 additions & 1 deletion database/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ async-trait = "0.1"
tokio = { version = "1.6", features = ["sync", "macros"] }
snap = "1"
intern = { path = "../intern" }
chrono = "0.4"
chrono = { version = "0.4", features = ["serde"] }
reqwest = { version = "0.11", features = ["blocking"] }
postgres-native-tls = "0.5"
native-tls = "0.2"
lazy_static = "1"
env_logger = "0.8"
futures = "0.3.5"
log = "0.4"
bytes = "1"
csv = "1"
clap = "2.25"
Loading