fix: rewrote settings logic to mimic aw-server-python behavior (#428) #787
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@v3 | |
- name: Set up Rust nightly | |
id: toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: nightly | |
override: true | |
- name: Cache cargo build | |
uses: actions/cache@v3 | |
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 rustc_hash due to https://github.com/ActivityWatch/aw-server-rust/issues/180 | |
key: ${{ runner.os }}-${{ env.cache-name }}-${{ steps.toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-${{ env.cache-name }}-${{ steps.toolchain.outputs.rustc_hash }}- | |
- name: Build | |
run: cargo build --workspace --verbose | |
- name: Run tests | |
run: cargo test --workspace --verbose | |
- uses: actions/upload-artifact@v3 | |
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@v3 | |
- name: Set up Rust nightly | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: nightly | |
override: true | |
- name: Cache cargo build | |
uses: actions/cache@v3 | |
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@v3 | |
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@v3 | |
- name: Set up Rust nightly | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: nightly | |
override: true | |
# 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. | |
# NOTE: actions-rs is unmaintained, using fork with fix for update to node 16 | |
# https://github.com/actions-rs/tarpaulin/pull/22 | |
- uses: FreeMasen/tarpaulin-action@9f7e03f06fea8f374c85a95c2ecff6a4d5805845 | |
with: | |
version: "0.22.0" # not latest, due to error/bug in action (after release artifacts changed name?) | |
# Note: closed-source code needs to provide a token, | |
# but open source code does not. | |
- name: Upload to codecov.io | |
uses: codecov/codecov-action@v3 | |
# Code coverage using grcov | |
#build-coverage-grcov: | |
# name: Build with coverage | |
# runs-on: ubuntu-latest | |
# steps: | |
# - uses: actions/checkout@v3 | |
# - name: Set up Rust nightly | |
# uses: actions-rs/toolchain@v1 | |
# with: | |
# profile: minimal | |
# toolchain: nightly | |
# override: true | |
# - name: Cache cargo build | |
# uses: actions/cache@v3 | |
# 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; |