infra: pdm, docs #8
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: CI | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
jobs: | |
validate: | |
name: "Validate" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Python 3.11 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.11" | |
- name: Install Pre-Commit | |
run: python -m pip install pre-commit && pre-commit install | |
- name: Execute Pre-Commit | |
run: pre-commit run --show-diff-on-failure --color=always --all-files | |
pyton_tests: | |
name: "Python Tests" | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11"] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- uses: pdm-project/setup-pdm@v3 | |
name: Set up PDM | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install Python Dependencies | |
run: pdm install | |
- name: Set pythonpath | |
run: echo "PYTHONPATH=$PWD" >> $GITHUB_ENV | |
- name: Install library | |
run: pdm run maturin develop | |
- name: Test | |
run: pdm run pytest | |
rust_tests: | |
name: "Rust Tests" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
override: true | |
target: x86_64-unknown-linux-musl | |
components: llvm-tools-preview | |
- name: Download grcov | |
run: | | |
mkdir -p "${HOME}/.local/bin" | |
curl -sL https://github.com/mozilla/grcov/releases/download/v0.8.10/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf - -C "${HOME}/.local/bin" | |
echo "$HOME/.local/bin" >> $GITHUB_PATH | |
- name: Test with Coverage | |
run: CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw' cargo test | |
- name: Generate Coverage Report | |
run: mkdir coverage && grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o coverage.lcov | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: coverage-lcov | |
path: coverage.lcov | |
sonar: | |
name: "Sonar" | |
needs: | |
- pyton_tests | |
- rust_tests | |
- validate | |
if: github.event.pull_request.head.repo.fork == false | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Download Artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: coverage-lcov | |
- name: Fix coverage file for sonarcloud | |
run: sed -i "s/home\/runner\/work\/http_utils\/src/github\/workspace/g" coverage.lcov | |
- name: SonarCloud Scan | |
uses: sonarsource/sonarcloud-github-action@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |