Skip to content

Commit

Permalink
ci: add matrix & fix conda (#1257)
Browse files Browse the repository at this point in the history
  • Loading branch information
bonjourmauko authored Oct 4, 2024
2 parents 0c3544a + 7fddb18 commit bbf342f
Show file tree
Hide file tree
Showing 25 changed files with 578 additions and 196 deletions.
9 changes: 9 additions & 0 deletions .conda/openfisca-core/conda_build_config.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
46 changes: 17 additions & 29 deletions .conda/meta.yaml → .conda/openfisca-core/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ package:
version: {{ version }}

source:
path: ..
path: ../..

build:
noarch: python
Expand All @@ -24,34 +24,23 @@ build:

requirements:
host:
- python
- numpy
- pip
- python
- setuptools >=61.0
run:
{% for req in data.get('install_requires', []) %}
- numpy
- python
{% for req in data['install_requires'] %}
{% if not req.startswith('numpy') %}
- {{ req }}
{% endif %}
{% endfor %}
# - PyYAML >=6.0,<7.0
# - dpath >=2.1.4,<3.0.0
# - importlib-metadata >=6.1.0,<7.0
# - numexpr >=2.8.4,<=3.0
# - numpy >=1.24.2,<1.25.0
# - pendulum >=2.1.2,<3.0.0
# - psutil >=5.9.4,<6.0.0
# - pytest >=7.2.2,<8.0.0
# - python >=3.9,<4.0
# - sortedcontainers >=2.4.0
# - typing-extensions >=4.5.0,<5.0

test:
imports:
- openfisca_core
- openfisca_core.commons
requires:
- pip
commands:
- pip check
- openfisca --help
- openfisca-run-test --help

outputs:
- name: openfisca-core
Expand All @@ -61,28 +50,27 @@ outputs:
noarch: python
requirements:
host:
- numpy
- python
run:
- python >=3.9,<4.0
{% for req in data.get('api_requirements', []) %}
- numpy
- python
{% for req in data['extras_require']['web-api'] %}
- {{ req }}
{% endfor %}
#
# - flask >=2.2.3,<3.0
# - flask-cors >=3.0.10,<4.0
# - gunicorn >=20.1.0,<21.0.0
# - werkzeug >=2.2.3,<3.0.0
- {{ pin_subpackage('openfisca-core', exact=True) }}

- name: openfisca-core-dev
build:
noarch: python
requirements:
host:
- numpy
- python
run:
- python >=3.9,<4.0
{% for req in data.get('dev_requirements', []) %}
- numpy
- python
{% for req in data['extras_require']['dev'] %}
- {{ req }}
{% endfor %}
- {{ pin_subpackage('openfisca-core-api', exact=True) }}
Expand Down
42 changes: 42 additions & 0 deletions .conda/openfisca-country-template/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: 7.1.5

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

source:
url: https://pypi.org/packages/source/${{ name[0] }}/${{ name }}/openfisca_country_template-${{ version }}.tar.gz
sha256: b2f2ac9945d9ccad467aed0925bd82f7f4d5ce4e96b212324cd071b8bee46914

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

requirements:
host:
- numpy
- pip
- python
- setuptools >=61.0
run:
- numpy
- python
- openfisca-core >=42,<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
7 changes: 7 additions & 0 deletions .conda/openfisca-country-template/variants.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
numpy:
- "1.26"

python:
- "3.9"
- "3.10"
- "3.11"
43 changes: 43 additions & 0 deletions .conda/openfisca-extension-template/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
schema_version: 1

context:
name: openfisca-extension-template
version: 1.3.15

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

source:
url: https://pypi.org/packages/source/${{ name[0] }}/${{ name }}/openfisca_extension_template-${{ version }}.tar.gz
sha256: e16ee9cbefdd5e9ddc1c2c0e12bcd74307c8cb1be55353b3b2788d64a90a5df9

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

requirements:
host:
- numpy
- pip
- python
- setuptools >=61.0
run:
- numpy
- python
- openfisca-country-template >=7,<8

tests:
- python:
imports:
- openfisca_extension_template

about:
summary: An OpenFisca extension that adds some variables to an already-existing
tax and benefit system.
license: AGPL-3.0
license_file: LICENSE

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

python:
- "3.9"
- "3.10"
- "3.11"
41 changes: 41 additions & 0 deletions .conda/pylint-per-file-ignores/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
schema_version: 1

context:
name: pylint-per-file-ignores
version: 1.3.2

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

source:
url: https://pypi.org/packages/source/${{ name[0] }}/${{ name }}/pylint_per_file_ignores-${{ version }}.tar.gz
sha256: 3c641f69c316770749a8a353556504dae7469541cdaef38e195fe2228841451e

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

requirements:
host:
- python
- poetry-core >=1.0.0
- pip
run:
- pylint >=3.3.1,<4.0
- python
- tomli >=2.0.1,<3.0.0

tests:
- python:
imports:
- pylint_per_file_ignores

about:
summary: A pylint plugin to ignore error codes per file.
license: MIT
homepage: https://github.com/christopherpickering/pylint-per-file-ignores.git

extra:
recipe-maintainers:
- bonjourmauko
4 changes: 4 additions & 0 deletions .conda/pylint-per-file-ignores/variants.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
python:
- "3.9"
- "3.10"
- "3.11"
2 changes: 1 addition & 1 deletion .github/get_pypi_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def replace_in_file(filepath: str, info: dict) -> None:
"-f",
"--filename",
type=str,
default=".conda/meta.yaml",
default=".conda/openfisca-core/meta.yaml",
help="Path to meta.yaml, with filename",
)
args = parser.parse_args()
Expand Down
109 changes: 109 additions & 0 deletions .github/workflows/_before-conda.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Setup conda

