Update README #143
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: 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 |