-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (89 loc) · 2.96 KB
/
build_and_test.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
# This file is part of the rust-for-it project.
#
# Copyright (c) 2023 Sebastian Pipping <[email protected]>
# SPDX-License-Identifier: MIT
name: Build and test
on:
pull_request:
push:
schedule:
- cron: '0 16 * * 5' # Every Friday 4pm
workflow_dispatch:
defaults:
run:
shell: bash
jobs:
build_and_test:
name: Build and test
strategy:
fail-fast: false
matrix:
runs-on: [macos-latest, ubuntu-24.04, windows-latest]
runs-on: ${{ matrix.runs-on }}
env:
RUSTFLAGS: "-Cinstrument-coverage -D warnings"
steps:
- name: Check out
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Build
run: |-
set -x
rustc --version --verbose
cargo build
cargo build --tests
- name: Check whether Cargo.lock is in sync
run: |-
git diff --exit-code -- Cargo.lock # non-empty diff fails CI
- name: Test
run: |-
set -x
for i in {1..10}; do
cargo test -- --test-threads 10 --nocapture --color=always
done
- name: Smoke test CLI
run: |-
set -x
cargo run -- --version
cargo run -- --help
! cargo run -- --strict -t1 -s google.com:1234 -- true
! cargo run -- --strict -t1 -s somewhere.invalid:80 -- true
cargo run -- -t0 -s google.com:80 -- echo 'Google is up'
- name: Install coverage tools
if: runner.os == 'Linux'
run: |-
set -x
# Install grcov
wget https://github.com/mozilla/grcov/releases/download/v0.8.19/grcov-x86_64-unknown-linux-gnu.tar.bz2
tar xf grcov-x86_64-unknown-linux-gnu.tar.bz2
chmod a+x grcov
mkdir -p ~/.local/bin/
mv grcov ~/.local/bin/
echo "${USER}/.local/bin/" >> "${GITHUB_PATH}"
# Install lcov + llvm for llvm-profdata
sudo apt-get update
sudo apt-get install --yes --no-install-recommends -V \
lcov \
llvm
- name: Render coverage report
if: runner.os == 'Linux'
run: |-
set -x
grcov_args=(
--binary-path target/debug
--source-dir src
--ignore '/*'
--branch
# grcov needs help finding llvm-profdata, apparently
--llvm-path "$(dirname "$(which llvm-profdata)")"
)
grcov "${grcov_args[@]}" -t html -o target/coverage/html .
grcov "${grcov_args[@]}" -t lcov -o target/coverage/lcov .
lcov --list target/coverage/lcov 2>/dev/null \
| tee target/coverage/summary.txt
- name: Store coverage report
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
if: runner.os == 'Linux'
with:
name: coverage_${{ matrix.runs-on }}_${{ github.sha }}
path: target/coverage/
if-no-files-found: error