From 72bfc3a24534a8f6221a3b734cd17429035db258 Mon Sep 17 00:00:00 2001 From: fmaccha Date: Thu, 18 Jul 2024 03:56:11 +0900 Subject: [PATCH 1/5] add ci workflow --- .github/actions/cache_cargo/action.yaml | 17 ++++++++ .github/workflows/rust_ci.yaml | 58 +++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 .github/actions/cache_cargo/action.yaml create mode 100644 .github/workflows/rust_ci.yaml diff --git a/.github/actions/cache_cargo/action.yaml b/.github/actions/cache_cargo/action.yaml new file mode 100644 index 0000000..522eebd --- /dev/null +++ b/.github/actions/cache_cargo/action.yaml @@ -0,0 +1,17 @@ +name: cache_cargo +description: "Cache .cargo registry" + +runs: + using: "composite" + steps: + - name: Cache .cargo registry + 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') }} + restore-keys: ${{ runner-os }}-cargo- \ No newline at end of file diff --git a/.github/workflows/rust_ci.yaml b/.github/workflows/rust_ci.yaml new file mode 100644 index 0000000..a373d87 --- /dev/null +++ b/.github/workflows/rust_ci.yaml @@ -0,0 +1,58 @@ +name: Rust CI + +on: + push: + branches: + - main + - ci_test + paths: + - 'src/**' + - 'tests/**' + - 'Cargo.**' + pull_request: + branches: + - main + +jobs: + build_cache: + name: Cache Rust ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest, macos-latest] + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Cache cargo directory + uses: ./.github/actions/cache_cargo + - name: Build + run: cargo build + + fmt_clippy: + name: format and clippy + runs-on: ubuntu-latest + needs: build_cache + steps: + - name: Checkout code + uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - name: Format code + run: cargo fmt --all -- --check + + test: + name: cargo test + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest, macos-latest] + needs: build_cache + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Cache cargo directory + uses: ./.github/actions/cache_cargo + - name: Run tests + run: cargo test -- --nocapture + From a548e943aad2ccef5d6ff1fbab28bd98886bc48f Mon Sep 17 00:00:00 2001 From: fmaccha Date: Thu, 18 Jul 2024 04:05:47 +0900 Subject: [PATCH 2/5] Update CI workflow to include enhancement branch --- .github/workflows/rust_ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust_ci.yaml b/.github/workflows/rust_ci.yaml index a373d87..f7fc919 100644 --- a/.github/workflows/rust_ci.yaml +++ b/.github/workflows/rust_ci.yaml @@ -4,7 +4,7 @@ on: push: branches: - main - - ci_test + - enhancement** paths: - 'src/**' - 'tests/**' From 75377bfcbde6d52749b275389b454123530699c7 Mon Sep 17 00:00:00 2001 From: fmaccha Date: Thu, 18 Jul 2024 04:08:17 +0900 Subject: [PATCH 3/5] Update CI workflow to include .github directory --- .github/workflows/rust_ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/rust_ci.yaml b/.github/workflows/rust_ci.yaml index f7fc919..847a2d2 100644 --- a/.github/workflows/rust_ci.yaml +++ b/.github/workflows/rust_ci.yaml @@ -9,6 +9,7 @@ on: - 'src/**' - 'tests/**' - 'Cargo.**' + - '.github/**' pull_request: branches: - main From 92566f37b065fb300f5bfa67880cd949d278e61f Mon Sep 17 00:00:00 2001 From: fmaccha Date: Sat, 5 Oct 2024 19:12:32 +0900 Subject: [PATCH 4/5] Fix CI workflow --- .github/actions/cache_cargo/action.yaml | 3 +-- .github/workflows/rust_ci.yaml | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.github/actions/cache_cargo/action.yaml b/.github/actions/cache_cargo/action.yaml index 522eebd..ecb5c2a 100644 --- a/.github/actions/cache_cargo/action.yaml +++ b/.github/actions/cache_cargo/action.yaml @@ -8,10 +8,9 @@ runs: 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') }} - restore-keys: ${{ runner-os }}-cargo- \ No newline at end of file + restore-keys: ${{ runner.os }}-cargo- \ No newline at end of file diff --git a/.github/workflows/rust_ci.yaml b/.github/workflows/rust_ci.yaml index 847a2d2..044e208 100644 --- a/.github/workflows/rust_ci.yaml +++ b/.github/workflows/rust_ci.yaml @@ -5,6 +5,7 @@ on: branches: - main - enhancement** + - bug** paths: - 'src/**' - 'tests/**' @@ -14,6 +15,7 @@ on: branches: - main + jobs: build_cache: name: Cache Rust ${{ matrix.os }} @@ -21,14 +23,20 @@ jobs: strategy: fail-fast: true matrix: - os: [ubuntu-latest, macos-latest] + # os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest] steps: - name: Checkout code uses: actions/checkout@v4 - name: Cache cargo directory uses: ./.github/actions/cache_cargo + - name: Set toolchain + uses: dtolnay/rust-toolchain@master + with: + toolchain: stable + components: rustfmt, clippy - name: Build - run: cargo build + run: cargo build fmt_clippy: name: format and clippy @@ -37,9 +45,14 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - name: Cache cargo directory + uses: ./.github/actions/cache_cargo + - name: Check + run: cargo check - name: Format code run: cargo fmt --all -- --check + - name: Clippy + run: cargo clippy --all-targets --all-features -- -D warnings --no-deps test: name: cargo test @@ -47,7 +60,8 @@ jobs: strategy: fail-fast: true matrix: - os: [ubuntu-latest, macos-latest] + # os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest] needs: build_cache steps: - name: Checkout code From bd7fbbd91a3ef303618dc29ddd2099f862327cb3 Mon Sep 17 00:00:00 2001 From: fmaccha Date: Sat, 5 Oct 2024 21:23:42 +0900 Subject: [PATCH 5/5] Fix CI workflow --- .github/workflows/rust_ci.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/rust_ci.yaml b/.github/workflows/rust_ci.yaml index 044e208..362263a 100644 --- a/.github/workflows/rust_ci.yaml +++ b/.github/workflows/rust_ci.yaml @@ -10,7 +10,6 @@ on: - 'src/**' - 'tests/**' - 'Cargo.**' - - '.github/**' pull_request: branches: - main