|
8 | 8 | - "pyproject.toml" |
9 | 9 | branches: [master] |
10 | 10 | jobs: |
11 | | - build-package: |
12 | | - runs-on: ubuntu-latest |
| 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/check_version.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 |
| 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')" |
| 73 | +
|
| 74 | + build-conda: |
| 75 | + runs-on: ubuntu-24.04 |
13 | 76 | steps: |
14 | | - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
15 | | - - name: Install uv |
16 | | - uses: astral-sh/setup-uv@caf0cab7a618c569241d31dcd442f54681755d39 # v3.2.4 |
17 | | - with: |
18 | | - version: "latest" |
19 | | - - name: Set up Python |
20 | | - run: uv python install 3.12 |
21 | | - - name: Check versions |
22 | | - run: | |
23 | | - uv run python .github/check_version.py -o |
24 | | - - name: Build pip package |
25 | | - run: | |
26 | | - uv build |
27 | | - - name: Archive Pypi artifacts |
28 | | - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
29 | | - with: |
30 | | - name: pypi_dist |
31 | | - path: dist |
32 | | - python-test: |
33 | | - runs-on: ubuntu-24.04 |
34 | | - strategy: |
35 | | - matrix: |
36 | | - python-version: ["3.9", "3.12", "3.13"] |
37 | | - steps: |
38 | | - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
39 | | - - name: Install uv |
40 | | - uses: astral-sh/setup-uv@caf0cab7a618c569241d31dcd442f54681755d39 # v3.2.4 |
41 | | - with: |
42 | | - version: "latest" |
43 | | - - name: Set up Python ${{ matrix.python-version }} |
44 | | - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 |
45 | | - with: |
46 | | - python-version: ${{ matrix.python-version }} |
47 | | - - name: Install dependencies |
48 | | - run: uv sync |
49 | | - - name: Test package |
50 | | - run: uv run task test-package |
51 | | - build-conda: |
52 | | - runs-on: ubuntu-24.04 |
53 | | - steps: |
54 | | - - name: Checkout |
55 | | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
56 | | - - name: Cache build |
57 | | - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 |
58 | | - with: |
59 | | - path: /tmp/conda-bld |
60 | | - key: build-conda-${{ github.sha }} |
61 | | - - name: set version |
62 | | - run: | |
63 | | - python3 .github/pyproject_versions.py --replace True |
64 | | - - name: Build conda package |
65 | | - uses: prefix-dev/rattler-build-action@20cb88d3095cc01fa181385021c57f886d624879 # v0.2.16 |
66 | | - with: |
67 | | - build-args: --channel codecarbon --channel conda-forge --output-dir /tmp/conda-bld |
68 | | - recipe-path: .conda/recipe.yaml |
69 | | - upload-artifact: false |
70 | | - test-conda: |
71 | | - runs-on: ubuntu-24.04 |
72 | | - needs: [ build-conda ] |
73 | | - steps: |
74 | | - # Checkout needed to get github.sha |
75 | | - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
76 | | - - name: Setup conda |
77 | | - uses: conda-incubator/setup-miniconda@505e6394dae86d6a5c7fbb6e3fb8938e3e863830 # v3.1.1 |
78 | | - with: |
79 | | - activate-environment: codecarbon |
80 | | - miniforge-version: latest |
81 | | - python-version: 3.12 |
82 | | - use-mamba: true |
83 | | - - name: Restore build |
84 | | - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 |
85 | | - with: |
86 | | - path: /tmp/conda-bld |
87 | | - key: build-conda-${{ github.sha }} |
88 | | - fail-on-cache-miss: true |
89 | | - - name: Install package |
90 | | - shell: bash -l {0} |
91 | | - run: mamba install --channel file:///tmp/conda-bld --channel codecarbon codecarbon |
92 | | - - name: Test conda package |
93 | | - shell: bash -l {0} |
94 | | - run: codecarbon --help |
| 77 | + - name: Checkout |
| 78 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 79 | + - name: Cache build |
| 80 | + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 |
| 81 | + with: |
| 82 | + path: /tmp/conda-bld |
| 83 | + key: build-conda-${{ github.sha }} |
| 84 | + - name: set version |
| 85 | + run: | |
| 86 | + python3 .github/pyproject_versions.py --replace True |
| 87 | + - name: Build conda package |
| 88 | + uses: prefix-dev/rattler-build-action@20cb88d3095cc01fa181385021c57f886d624879 # v0.2.16 |
| 89 | + with: |
| 90 | + build-args: --channel codecarbon --channel conda-forge --output-dir /tmp/conda-bld |
| 91 | + recipe-path: .conda/recipe.yaml |
| 92 | + upload-artifact: false |
| 93 | + test-conda: |
| 94 | + runs-on: ubuntu-24.04 |
| 95 | + needs: [ build-conda ] |
| 96 | + steps: |
| 97 | + # Checkout needed to get github.sha |
| 98 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 99 | + - name: Setup conda |
| 100 | + uses: conda-incubator/setup-miniconda@505e6394dae86d6a5c7fbb6e3fb8938e3e863830 # v3.1.1 |
| 101 | + with: |
| 102 | + activate-environment: codecarbon |
| 103 | + miniforge-version: latest |
| 104 | + python-version: 3.12 |
| 105 | + use-mamba: true |
| 106 | + - name: Restore build |
| 107 | + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 |
| 108 | + with: |
| 109 | + path: /tmp/conda-bld |
| 110 | + key: build-conda-${{ github.sha }} |
| 111 | + fail-on-cache-miss: true |
| 112 | + - name: Install package |
| 113 | + shell: bash -l {0} |
| 114 | + run: mamba install --channel file:///tmp/conda-bld --channel codecarbon codecarbon |
| 115 | + - name: Test conda package |
| 116 | + shell: bash -l {0} |
| 117 | + run: codecarbon --help |
0 commit comments