-
-
Notifications
You must be signed in to change notification settings - Fork 4
128 lines (108 loc) · 3.77 KB
/
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: Test
on:
push:
branches:
- main
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
# https://blog.rust-lang.org/2022/06/22/sparse-registry-testing.html
CARGO_UNSTABLE_SPARSE_REGISTRY: false
# https://doc.rust-lang.org/beta/cargo/reference/config.html#registriescrates-ioprotocol
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: git
jobs:
Testing:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v3
- name: Set up Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
- name: Cache Rust
uses: Swatinem/rust-cache@v2
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: "requirements_dev.txt"
- name: Create virtual environment
run: |
python -m venv venv
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
components: llvm-tools-preview
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: "Test Rust"
if: matrix.os == 'ubuntu-latest'
run: |
source <(cargo llvm-cov show-env --export-prefix)
cargo test
- name: Install tzfpy and test(Windows)
if: matrix.os == 'windows-latest'
shell: bash
run: |
source venv/Scripts/activate
python -m pip install --upgrade pip
pip install -r requirements_dev.txt
maturin develop --release --extras=pytz
pytest --cov --cov-report xml | tee benchmark_result.txt
- name: Install tzfpy and test(Ubuntu&macoS)
if: matrix.os != 'windows-latest'
shell: bash
run: |
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements_dev.txt
maturin develop --release --extras=pytz
pytest --cov --cov-report xml | tee benchmark_result.txt
- name: Postprocessing cov
if: matrix.os == 'ubuntu-latest'
run: |
source <(cargo llvm-cov show-env --export-prefix)
cargo llvm-cov --no-run --lcov --output-path coverage.lcov
- uses: codecov/codecov-action@v3
if: matrix.os == 'ubuntu-latest'
with:
files: coverage.lcov,coverage.xml
name: ${{ matrix.os }}
- name: Setup benchmark file name
id: gen-benchmark-file-name
shell: bash
run: |
echo "filename=tzfpy_benchmark_py_${{ matrix.python-version }}_${{ matrix.os }}.md" >> $GITHUB_OUTPUT
- name: Report
shell: bash
run: |
set +e
echo "## Python ${{ matrix.python-version }} with ${{ matrix.os }}" >> ${{ steps.gen-benchmark-file-name.outputs.filename }}
echo '```' >> ${{ steps.gen-benchmark-file-name.outputs.filename }}
cat benchmark_result.txt >> ${{ steps.gen-benchmark-file-name.outputs.filename }}
echo '```' >> ${{ steps.gen-benchmark-file-name.outputs.filename }}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: "benchmark_result_as_md"
path: ${{ steps.gen-benchmark-file-name.outputs.filename }}
Report:
needs: [Testing]
runs-on: ubuntu-latest
steps:
- name: Download a Build Artifact
uses: actions/download-artifact@v3
with:
name: "benchmark_result_as_md"
path: ""
- run: cat tzfpy_benchmark_*.md > $GITHUB_STEP_SUMMARY