-
Notifications
You must be signed in to change notification settings - Fork 3
107 lines (106 loc) · 3.74 KB
/
test.yaml
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 Astarte.
#
# Copyright 2024 SECO Mind Srl
#
# SPDX-License-Identifier: Apache-2.0
name: test
on:
workflow_call:
workflow_dispatch:
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
# Enable logging otherwise the logging lines will count as not covered in the test coverage
RUST_LOG: trace
jobs:
required:
runs-on: ubuntu-latest
name: ubuntu / ${{ matrix.toolchain }}
strategy:
matrix:
toolchain: [stable, beta]
steps:
- uses: actions/checkout@v4
- name: Install ${{ matrix.toolchain }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
- name: Install sccache-cache
uses: mozilla-actions/[email protected]
- name: cargo generate-lockfile
if: hashFiles('Cargo.lock') == ''
run: cargo generate-lockfile
- name: Run cargo test --locked
run: cargo test --locked --all-features --all-targets --workspace
os-check:
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} / stable / vcpkg
strategy:
fail-fast: false
matrix:
os: [windows-latest]
steps:
- uses: actions/checkout@v4
- name: Install stable
uses: dtolnay/rust-toolchain@stable
- name: Install sccache-cache
uses: mozilla-actions/[email protected]
# Setup vcpkg binary cache
# https://learn.microsoft.com/en-us/vcpkg/users/binarycaching#gha-quickstart
- uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Set VCPKG_ROOT
run: echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Install dependencies
run: vcpkg install --binarysource="clear;x-gha,readwrite" openssl:x64-windows-static-md sqlite3:x64-windows-static-md
- name: cargo generate-lockfile
if: hashFiles('Cargo.lock') == ''
run: cargo generate-lockfile
- name: cargo test
run: cargo test --locked --all-features --all-targets --workspace
coverage:
runs-on: ubuntu-latest
name: ubuntu / stable / coverage
steps:
- uses: actions/checkout@v4
- name: Install stable
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Install sccache-cache
uses: mozilla-actions/[email protected]
- name: cargo install cargo-tarpaulin
uses: taiki-e/install-action@cargo-tarpaulin
- name: cargo generate-lockfile
if: hashFiles('Cargo.lock') == ''
run: cargo generate-lockfile
- name: Run cargo-tarpaulin with xml output
run: cargo tarpaulin --engine llvm --locked --all-features --ignore-tests --lib --out xml -- --test-threads 1
# Upload the coverage if we are not a PR from a fork, see ".github/workflows/coverage.yaml"
- name: Upload to codecov.io
if: ${{ github.event_name == 'push' }}
uses: codecov/codecov-action@v4
with:
token: ${{secrets.CODECOV_TOKEN}}
fail_ci_if_error: true
# Save data to use in workflow_run
- name: Save PR number
if: ${{ github.event_name == 'pull_request' }}
env:
PR_NUMBER: ${{ github.event.number }}
run: |
echo "$PR_NUMBER" > ./pr_number
- name: Upload coverage artifact
if: ${{ github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v4
with:
name: coverage
path: |
pr_number
cobertura.xml