Skip to content

Commit 5f24d04

Browse files
committed
some updates
1 parent ef9d911 commit 5f24d04

9 files changed

Lines changed: 473 additions & 59 deletions

File tree

.github/workflows/README.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# GitHub Workflows
2+
3+
This directory contains the modernized GitHub Actions workflows for the mlscorecheck project.
4+
5+
## Workflows Overview
6+
7+
### 1. **Build & Test** (`build.yml`)
8+
**Triggers:** Push/PR to main/develop branches
9+
10+
**Features:**
11+
- **Code Quality**: Linting with flake8
12+
- **Multi-platform Testing**: Ubuntu, Windows, macOS
13+
- **Multi-version Testing**: Python 3.10, 3.11, 3.12, 3.13
14+
- **Coverage Reporting**: Integrated with Codecov
15+
- **Build Artifacts**: Uploads wheel and source distribution
16+
- **Concurrency Control**: Cancels redundant runs
17+
18+
**Jobs:**
19+
1. `lint` - Code quality checks
20+
2. `test` - Cross-platform testing with coverage
21+
3. `build` - Package building and artifact upload
22+
23+
### 2. **Release** (`release.yml`)
24+
**Triggers:** GitHub releases or manual dispatch
25+
26+
**Features:**
27+
- **Trusted Publishing**: Secure PyPI publishing without tokens
28+
- **Test PyPI Support**: Option to publish to test environment
29+
- **Release Validation**: Runs tests before publishing
30+
- **GitHub Assets**: Automatically uploads wheels to releases
31+
- **Dual Environment**: Supports both PyPI and Test PyPI
32+
33+
**Jobs:**
34+
1. `validate-release` - Pre-publish validation
35+
2. `build-and-publish` - Build and publish to PyPI
36+
3. `create-github-release-assets` - Upload to GitHub releases
37+
38+
### 3. **Documentation** (`docs.yml`)
39+
**Triggers:** Changes to docs/ or mlscorecheck/ directories
40+
41+
**Features:**
42+
- **Sphinx Documentation**: Builds HTML documentation
43+
- **Warning Detection**: Fails on warnings/errors
44+
- **Artifact Upload**: Stores built docs as artifacts
45+
- **Path-based Triggers**: Only runs when relevant files change
46+
47+
**Jobs:**
48+
1. `build-docs` - Build and validate documentation
49+
50+
## Key Improvements
51+
52+
### Security
53+
- **Trusted Publishing**: Uses OIDC tokens instead of API keys
54+
- **Environment Protection**: Release jobs require approval
55+
- **Minimal Permissions**: Only grants necessary permissions
56+
57+
### Performance
58+
- **Concurrency Control**: Cancels redundant workflow runs
59+
- **Conditional Execution**: Docs only build when needed
60+
- **Artifact Caching**: Efficient dependency management
61+
62+
### Maintainability
63+
- **Modern Actions**: Uses latest action versions (v4, v5)
64+
- **Clear Job Names**: Descriptive and organized
65+
- **Fail-Fast Strategy**: Quick feedback on failures
66+
- **Comprehensive Testing**: Multiple OS and Python versions
67+
68+
### Developer Experience
69+
- **Manual Dispatch**: Test releases manually
70+
- **Clear Feedback**: Detailed job names and status
71+
- **Artifact Downloads**: Easy access to build outputs
72+
- **Path-based Triggers**: Reduced unnecessary runs
73+
74+
## Migration Notes
75+
76+
The new workflows replace the previous files:
77+
-`pythonpackage.yml` → ✅ `build.yml`
78+
-`pythonpublish.yml` → ✅ `release.yml`
79+
-`codecov.yml` → ✅ Integrated into `build.yml`
80+
81+
All functionality is preserved while adding modern best practices and improved organization.

.github/workflows/build.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Build & Test
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
lint:
15+
name: Code Quality
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: '3.11'
25+
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install flake8
30+
31+
- name: Lint with flake8
32+
run: |
33+
# stop the build if there are Python syntax errors or undefined names
34+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
35+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
36+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
37+
38+
test:
39+
name: Test Python ${{ matrix.python-version }} on ${{ matrix.os }}
40+
runs-on: ${{ matrix.os }}
41+
needs: lint
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
os: [ubuntu-latest, windows-latest, macos-latest]
46+
python-version: ['3.10', '3.11', '3.12', '3.13']
47+
48+
steps:
49+
- name: Checkout code
50+
uses: actions/checkout@v4
51+
52+
- name: Set up Python ${{ matrix.python-version }}
53+
uses: actions/setup-python@v5
54+
with:
55+
python-version: ${{ matrix.python-version }}
56+
57+
- name: Install dependencies
58+
run: |
59+
python -m pip install --upgrade pip
60+
pip install -r requirements.txt
61+
pip install pytest coverage
62+
63+
- name: Install package
64+
run: pip install -e .
65+
66+
- name: Run tests with coverage
67+
run: |
68+
coverage run --source mlscorecheck -m pytest tests/
69+
coverage xml
70+
71+
- name: Upload coverage to Codecov
72+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
73+
uses: codecov/codecov-action@v4
74+
with:
75+
file: ./coverage.xml
76+
flags: unittests
77+
name: codecov-umbrella
78+
fail_ci_if_error: false
79+
verbose: true
80+
81+
build:
82+
name: Build Package
83+
runs-on: ubuntu-latest
84+
needs: test
85+
steps:
86+
- name: Checkout code
87+
uses: actions/checkout@v4
88+
89+
- name: Set up Python
90+
uses: actions/setup-python@v5
91+
with:
92+
python-version: '3.11'
93+
94+
- name: Install build dependencies
95+
run: |
96+
python -m pip install --upgrade pip
97+
pip install build
98+
99+
- name: Build package
100+
run: python -m build
101+
102+
- name: Upload build artifacts
103+
uses: actions/upload-artifact@v4
104+
with:
105+
name: dist-files
106+
path: dist/
107+
retention-days: 7

.github/workflows/codecov.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.github/workflows/docs.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Documentation
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- 'docs/**'
8+
- 'mlscorecheck/**'
9+
pull_request:
10+
branches: [ main ]
11+
paths:
12+
- 'docs/**'
13+
- 'mlscorecheck/**'
14+
15+
jobs:
16+
build-docs:
17+
name: Build Documentation
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: '3.11'
27+
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
pip install -r requirements.txt
32+
pip install -r docs/requirements.txt
33+
34+
- name: Install package
35+
run: pip install -e .
36+
37+
- name: Build documentation
38+
run: |
39+
cd docs
40+
make html
41+
42+
- name: Check for warnings
43+
run: |
44+
cd docs
45+
make html 2>&1 | tee build.log
46+
if grep -q "WARNING\|ERROR" build.log; then
47+
echo "Documentation build contains warnings or errors"
48+
exit 1
49+
fi
50+
echo "Documentation built successfully without warnings"
51+
52+
- name: Upload documentation artifacts
53+
uses: actions/upload-artifact@v4
54+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
55+
with:
56+
name: documentation
57+
path: docs/_build/html/
58+
retention-days: 30

.github/workflows/pythonpackage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
max-parallel: 4
1111
matrix:
1212
os: [ubuntu-latest, macos-latest, windows-latest]
13-
python-version: ['3.9', '3.10', '3.11']
13+
python-version: ['3.10', '3.11', '3.12', '3.13']
1414

1515
steps:
1616
- uses: actions/checkout@v1

.github/workflows/pythonpublish.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)