name: Build on: push: branches: [ master ] pull_request: branches: [ master ] jobs: build: name: ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macOS-latest] steps: - uses: actions/checkout@v7 - name: Set up Rust id: toolchain uses: dtolnay/rust-toolchain@stable - name: Cache cargo build uses: actions/cache@v6 if: runner.os != 'macOS' # cache doesn't seem to behave nicely on macOS, see: https://github.com/ActivityWatch/aw-server-rust/issues/180 env: cache-name: cargo-build-target with: path: target # key needs to contain cachekey due to https://github.com/ActivityWatch/aw-server-rust/issues/180 key: ${{ runner.os }}-${{ env.cache-name }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('**/Cargo.lock') }} restore-keys: | ${{ runner.os }}-${{ env.cache-name }}-${{ steps.toolchain.outputs.cachekey }}- - name: Build run: cargo build --workspace --verbose - name: Run tests run: cargo test --workspace --verbose - uses: actions/upload-artifact@v7 with: # TODO: These binaries are debug builds name: binaries-${{runner.os}} path: | target/*/aw-server target/*/aw-server.exe target/*/aw-sync target/*/aw-sync.exe build-android: name: Android runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - name: Verify Android build script cwd handling run: bash ./scripts/test-compile-android-cwd.sh - name: Set up Rust uses: dtolnay/rust-toolchain@stable - name: Cache cargo build uses: actions/cache@v6 env: cache-name: cargo-build-target-android with: path: target key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }} restore-keys: | ${{ runner.os }}-${{ env.cache-name }}- - name: Build run: | export ANDROID_NDK_HOME= # needed because GitHub Actions sets it by default... make android - uses: actions/upload-artifact@v7 with: # TODO: These binaries are debug builds name: binaries-android path: | target/*/*/libaw_server.so # Code coverage using tarpaulin # Works better than grcov, but not as many fancy features (no branch coverage, no LLVM) # See: https://shift.click/blog/github-actions-rust/#code-coverage build-coverage-tarpaulin: name: Code coverage runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - name: Set up Rust uses: dtolnay/rust-toolchain@stable # Note: If you need to combine the coverage info of multiple # feature sets, you need a `.tarpaulin.toml` config file, see # the link above for those docs. - name: Install cargo-tarpaulin run: cargo install cargo-tarpaulin - name: Run tests with coverage run: cargo tarpaulin --out Xml # Note: closed-source code needs to provide a token, # but open source code does not. - name: Upload to codecov.io uses: codecov/codecov-action@v7 # Code coverage using grcov #build-coverage-grcov: # name: Build with coverage # runs-on: ubuntu-latest # steps: # - uses: actions/checkout@v7 # - name: Set up Rust nightly # uses: actions-rs/toolchain@v1 # with: # profile: minimal # toolchain: nightly # override: true # - name: Cache cargo build # uses: actions/cache@v6 # env: # cache-name: cargo-build-target-coverage # with: # path: target # key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }} # restore-keys: | # ${{ runner.os }}-${{ env.cache-name }}- # - name: Install llvm-tools # run: | # rustup component add llvm-tools-preview # - name: Download grcov # run: | # curl -L https://github.com/mozilla/grcov/releases/latest/download/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf - # - name: Run tests with coverage # run: | # # Add cwd to path to find grcov # export PATH=$PATH:. # make coverage-lcov COVERAGE_CACHE=1 # - name: Upload coverage files # run: bash <(curl -s https://codecov.io/bash) -f target/debug/lcov.info;