diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 28173df..1a780e7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,47 +1,44 @@ -name: CI +name: ci on: push: - branches: [main] + branches: + - main + tags-ignore: + - v* + pull_request: - branches: [main] + branches: + - main jobs: - test: + ci: runs-on: ubuntu-latest steps: - name: Check out uses: actions/checkout@v3 + # Nightly needed for `cargo +nightly fmt` below - name: Install Rust toolchain run: | rustup update - rustup toolchain install nightly + rustup toolchain install nightly --profile minimal rustup component add rustfmt --toolchain nightly - rustup component add clippy --toolchain nightly + # rustup component add clippy --toolchain nightly - - name: Set up cargo cache - uses: actions/cache@v3 - continue-on-error: false + - name: Install just + uses: taiki-e/install-action@v2 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- - - - name: Check code format (cargo fmt) - run: cargo +nightly fmt --check - - - name: Lint (cargo clippy) - run: cargo clippy --no-deps -- -D warnings - - - name: Test (cargo test) - env: - GCP_SERVICE_ACCOUNT: ${{ secrets.GCP_SERVICE_ACCOUNT }} - run: | - printenv GCP_SERVICE_ACCOUNT > pub-sub-client-tests/secrets/active-road-365118-2eca6b7b8fd9.json - cargo test + tool: just + + - name: Set up Rust cache + uses: Swatinem/rust-cache@v2 + + - name: Check code format + run: just fmt_check + + - name: Run linter + run: just lint + + - name: Run tests + run: just test diff --git a/justfile b/justfile new file mode 100644 index 0000000..b99ca07 --- /dev/null +++ b/justfile @@ -0,0 +1,18 @@ +set shell := ["bash", "-uc"] + +check: + cargo check --tests + +fmt: + cargo +nightly fmt + +fmt_check: + cargo +nightly fmt --check + +lint: + cargo clippy --no-deps -- -D warnings + +test: + cargo test + +all: fmt check lint test