This repository was archived by the owner on Aug 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (64 loc) · 2.82 KB
/
Copy pathci.yml
File metadata and controls
82 lines (64 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Lint and Test
on:
push:
pull_request:
permissions:
contents: write
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12.9"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Download and preprocess dataset
run: |
python model_training/dataset.py download
python model_training/dataset.py preprocess
- name: Run tests and capture adequacy score
run: pytest tests/ | tee reports/test_output.txt
- name: Run tests with coverage
run: pytest --cov=model_training --cov-config=coverage.ini --cov-report=xml --cov-report=term tests/
- name: Run pylint
run: pylint model_training/ tests/ --fail-under=7
- name: Install pybadges
run: pip install pybadges
- name: Generate pylint badge
run: |
pylint model_training/ tests/ --exit-zero > reports/pylint_output.txt || true
echo "---- Pylint output start ----"
cat reports/pylint_output.txt
echo "---- Pylint output end ----"
SCORE=$(grep "rated at" reports/pylint_output.txt | sed -E 's/.*rated at ([0-9]+\.[0-9]+)\/.*/\1/' || echo "0")
echo "Pylint score: $SCORE"
mkdir -p badges
python -m pybadges --left-text="pylint" --right-text="$SCORE/10" --right-color="green" > reports/badges/pylint.svg
- name: Generate test adequacy badge
run: |
RAW_SCORE=$(cat reports/ml_test_score.txt)
ADEQUACY_SCORE=${RAW_SCORE:-0}
echo "Adequacy score is $ADEQUACY_SCORE%"
mkdir -p badges
python -m pybadges --left-text="adequacy" --right-text="$ADEQUACY_SCORE%" --right-color="orange" > reports/badges/adequacy.svg
- name: Generate test coverage badge
run: |
COVERAGE=$(grep -m 1 -Po 'line-rate="\K[\d.]+' coverage.xml | awk '{ printf("%.0f", $1 * 100) }')
echo "Coverage is $COVERAGE%"
mkdir -p badges
python -m pybadges --left-text="coverage" --right-text="$COVERAGE%" --right-color="blue" > reports/badges/coverage.svg
- name: Commit and push badge
if: github.event_name == 'push'
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git remote set-url origin https://x-access-token:${{ secrets.GH_PAT }}@github.com/${{ github.repository }}
git add reports/badges/pylint.svg reports/badges/adequacy.svg reports/badges/coverage.svg
git commit -m "Auto-update pylint badge" || echo "No changes to commit"
git push origin HEAD:${{ github.ref_name }}