From 18f41d68610e8c0b093f59697bc33ff8335d94bb Mon Sep 17 00:00:00 2001 From: MountainGod2 <88257202+MountainGod2@users.noreply.github.com> Date: Thu, 28 Nov 2024 16:38:28 -0800 Subject: [PATCH] =?UTF-8?q?ci:=20refactor=20CI=20workflow=20to=20enhance?= =?UTF-8?q?=20code=20quality=20checks=20and=20streamlin=E2=80=A6=20(#109)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ci: refactor CI workflow to enhance code quality checks and streamline documentation deployment * ci: restore unit tests step in CI workflow for improved code validation * ci: add unit tests with coverage and upload coverage report as artifact * ci: update unit test command to include coverage report and restrict artifact upload to Python 3.13 * ci: enhance CI workflow to conditionally run unit tests with coverage and upload reports to Codecov * ci: fix spacing in unit test command for improved readability * ci: simplify unit test command by removing conditional coverage flag * ci: simplify unit test command by removing conditional coverage flag * ci: refactor CI workflow to streamline unit tests and coverage reporting --- .github/workflows/ci.yml | 92 ++++++++++++++++++++++++++++------------ 1 file changed, 64 insertions(+), 28 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 63169bbe..0d803c0a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,17 +6,18 @@ on: pull_request: branches: [main] +env: + UV_CACHE_DIR: /tmp/uv-cache + jobs: ci: - name: CI - Code Quality and Documentation Build + name: Code Quality Checks runs-on: ubuntu-latest strategy: matrix: python-version: [3.11, 3.12, 3.13] fail-fast: true timeout-minutes: 20 - env: - UV_CACHE_DIR: /tmp/uv-cache-${{ matrix.python-version }} steps: - name: Checkout Repository @@ -41,46 +42,81 @@ jobs: - name: Install and Sync Dependencies run: uv sync - - name: Run Code Quality Checks - run: | - uv run ruff format ./ - uv run ruff check --fix ./ - uv run mypy ./ - uv run pylint ./ - uv run pytest ./ - uv run bandit -c pyproject.toml -r ./ - - - name: Build Documentation (Python 3.13 only) - if: matrix.python-version == '3.13' + - name: Run Ruff Formatting + run: uv run ruff format ./ + + - name: Run Ruff Checks + run: uv run ruff check --fix ./ + + - name: Run MyPy Static Typing Checks + run: uv run mypy ./ + + - name: Run Pylint Linting + run: uv run pylint ./ + + - name: Run Bandit Security Checks + run: uv run bandit -c pyproject.toml -r ./ + + docs: + name: Documentation Build and Deployment + runs-on: ubuntu-latest + timeout-minutes: 10 + strategy: + matrix: + python-version: [3.13] + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup UV Environment + uses: astral-sh/setup-uv@v4 + + - name: Install and Sync Dependencies + run: uv sync + + - name: Build Documentation run: uv run --group=docs make clean html --directory docs/ - - name: Deploy Documentation to GitHub Pages (Python 3.13 only) - if: success() && matrix.python-version == '3.13' + - name: Deploy Documentation to GitHub Pages uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: docs/_build/html - - name: Scan Codebase with SonarCloud (Python 3.13 only) - if: matrix.python-version == '3.13' + analysis: + name: Code Analysis and Coverage + runs-on: ubuntu-latest + timeout-minutes: 15 + strategy: + matrix: + python-version: [3.13] + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup UV Environment + uses: astral-sh/setup-uv@v4 + + - name: Install and Sync Dependencies + run: uv sync + + - name: Run Unit Tests with Pytest + run: uv run pytest ./ + + - name: Scan Codebase with SonarCloud uses: SonarSource/sonarcloud-github-action@v3 env: - SONAR_TOKEN: '${{ secrets.SONAR_TOKEN }}' + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - name: Upload Test Coverage Report to Codecov (Python 3.13 only) - if: success() && matrix.python-version == '3.13' + - name: Upload Test Coverage Report to Codecov uses: codecov/codecov-action@v5 with: - token: '${{ secrets.CODECOV_TOKEN }}' + token: ${{ secrets.CODECOV_TOKEN }} files: ./coverage.xml fail_ci_if_error: true - - name: Upload Test Results to Codecov if Tests Failed (Python 3.13 only) - if: ${{ !cancelled() }} && matrix.python-version == '3.13' + - name: Upload Test Results to Codecov + if: failure() uses: codecov/test-results-action@v1 with: token: ${{ secrets.CODECOV_TOKEN }} - - - name: Minimize UV Cache - if: always() - run: uv cache prune --ci