Skip to content

Commit

Permalink
ci: build conda pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
bonjourmauko committed Oct 15, 2024
1 parent 17f94ad commit aa80b17
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 11 deletions.
42 changes: 42 additions & 0 deletions .conda/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
schema_version: 1

context:
name: openfisca-country-template
version: 8.0.0

package:
name: ${{ name|lower }}
version: ${{ version }}

source:
path: ..

build:
number: 0
noarch: python
script: pip install . -v

requirements:
host:
- numpy
- pip
- python
- setuptools >=61.0
run:
- numpy
- python
- openfisca-core-api >=43

tests:
- python:
imports:
- openfisca_country_template

about:
summary: OpenFisca Rules as Code model for Country-Template.
license: AGPL-3.0
license_file: LICENSE

extra:
recipe-maintainers:
- bonjourmauko
9 changes: 9 additions & 0 deletions .conda/variants.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
numpy:
- "1.24"
- "1.25"
- "1.26"

python:
- "3.9"
- "3.10"
- "3.11"
21 changes: 16 additions & 5 deletions .github/is-version-number-acceptable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,29 @@ then
exit 0
fi

current_version=$(grep '^version =' pyproject.toml | cut -d '"' -f 2) # parsing with tomllib is complicated, see https://github.com/python-poetry/poetry/issues/273
# parsing with tomllib is complicated, see
# https://github.com/python-poetry/poetry/issues/273
python_version=$(grep '^version =' pyproject.toml | cut -d '"' -f 2)

if [[ ! $current_version ]]
# we do the same for conda
conda_version=$(grep '^ version: \d' .conda/recipe.yaml | cut -d ' ' -f 4)

if [[ ! $python_version || ! $conda_version ]]
then
echo "Error getting current version"
exit 1
fi

if git rev-parse --verify --quiet $current_version
if [[ "$python_version" != "$conda_version" ]]
then
echo "Python ($python_version) and Conda ($conda_version) versions do not match"
exit 1
fi

if git rev-parse --verify --quiet "$python_version"
then
echo "Version $current_version already exists in commit:"
git --no-pager log -1 $current_version
echo "Version $python_version already exists in commit:"
git --no-pager log -1 "$python_version"
echo
echo "Update the version number in pyproject.toml before merging this branch into main."
echo "Look at the CONTRIBUTING.md file to learn how the version number should be updated."
Expand Down
23 changes: 18 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ on:
workflow_call:

jobs:
build-and-cache:
python-build-and-cache:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9.12 # Patch version must be specified to avoid any cache confusion, since the cache key depends on the full Python version. Any difference in patches between jobs will lead to a cache not found error.

- name: Cache build
uses: actions/cache@v4
with:
Expand All @@ -23,12 +23,25 @@ jobs:
restore-keys: |
build-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}
build-${{ env.pythonLocation }}-
- name: Build package
run: make build

- name: Cache release
uses: actions/cache@v4
with:
path: dist
key: release-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }}

conda-build-and-upload:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Build conda package
uses: prefix-dev/rattler-build-action@v0.2.16
with:
build-args: --channel openfisca --channel conda-forge
recipe-path: .conda/recipe.yaml
upload-artifact: true
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "openfisca-country_template"
version = "7.1.6"
version = "8.0.0"
dependencies = [
"openfisca-core[web-api] >= 43",
]
Expand Down

0 comments on commit aa80b17

Please sign in to comment.