Skip to content

Merge pull request #824 from IamLRBA/codecarbon2 #1894

Merge pull request #824 from IamLRBA/codecarbon2

Merge pull request #824 from IamLRBA/codecarbon2 #1894

Workflow file for this run

name: package
on:
push:
paths:
- "codecarbon/**"
- "pyproject.toml"
branches: [master]
jobs:
build-package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Check versions
run: |
pip install -U pip requests
python3 .github/check_version.py -o
- name: Build pip package
run: |
pip install -U pip build
python3 -m build
- name: Archive Pypi artifacts
uses: actions/upload-artifact@v4
with:
name: pypi_dist
path: dist
python-test:
runs-on: ubuntu-24.04
strategy:
matrix:
python-version: ["3.9", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install hatch==1.13.0 hatchling==1.25.0
- name: Test package
run: |
hatch run +py=${{ matrix.python-version }} test:package
build-conda:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache build
uses: actions/cache@v4
with:
path: /tmp/conda-bld
key: build-conda-${{ github.sha }}
- name: set version
run: |
python3 .github/pyproject_versions.py --replace True
- name: Build conda package
uses: prefix-dev/rattler-build-action@v0.2.16
with:
build-args: --channel codecarbon --channel conda-forge --output-dir /tmp/conda-bld
recipe-path: .conda/recipe.yaml
upload-artifact: false
test-conda:
runs-on: ubuntu-24.04
needs: [ build-conda ]
steps:
# Checkout needed to get github.sha
- uses: actions/checkout@v4
- name: Setup conda
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: codecarbon
miniforge-version: latest
python-version: 3.12
use-mamba: true
- name: Restore build
uses: actions/cache@v4
with:
path: /tmp/conda-bld
key: build-conda-${{ github.sha }}
fail-on-cache-miss: true
- name: Install package
shell: bash -l {0}
run: mamba install --channel file:///tmp/conda-bld --channel codecarbon codecarbon
- name: Test conda package
shell: bash -l {0}
run: codecarbon --help