From aba31775fa5174e135067b183a9619ece495207f Mon Sep 17 00:00:00 2001 From: Evan Lloyd New-Schmidt Date: Thu, 1 Jun 2023 03:25:35 -0400 Subject: [PATCH] Setup GitHub (#2) * Fix license identifier * Add CI tests A cached setup that includes cargo check, clippy, fmt, and test * Fix formatting * Remove explicit rustup install cargo, etc. is already installed, see: * Add more context to cache prefix-key * Apply suggestions from code review * Ignore non-rust files * Remove unused matrix testing key * Use a better filename --------- Signed-off-by: Evan Lloyd New-Schmidt Co-authored-by: Alexander Borsuk <170263+biodranik@users.noreply.github.com> --- .github/workflows/rust-checks.yml | 36 +++++++++++++++++++++++++++++++ Cargo.toml | 2 +- src/main.rs | 4 +--- 3 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/rust-checks.yml diff --git a/.github/workflows/rust-checks.yml b/.github/workflows/rust-checks.yml new file mode 100644 index 0000000..a7ac273 --- /dev/null +++ b/.github/workflows/rust-checks.yml @@ -0,0 +1,36 @@ +name: Rust Checks + +on: + pull_request: + paths-ignore: + - .gitignore + - LICENSE + - README.md + +jobs: + test: + name: cargo check/clippy/fmt/test + runs-on: ubuntu-latest + + env: + CARGO_TERM_COLOR: always + RUST_BACKTRACE: 1 + + steps: + - uses: actions/checkout@v3 + + - uses: Swatinem/rust-cache@v2 + with: + # Bump this to manually invalidate the build/dependency cache. + # It is also keyed on the job, rustc version, Cargo.lock, and other + # values explained here: https://github.com/Swatinem/rust-cache#cache-details + prefix-key: "v0-rust" + + - name: Check compilation + run: cargo check --verbose --locked + - name: Lint + run: cargo clippy + - name: Test + run: cargo test --verbose --locked + - name: Formatting + run: cargo fmt --verbose --check diff --git a/Cargo.toml b/Cargo.toml index 0a2f9cb..6003f4e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "om-wikiparser" version = "0.0.0" -license = "AGPL-3.0-or-later" +license = "AGPL-3.0-only" edition = "2021" repository = "https://github.com/organicmaps/wikiparser/" diff --git a/src/main.rs b/src/main.rs index e58c983..f811ed2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,9 +2,7 @@ // pv ~/Downloads/enwiki-NS0-20230401-ENTERPRISE-HTML.json.tar.gz | tar xzO | cargo run --release > /dev/null use serde::Deserialize; -use std::{ - io::{self, stdin, BufRead, BufReader, Write}, -}; +use std::io::{self, stdin, BufRead, BufReader, Write}; #[derive(Deserialize)] struct Page {