From 0af5a1da96b1e35e6e46ab3355dd85eeec6115de Mon Sep 17 00:00:00 2001 From: Boyu Yang Date: Wed, 20 Mar 2024 08:03:48 +0800 Subject: [PATCH] ci: enable GitHub actions --- .github/workflows/ci.yaml | 61 +++++++++++++++++++++++++++++++++++++++ Makefile | 5 ++++ README.md | 2 ++ 3 files changed, 68 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..538f4f6 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,61 @@ +name: CI +on: + push: + branches: [ master, develop, release/* ] + pull_request: + branches: [ master, release/* ] +defaults: + run: + shell: bash +env: + CARGO_TERM_COLOR: always + RUST_TOOLCHAIN: 1.76.0 +jobs: + rustfmt: + name: Checks / Format + runs-on: ubuntu-latest + steps: + - name: Checkout the Repository + uses: actions/checkout@v4 + - name: Install Rust Toolchain + run: | + rustup toolchain install ${{ env.RUST_TOOLCHAIN }} --profile minimal --component rustfmt + rustup override set ${{ env.RUST_TOOLCHAIN }} + - name: Format Check + run: make fmt + clippy: + name: Checks / Clippy + runs-on: ubuntu-latest + steps: + - name: Checkout the Repository + uses: actions/checkout@v4 + - name: Install Rust Toolchain + run: | + rustup toolchain install ${{ env.RUST_TOOLCHAIN }} --profile minimal --component clippy + rustup override set ${{ env.RUST_TOOLCHAIN }} + - name: Lint Check + run: make clippy + test: + name: Tests / Build & Test + needs: [ rustfmt, clippy ] + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-latest, macos-latest, windows-latest ] + fail-fast: true + max-parallel: 3 + steps: + - name: Checkout the Repository + uses: actions/checkout@v4 + with: + submodules: recursive + - name: Install Rust Toolchain + run: | + rustup toolchain install ${{ env.RUST_TOOLCHAIN }} --profile minimal + rustup override set ${{ env.RUST_TOOLCHAIN }} + - name: Install cargo-nextest + uses: taiki-e/install-action@nextest + - name: Build + run: make build + - name: Unit Testing + run: make test diff --git a/Makefile b/Makefile index 760d0f1..b584daf 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ CARGO := @cargo +NEXTEST_RUN_ARGS := --no-fail-fast --success-output immediate --failure-output final + # # Check # @@ -13,6 +15,9 @@ fmt: clippy: ${CARGO} clippy --workspace --tests -- --deny warnings +test: + ${CARGO} nextest run ${NEXTEST_RUN_ARGS} --workspace types::extension::packed::test_service + # # Build # diff --git a/README.md b/README.md index 51f128a..3246158 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # CKB Bitcoin SPV Service [![License]](#license) +[![GitHub Actions]](https://github.com/yangby-cryptape/ckb-bitcoin-spv-service/actions) > [!WARNING] > This repository is still in the proof-of-concept stage. @@ -10,6 +11,7 @@ and provides an API to generate proofs for [Bitcoin] transactions so that they can be verified on [CKB]. [License]: https://img.shields.io/badge/License-MIT-blue.svg +[GitHub Actions]: https://github.com/yangby-cryptape/ckb-bitcoin-spv-service/workflows/CI/badge.svg ## Usage