Merge pull request #3 from gmuloc/ci-adjust-sonar #36
This file contains hidden or 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: "Build and Test Pull Request and main branch" | |
| "on": | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| concurrency: | |
| # For PRs the head_ref will be used. For Merge Queues (merge_group) we fallback to run_id. | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| env: | |
| # Augment verbosity if ACTIONS_STEP_DEBUG is set | |
| CIBW_BUILD_VERBOSITY: ${{ secrets.ACTIONS_STEP_DEBUG && 3 || 0 }} | |
| # TODO: Check if this is used for pytest | |
| PY_COLORS: 1 | |
| # rust | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| # -------------------------------------------- # | |
| # Python type checking not covered in pre-commit | |
| # -------------------------------------------- # | |
| python_type_checking: | |
| name: Python Linting not covered in pre-commit | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.12" | |
| - name: Install pyavd-utils | |
| # Adding pyavd-utils as editable to force a build of the .so files. | |
| run: | | |
| pip install -e . --group pytest --upgrade | |
| - name: PyRight static type checker | |
| # Specific SHA as allowed by github org admins | |
| uses: jakebailey/pyright-action@6cabc0f01c4994be48fd45cd9dbacdd6e1ee6e5e | |
| python_coverage: | |
| name: Python coverage | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: 3.11 | |
| - name: Install tox | |
| run: | | |
| pip install tox --upgrade | |
| - name: Generate coverage report | |
| run: |- | |
| tox run -e coverage,report | |
| - name: Upload pytest coverage data | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: pytest-coverage | |
| path: coverage.xml | |
| # ----------------------------------- # | |
| # Cargo build, test and linting | |
| # ----------------------------------- # | |
| cargo_build_and_test: | |
| name: Cargo build, test and linting on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: | |
| - ubuntu-latest | |
| - ubuntu-24.04-arm | |
| - windows-latest | |
| - macos-15-intel | |
| - macos-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| # This is needed for arm machines since they don't ship with 2024 edition. | |
| - name: Upgrade rust and cargo | |
| run: rustup update stable | |
| # This is needed because we have pyo3 tests and our minimum python version is 3.10. | |
| # On some test containers (looking at you windows-latest) the included Python is 3.9. | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.12" | |
| - name: Check code formatting with cargo fmt | |
| run: cargo fmt --verbose | |
| if: | | |
| matrix.os == 'ubuntu-latest' | |
| - name: Check code style with clippy | |
| run: cargo clippy --all-targets --all-features | |
| if: | | |
| matrix.os == 'ubuntu-latest' | |
| - name: Run all tests | |
| run: cargo test --all-targets --all-features | |
| - name: Generate coverage report with cargo llvm-cov | |
| run: | | |
| rustup component add llvm-tools-preview --toolchain stable-x86_64-unknown-linux-gnu | |
| cargo install cargo-llvm-cov | |
| cargo llvm-cov --all-targets --all-features --lcov --output-path lcov.info | |
| if: | | |
| matrix.os == 'ubuntu-latest' | |
| - name: Upload coverage report | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: rust-llvm-cov | |
| path: lcov.info | |
| if: | | |
| matrix.os == 'ubuntu-latest' | |
| - name: Test building to all targets | |
| run: cargo build --all-targets --all-features | |
| - name: Check Rust dependencies with cargo deny | |
| run: | | |
| cargo install cargo-deny | |
| cargo deny check | |
| if: |- | |
| matrix.os == 'ubuntu-latest' | |
| # --------------------------------------------------------------------- # | |
| # Build and test cross platform pyavd-utils wheels and upload artifacts | |
| # --------------------------------------------------------------------- # | |
| build_and_test_pyavd_utils_wheels: | |
| name: Build pyavd-utils wheel on ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: | |
| - ubuntu-latest | |
| - ubuntu-24.04-arm | |
| - windows-latest | |
| - macos-15-intel | |
| - macos-latest | |
| uses: ./.github/workflows/build-wheel.yml | |
| with: | |
| runner: ${{ matrix.os }} |