-
-
Notifications
You must be signed in to change notification settings - Fork 56
134 lines (125 loc) · 4.38 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
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
id: toolchain
uses: dtolnay/rust-toolchain@stable
- 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 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@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
uses: dtolnay/rust-toolchain@stable
- 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
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.
# 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;