Skip to content

Commit 171143f

Browse files
committed
docs: update .github/workflows/ci.yml via Apex Optimizer
1 parent a226c78 commit 171143f

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

.github/workflows/ci.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: CI Pipeline
2+
3+
# Trigger the workflow on push events to the main branch and pull requests targeting the main branch.
4+
on:
5+
push:
6+
branches: [ main ]
7+
pull_request:
8+
branches: [ main ]
9+
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'
15+
16+
jobs:
17+
build-and-test:
18+
name: Build and Test
19+
runs-on: ubuntu-latest # Use the latest Ubuntu runner
20+
21+
steps:
22+
# Step 1: Checkout the repository code
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0 # Fetch all history for accurate blame/coverage analysis
27+
28+
# Step 2: Set up Python environment
29+
- name: Set up Python ${{ env.PYTHON_VERSION }}
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: ${{ env.PYTHON_VERSION }}
33+
cache: 'uv'
34+
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
40+
41+
# Step 4: Lint and format code with Ruff
42+
- name: Lint and format with Ruff
43+
run: |
44+
python -m uv exec ruff format --check .
45+
python -m uv exec ruff check .
46+
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.
53+
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
57+
uses: codecov/codecov-action@v4
58+
if: github.ref == 'refs/heads/main' || github.ref == 'refs/pull/${{ github.event.number }}/merge'
59+
with:
60+
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.

0 commit comments

Comments
 (0)