@@ -2,71 +2,16 @@ name: package
22permissions :
33 contents : read
44on :
5+ pull_request :
6+ paths :
7+ - " codecarbon/**"
8+ - " pyproject.toml"
9+ branches : [master]
510 push :
611 paths :
712 - " codecarbon/**"
813 - " pyproject.toml"
914 branches : [master]
1015jobs :
11-
12- build-package :
13- runs-on : ubuntu-latest
14- steps :
15- - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
16- - name : Install uv
17- uses : astral-sh/setup-uv@caf0cab7a618c569241d31dcd442f54681755d39 # v3.2.4
18- with :
19- version : " latest"
20- - name : Set up Python
21- run : uv python install 3.12
22- - name : Check versions
23- run : uv run python .github/pyproject_versions.py -o
24- - name : Build pip package
25- run : uv build
26- - name : Archive Pypi artifacts
27- uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
28- with :
29- name : pypi_dist
30- path : dist
31-
32- test-package-from-wheel :
33- runs-on : ubuntu-24.04
34- needs : [build-package]
35- steps :
36- - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
37- with :
38- sparse-checkout : |
39- tests/
40- pytest.ini
41- sparse-checkout-cone-mode : false
42- - name : Install uv
43- uses : astral-sh/setup-uv@caf0cab7a618c569241d31dcd442f54681755d39 # v3.2.4
44- with :
45- version : " latest"
46- - name : Set up Python
47- run : uv python install 3.12
48- - name : Download built package
49- uses : actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
50- with :
51- name : pypi_dist
52- path : dist
53- - name : Create clean virtual environment
54- run : |
55- uv venv .venv --python 3.12
56- echo "VIRTUAL_ENV=$PWD/.venv" >> $GITHUB_ENV
57- echo "$PWD/.venv/bin" >> $GITHUB_PATH
58- - name : Install package from wheel (without source)
59- run : |
60- # Install the wheel and test dependencies without the source code
61- uv pip install dist/*.whl
62- uv pip install pytest pytest-mock requests-mock responses pandas logfire
63- - name : Test package integrity
64- run : |
65- # Run the package integrity tests to verify all data files are included
66- uv run python -m pytest tests/test_package_integrity.py -v
67- CODECARBON_ALLOW_MULTIPLE_RUNS=True pytest --ignore=tests/test_viz_data.py -vv -m 'not integ_test' tests/
68- - name : Test CLI functionality
69- run : |
70- # Test that the CLI is functional
71- codecarbon --help
72- python -c "from codecarbon import EmissionsTracker; print('✓ Package import successful')"
16+ validate-package :
17+ uses : ./.github/workflows/package-validation-reusable.yml
0 commit comments