Skip to content

Commit

Permalink
Use make file targets in CI
Browse files Browse the repository at this point in the history
Signed-off-by: Sreekanth <prsreekanth920@gmail.com>
  • Loading branch information
BulkBeing committed Oct 8, 2024
1 parent 6ef61c4 commit f5684c9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 31 deletions.
45 changes: 15 additions & 30 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,28 @@ jobs:
runs-on: ubuntu-24.04
steps:
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Rust
uses: actions-rs/toolchain@v1
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
override: true
cache-workspaces: |
. -> target
- name: Cache Cargo dependencies
uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Install protoc (for Protocol Buffers)
- name: Configure sccache
run: |
set -eux -o pipefail
PROTOC_VERSION=3.19.4
PROTOC_ZIP=protoc-$PROTOC_VERSION-linux-x86_64.zip
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOC_VERSION/$PROTOC_ZIP
sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
sudo unzip -o $PROTOC_ZIP -d /usr/local 'include/*'
sudo chmod +x /usr/local/bin/protoc
sudo find /usr/local/include -type f | xargs sudo chmod a+r
sudo find /usr/local/include -type d | xargs sudo chmod a+rx
rm -f $PROTOC_ZIP
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.5
- name: Install dependencies
run: sudo apt-get install -y protobuf-compiler

- name: Build
run: cargo build --verbose
- name: Lint
run: make lint

- name: Run tests
run: cargo test --verbose
run: make test

- name: Check formatting
run: cargo fmt --all -- --check
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@ fmt:

# Check if all files are formatted and run clippy on all directories containing a Cargo.toml file
.PHONY: lint
lint:
lint: test-fmt clippy

.PHONY: test-fmt
test-fmt:
@for dir in $(DIRS); do \
echo "Checking if code is formatted in directory: $$dir"; \
cargo fmt --all --check --manifest-path "$$dir/Cargo.toml" || { echo "Code is not formatted in $$dir"; exit 1; }; \
done

.PHONY: clippy
clippy:
@for dir in $(DIRS); do \
echo "Running clippy in directory: $$dir"; \
cargo clippy --workspace --manifest-path "$$dir/Cargo.toml" -- -D warnings || { echo "Clippy warnings/errors found in $$dir"; exit 1; }; \
done
Expand Down

0 comments on commit f5684c9

Please sign in to comment.