Skip to content

Commit

Permalink
Merge pull request #13 from andrewdavidmackenzie/add-CI
Browse files Browse the repository at this point in the history
add-gh-ci
  • Loading branch information
andrewdavidmackenzie authored May 13, 2024
2 parents a113b61 + e98290e commit d386385
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 1 deletion.
77 changes: 77 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Build and Test with Coverage

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
schedule: # Build every day at 5PM UTC
- cron: '0 17 * * *'

env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0

jobs:
clippy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable

- name: install cross
run: cargo install cross --git https://github.com/cross-rs/cross

- name: make clippy
run: make clippy

build-and-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ macos-14, ubuntu-latest ]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable

- name: InstallLinuxDependencies
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get -y install lcov

- name: InstallMacDependencies
if: runner.os == 'macOS'
run: brew install lcov

- name: ConfigureCoverage
run: |
cargo install grcov
rustup component add llvm-tools-preview
echo RUSTFLAGS="-C instrument-coverage" >> "$GITHUB_ENV"
echo LLVM_PROFILE_FILE="flow-%p-%m.profraw" >> "$GITHUB_ENV"
- name: install cross
run: cargo install cross --git https://github.com/cross-rs/cross

- name: build
run: make build

- name: test
run: make test

- name: Upload code coverage
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ release: release-build pibuild

.PHONY: piclippy
piclippy:
CROSS_CONTAINER_OPTS="--platform linux/amd64" cross clippy --release --features "rppal","iced" --target=aarch64-unknown-linux-gnu
CROSS_CONTAINER_OPTS="--platform linux/amd64" cross clippy --release --features "rppal","iced" --tests --no-deps --target=aarch64-unknown-linux-gnu

.PHONY: clippy
clippy: piclippy
cargo clippy --features "iced" --tests --no-deps
#-- --warn clippy::pedantic -D warnings

# This will build all binaries on the current host, be it macos, linux or raspberry pi
# Only enable the "iced" feature so we only build the "piggui" binary
Expand All @@ -39,6 +44,12 @@ release-build:
pibuild:
CROSS_CONTAINER_OPTS="--platform linux/amd64" cross build --release --features "rppal","iced" --target=aarch64-unknown-linux-gnu

# This will only test GUI tests in piggui on the local host, whatever that is
# We'd need to think how to run tests on RPi, on piggui with GUI and GPIO functionality, and piglet with GPIO functionality
.PHONY: test
test:
cargo test --features "iced"

.PHONY: copy
copy: pibuild
scp target/aarch64-unknown-linux-gnu/release/piggui $(PI_USER)@$(PI_TARGET):~/
Expand Down

0 comments on commit d386385

Please sign in to comment.