Skip to content

Commit c8e22c4

Browse files
committed
docs: update .github/workflows/ci.yml via Apex Optimizer
1 parent 2af9e00 commit c8e22c4

File tree

1 file changed

+43
-40
lines changed

1 file changed

+43
-40
lines changed

.github/workflows/ci.yml

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,65 @@
1-
name: CI Pipeline
1+
# .github/workflows/ci.yml
2+
# Apex Technical Authority Standard CI/CD Pipeline (Python/uv/Ruff/Pytest)
3+
4+
name: CI | Build, Test, and Lint
25

3-
# Trigger the workflow on push events to the main branch and pull requests targeting the main branch.
46
on:
57
push:
6-
branches: [ main ]
8+
branches: ["main"]
79
pull_request:
8-
branches: [ main ]
10+
branches: ["main"]
11+
workflow_dispatch:
912

10-
# Define environment variables for the workflow
11-
env:
12-
PYTHON_VERSION: '3.10'
13-
REPO_NAME: 'Academic-Python-Lab-Solutions-Toolkit'
14-
OWNER_NAME: 'chirag127'
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
15+
cancel-in-progress: true
1516

1617
jobs:
1718
build-and-test:
18-
name: Build and Test
19-
runs-on: ubuntu-latest # Use the latest Ubuntu runner
19+
name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
20+
runs-on: ${{ matrix.os }}
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
os: [ubuntu-latest]
25+
python-version: ["3.10", "3.11", "3.12"]
2026

2127
steps:
22-
# Step 1: Checkout the repository code
23-
- name: Checkout repository
28+
- name: 1. | Check out repository
2429
uses: actions/checkout@v4
25-
with:
26-
fetch-depth: 0 # Fetch all history for accurate blame/coverage analysis
2730

28-
# Step 2: Set up Python environment
29-
- name: Set up Python ${{ env.PYTHON_VERSION }}
31+
- name: 2. | Set up Python ${{ matrix.python-version }}
3032
uses: actions/setup-python@v5
3133
with:
32-
python-version: ${{ env.PYTHON_VERSION }}
33-
cache: 'uv'
34+
python-version: ${{ matrix.python-version }}
3435

35-
# Step 3: Install dependencies using uv
36-
- name: Install dependencies with uv
37-
run: |
38-
python -m uv pip install --system --upgrade pip
39-
python -m uv pip install --system --all-extras # Installs all extras, including dev dependencies
36+
- name: 3. | Install uv (Ultra-Fast Python Package Manager)
37+
uses: astral-sh/install-uv-action@v1
4038

41-
# Step 4: Lint and format code with Ruff
42-
- name: Lint and format with Ruff
39+
- name: 4. | Install project dependencies via uv
4340
run: |
44-
python -m uv exec ruff format --check .
45-
python -m uv exec ruff check .
41+
# Create a virtual environment
42+
uv venv
43+
# Install main and dev dependencies
44+
if [ -f requirements-dev.txt ]; then
45+
uv pip install -r requirements.txt -r requirements-dev.txt
46+
else
47+
uv pip install -r requirements.txt
48+
fi
49+
shell: bash
4650

47-
# Step 5: Run tests with Pytest
48-
- name: Run tests with Pytest
49-
run: |
50-
python -m uv exec pytest --cov=${{ env.REPO_NAME }} --cov-report=xml
51-
# The --cov=${{ env.REPO_NAME }} flag enables coverage collection for the package itself.
52-
# The --cov-report=xml generates a coverage report in XML format, suitable for Codecov.
51+
- name: 5. | Lint with Ruff
52+
run: uv run ruff check .
53+
54+
- name: 6. | Check formatting with Ruff
55+
run: uv run ruff format --check .
56+
57+
- name: 7. | Run tests and generate coverage report
58+
run: uv run pytest --cov=./ --cov-report=xml
5359

54-
# Step 6: Upload coverage report to Codecov
55-
# This step assumes you have a CODECOV_TOKEN set in your GitHub repository secrets.
56-
- name: Upload coverage to Codecov
60+
- name: 8. | Upload coverage to Codecov
5761
uses: codecov/codecov-action@v4
58-
if: github.ref == 'refs/heads/main' || github.ref == 'refs/pull/${{ github.event.number }}/merge'
5962
with:
6063
token: ${{ secrets.CODECOV_TOKEN }}
61-
# This token is required for uploading coverage reports to Codecov.
62-
# It should be configured as a secret in your GitHub repository settings.
64+
fail_ci_if_error: true
65+
verbose: true

0 commit comments

Comments
 (0)