Skip to content

Commit

Permalink
build: use fixed nightly (#38)
Browse files Browse the repository at this point in the history
* build: use fixed nightly

* fixes

* fix

* fixxx
  • Loading branch information
hseeberger authored Nov 16, 2023
1 parent a9e5197 commit 019b0ed
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 13 deletions.
38 changes: 30 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
17 changes: 13 additions & 4 deletions justfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "stable"
channel = "nightly-2023-11-11"

0 comments on commit 019b0ed

Please sign in to comment.