on:
workflow_call:
inputs:
os:
required: true
type: string

numpy:
required: true
type: string

python:
required: true
type: string

defaults:
run:
shell: bash -l {0}

jobs:
setup:
runs-on: ${{ inputs.os }}
name: conda-setup-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python }}
env:
# To colorize output of make tasks.
TERM: xterm-256color

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Cache conda env
uses: actions/cache@v4
with:
path: |
/usr/share/miniconda/envs/openfisca
~/.conda/envs/openfisca
.env.yaml
key: conda-env-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python }}-${{ hashFiles('setup.py') }}
restore-keys: conda-env-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python }}-
id: cache-env

- name: Cache conda deps
uses: actions/cache@v4
with:
path: ~/conda_pkgs_dir
key: conda-deps-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python }}-${{ hashFiles('setup.py') }}
restore-keys: conda-deps-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python }}-
id: cache-deps

- name: Cache release
uses: actions/cache@v4
with:
path: ~/conda-rel
key: conda-release-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python }}-${{ hashFiles('setup.py') }}-${{ github.sha }}

- name: Setup conda
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: openfisca
miniforge-version: latest
python-version: ${{ inputs.python }}
use-mamba: true
if: steps.cache-env.outputs.cache-hit != 'true'

- name: Install dependencies
run: mamba install boa rattler-build anaconda-client
if: steps.cache-env.outputs.cache-hit != 'true'

- name: Update conda & dependencies
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: openfisca
environment-file: .env.yaml
miniforge-version: latest
use-mamba: true
if: steps.cache-env.outputs.cache-hit == 'true'

- name: Build pylint plugin package
run: |
rattler-build build \
--recipe .conda/pylint-per-file-ignores \
--output-dir ~/conda-rel
- name: Build core package
run: |
conda mambabuild .conda/openfisca-core \
--use-local \
--no-anaconda-upload \
--output-folder ~/conda-rel \
--numpy ${{ inputs.numpy }} \
--python ${{ inputs.python }}
- name: Build country template package
run: |
rattler-build build \
--recipe .conda/openfisca-country-template \
--output-dir ~/conda-rel \
- name: Build extension template package
run: |
rattler-build build \
--recipe .conda/openfisca-extension-template \
--output-dir ~/conda-rel
- name: Export env
run: mamba env export --name openfisca > .env.yaml
Loading

0 comments on commit bbf342f

Please sign in to comment.