From 9d487b7092866ab198279b1a9389e08e2d99d2a8 Mon Sep 17 00:00:00 2001 From: Ben Sully Date: Thu, 1 Jun 2023 09:04:05 +0100 Subject: [PATCH 1/4] Add Rust CI workflow --- .github/workflows/rust.yml | 135 +++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 .github/workflows/rust.yml diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 00000000..30316eb5 --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,135 @@ +name: Rust + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +env: + CARGO_TERM_COLOR: always + +jobs: + check: + name: Check + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - name: Cache build artifacts + uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Run cargo check + uses: actions-rs/cargo@v1 + with: + command: check + + test: + name: Tests + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - name: Cache build artifacts + uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Run cargo test + uses: actions-rs/cargo@v1 + with: + command: test + + fmt: + name: Rustfmt + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + components: rustfmt + + - name: Cache build artifacts + uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Run cargo fmt + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + clippy: + name: Clippy + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + components: clippy + + - name: Cache build artifacts + uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Run cargo clippy + uses: actions-rs/cargo@v1 + with: + command: clippy + args: -- -D warnings From dc8e0fb4b9120898c0716c817cb683d94b92f148 Mon Sep 17 00:00:00 2001 From: Ben Sully Date: Thu, 1 Jun 2023 09:20:15 +0100 Subject: [PATCH 2/4] Use moonrepo/setup-rust instead of actions-rs The actions-rs GitHub repos are unmaintained and use deprecated node versions, plus moonrepo/setup-rust handles caching and binary installs for us. --- .github/workflows/rust.yml | 94 ++++++-------------------------------- 1 file changed, 14 insertions(+), 80 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 30316eb5..ea0050d8 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -17,28 +17,11 @@ jobs: - name: Checkout sources uses: actions/checkout@v2 - - name: Install stable toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - - name: Cache build artifacts - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Install Rust toolchain + uses: moonrepo/setup-rust@v0 - name: Run cargo check - uses: actions-rs/cargo@v1 - with: - command: check + run: cargo check test: name: Tests @@ -47,28 +30,13 @@ jobs: - name: Checkout sources uses: actions/checkout@v2 - - name: Install stable toolchain - uses: actions-rs/toolchain@v1 + - name: Install Rust toolchain + uses: moonrepo/setup-rust@v0 with: - profile: minimal - toolchain: stable - override: true + bins: cargo-nextest - - name: Cache build artifacts - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - - name: Run cargo test - uses: actions-rs/cargo@v1 - with: - command: test + - name: Run cargo nextest + run: cargo nextest run fmt: name: Rustfmt @@ -77,30 +45,13 @@ jobs: - name: Checkout sources uses: actions/checkout@v2 - - name: Install stable toolchain - uses: actions-rs/toolchain@v1 + - name: Install Rust toolchain + uses: moonrepo/setup-rust@v0 with: - profile: minimal - toolchain: stable - override: true components: rustfmt - - name: Cache build artifacts - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - name: Run cargo fmt - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check + run: cargo fmt --all -- --check clippy: name: Clippy @@ -109,27 +60,10 @@ jobs: - name: Checkout sources uses: actions/checkout@v2 - - name: Install stable toolchain - uses: actions-rs/toolchain@v1 + - name: Install Rust toolchain + uses: moonrepo/setup-rust@v0 with: - profile: minimal - toolchain: stable - override: true components: clippy - - name: Cache build artifacts - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - name: Run cargo clippy - uses: actions-rs/cargo@v1 - with: - command: clippy - args: -- -D warnings + run: cargo clippy -- -D warnings From b1ca677200d356bedae397b597251025deaa3e06 Mon Sep 17 00:00:00 2001 From: Ben Sully Date: Thu, 1 Jun 2023 09:29:03 +0100 Subject: [PATCH 3/4] Add status badge for Rust workflow --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 548a348f..752e747f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # augurs - a time series framework for Rust -[![build-python](https://github.com/grafana/augurs/actions/workflows/python.yml/badge.svg)](https://github.com/grafana/augurs/actions/workflows/python.yml) +[![Python](https://github.com/grafana/augurs/actions/workflows/python.yml/badge.svg)](https://github.com/grafana/augurs/actions/workflows/python.yml) +[![Rust](https://github.com/grafana/augurs/actions/workflows/rust.yml/badge.svg)](https://github.com/grafana/augurs/actions/workflows/rust.yml) This repository contains `augurs`, a time series framework built in Rust. It aims to provide some useful primitives for working with time series, From e7ec9fab8508542e7de264ad861cb5a03db5901d Mon Sep 17 00:00:00 2001 From: Ben Sully Date: Thu, 1 Jun 2023 09:29:15 +0100 Subject: [PATCH 4/4] Rename 'python' job to 'Python' --- .github/workflows/python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 6b98b9dc..721e938e 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -3,7 +3,7 @@ # # maturin generate-ci github -m crates/pyaugurs/Cargo.toml # -name: python +name: Python on: push: