diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 489afe4..bb9c700 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -6,25 +6,42 @@ on: - main tags-ignore: - v* - pull_request: branches: - main + schedule: + - cron: 0 4/12 * * * + workflow_dispatch: + inputs: + nightly: + description: Use latest nightly + required: true + type: boolean jobs: ci: runs-on: ubuntu-latest steps: - name: Check out - uses: actions/checkout@v3 + uses: actions/checkout@v4 - # Nightly needed for `cargo +nightly fmt` below - name: Install Rust toolchain + env: + nightly: ${{ (github.event.inputs.nightly == 'true' || github.event_name == 'schedule') && 'true' || '' }} run: | - rustup update - rustup toolchain install nightly --profile minimal - rustup component add rustfmt --toolchain nightly - # rustup component add clippy --toolchain nightly + if [ -z $nightly ]; then + toolchain=$(grep channel rust-toolchain.toml | sed -r 's/channel = "(.*)"/\1/') + echo "installing toolchain $toolchain from rust-toolchain.toml" + else + toolchain='nightly' + echo "installing toolchain nightly" + echo "also setting RUSTUP_TOOLCHAIN to nightly" + echo "RUSTUP_TOOLCHAIN=nightly" >> "$GITHUB_ENV" + fi + rm /home/runner/.cargo/bin/rustfmt + rustup toolchain install $toolchain --profile minimal + rustup component add --toolchain $toolchain rustfmt + rustup component add --toolchain $toolchain clippy - name: Install just uses: taiki-e/install-action@v2 @@ -33,12 +50,17 @@ jobs: - name: Install protoc uses: arduino/setup-protoc@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Set up Rust cache uses: Swatinem/rust-cache@v2 + - name: Build + run: just check + - name: Check code format - run: just fmt_check + run: just fmt-check - name: Run linter run: just lint diff --git a/justfile b/justfile index 16b5c05..01f8ddd 100644 --- a/justfile +++ b/justfile @@ -1,21 +1,30 @@ set shell := ["bash", "-uc"] check: + @echo "RUSTUP_TOOLCHAIN is ${RUSTUP_TOOLCHAIN:-not set}" cargo check --tests fmt: - cargo +nightly fmt + @echo "RUSTUP_TOOLCHAIN is ${RUSTUP_TOOLCHAIN:-not set}" + cargo fmt -fmt_check: - cargo +nightly fmt --check +fmt-check: + @echo "RUSTUP_TOOLCHAIN is ${RUSTUP_TOOLCHAIN:-not set}" + cargo fmt --check lint: + @echo "RUSTUP_TOOLCHAIN is ${RUSTUP_TOOLCHAIN:-not set}" cargo clippy --no-deps -- -D warnings test: + @echo "RUSTUP_TOOLCHAIN is ${RUSTUP_TOOLCHAIN:-not set}" cargo test -all: fmt check lint test +fix: + @echo "RUSTUP_TOOLCHAIN is ${RUSTUP_TOOLCHAIN:-not set}" + cargo fix --allow-dirty --allow-staged + +all: check fmt lint test run-gateway: RUST_LOG=hello_tracing_gateway=debug,info \ diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 292fe49..6edd601 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "stable" +channel = "nightly-2023-11-11"