Skip to content

Commit

Permalink
Fix conda upload (#2374)
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit-cty authored Oct 31, 2024
2 parents c130e3d + 998e14c commit 0639cfa
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 72 deletions.
2 changes: 1 addition & 1 deletion .conda/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ source:
build:
noarch: python
number: 0
script: "pip install . -v"
script: "pip install ."

requirements:
host:
Expand Down
122 changes: 53 additions & 69 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,64 +44,53 @@ jobs:
key: release-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }}-${{ matrix.os }}-${{ matrix.openfisca-dependencies }}

build-conda:
runs-on: ubuntu-22.04
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache build
uses: actions/cache@v4
with:
path: /tmp/conda-bld
key: build-conda-${{ hashFiles('.conda/recipe.yaml') }}-${{ github.sha }}
restore-keys: |
build-conda-${{ hashFiles('.conda/recipe.yaml') }}
build-conda-
path: ${{ runner.temp }}\conda-bld
key: build-conda-${{ hashFiles('pyproject.toml') }}-${{ github.sha }}
- name: set version
run: |
python3 .github/pyproject_version.py --replace True
- name: Build conda package
uses: prefix-dev/[email protected]
with:
build-args: --channel openfisca --channel conda-forge --output-dir /tmp/conda-bld
build-args: --channel openfisca --channel conda-forge --output-dir ${{ runner.temp }}\conda-bld
recipe-path: .conda/recipe.yaml
upload-artifact: false
- name: Upload Conda build
uses: actions/upload-artifact@v4
with:
name: conda-build-${{ env.PACKAGE_VERSION }}-${{ github.sha }}
path: /tmp/conda-bld
retention-days: 30

test-conda:
runs-on: ubuntu-22.04
runs-on: windows-latest
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: openfisca
miniforge-version: latest
python-version: 3.9.12
use-mamba: true

- name: Restore build
uses: actions/cache@v4
with:
path: /tmp/conda-bld
key: build-conda-${{ hashFiles('.conda/recipe.yaml') }}-${{ github.sha }}

path: ${{ runner.temp }}\conda-bld
key: build-conda-${{ hashFiles('pyproject.toml') }}-${{ github.sha }}
fail-on-cache-miss: true
- name: Install package
# `bash -l {0}` démarre un login shell avec les variables d'environnement
# voir https://github.com/conda-incubator/setup-miniconda/issues/128
shell: bash -l {0}
run: mamba install --channel file:///tmp/conda-bld --channel openfisca openfisca-france

run: mamba install --channel file:///${RUNNER_TEMP//\\//}/conda-bld --channel openfisca openfisca-france
- name: Test conda package
shell: bash -l {0}
run: openfisca test tests/formulas/irpp.yaml



lint-files:
runs-on: ubuntu-20.04
strategy:
Expand Down Expand Up @@ -223,35 +212,32 @@ jobs:
run: "${GITHUB_WORKSPACE}/.github/test-api.sh"

test-on-windows:
runs-on: "windows-latest"
runs-on: windows-latest
if: github.ref == 'refs/heads/master' # Only triggered for the `master` branch
needs: [ build-conda ]
needs: [ test-conda ]
steps:
# Checkout needed to get github.sha
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: "3.9.9"
# Add conda-forge for OpenFisca-Core
channels: openfisca,conda-forge
activate-environment: true
- uses: actions/checkout@v4
activate-environment: openfisca
miniforge-version: latest
python-version: 3.10.6
use-mamba: true
- name: Restore build
uses: actions/cache@v4
with:
path: ${{ runner.temp }}\conda-bld
key: build-conda-${{ hashFiles('pyproject.toml') }}-${{ github.sha }}
fail-on-cache-miss: true
- name: Test max path length
run: "python3 openfisca_france/scripts/check_path_length.py"
- name: Get version
run: |
# chcp 65001 #set code page to utf-8
echo ("PACKAGE_VERSION=" + (python3 ./setup.py --version) ) >> $env:GITHUB_ENV
echo "Version setup.py: ${{ env.PACKAGE_VERSION }}"
- name: Download conda build
uses: actions/download-artifact@v3
with:
name: conda-build-${{ env.PACKAGE_VERSION }}-${{ github.sha }}
path: conda-build-tmp
- name: Install with conda
run: |
conda install -c ./conda-build-tmp/noarch/openfisca-france-dev-${{ env.PACKAGE_VERSION }}-py_0.tar.bz2 openfisca-france-dev
- name: openfisca test
run: openfisca test --country-package openfisca_france tests
- name: Install package
shell: bash -l {0}
run: mamba install --channel file:///${RUNNER_TEMP//\\//}/conda-bld --channel openfisca openfisca-france
- name: Test conda package
shell: bash -l {0}
run: openfisca test tests/formulas/irpp.yaml

check-version-and-changelog:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -323,32 +309,30 @@ jobs:
run: "${GITHUB_WORKSPACE}/.github/publish-git-tag.sh"

publish-to-conda:
runs-on: "ubuntu-20.04"
runs-on: windows-latest
needs: [ deploy, test-on-windows ]
steps:
- uses: conda-incubator/setup-miniconda@v3
- uses: actions/checkout@v4
- name: Restore build
uses: actions/cache@v4
with:
auto-update-conda: true
python-version: "3.9.9"
# Add conda-forge for OpenFisca-Core
channels: conda-forge
activate-environment: true
- name: Get source code
uses: actions/checkout@v4
- name: Get version
run: echo "PACKAGE_VERSION=$(python3 ./pyproject.toml --version)" >> $GITHUB_ENV
# Get the last commit hash on the PR (-2 : before the merge commit)
- uses: actions/github-script@v6
id: last_pr_commit
path: ${{ runner.temp }}\conda-bld
key: build-conda-${{ hashFiles('pyproject.toml') }}-${{ github.sha }}
fail-on-cache-miss: true
- uses: conda-incubator/setup-miniconda@v3
with:
script: |
const commits = ${{ toJSON(github.event.commits) }}
return commits.at(-2).id;
result-encoding: string
- name: Conda build and upload
# This shell is made necessary by https://github.com/conda-incubator/setup-miniconda/issues/128
activate-environment: openfisca
miniforge-version: latest
python-version: 3.10.6
use-mamba: true
- name: Install package
shell: bash -l {0}
run: mamba install --channel file:///${RUNNER_TEMP//\\//}/conda-bld --channel openfisca openfisca-france
- name: Test conda package
shell: bash -l {0}
run: openfisca test tests/formulas/irpp.yaml
- name: Conda upload already built package
shell: bash -l {0}
run: |
conda install --yes conda-build anaconda-client
conda config --set anaconda_upload yes
conda build --channel conda-forge --channel openfisca --token ${{ secrets.ANACONDA_TOKEN }} --user openfisca .conda
conda install --yes anaconda-client
anaconda -t ${{ secrets.ANACONDA_TOKEN }} upload --user openfisca ${{ runner.temp }}\conda-bld\noarch\openfisca-france-*
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

### 169.3.1 [2374](https://github.com/openfisca/openfisca-france/pull/2374)

* Correction d'un crash.
* Périodes concernées : aucune.
* Zones impactées : `workflow.yml`.
* Détails :
- La publication conda ne fonctionnait plus suite au passage à `pyproject.toml` : `C:\hostedtoolcache\windows\Python\3.9.13\x64\python3.exe: can't open file 'D:\a\openfisca-france\openfisca-france\setup.py': [Errno 2] No such file or directory`
- Met en place la pipeline conda faite dans Openfisca/country-template

### 169.3.0 [2376](https://github.com/openfisca/openfisca-france/pull/2376)

* Évolution du système socio-fiscal
Expand Down
3 changes: 2 additions & 1 deletion openfisca_france/scripts/check_path_length.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
FR: Ce script sert à estimer la longueur des chemins d'arborescence des paramètres,
afin de ne pas avoir de chemins > 150 caractères (incompatible Windows).
Il est à utiliser avant de contribuer à l'harmonisation
Il est à utiliser avant de contribuer à l'harmonisation.
⚠️ Il est également utilisé par la CI, dans l'étape de test sur Windows.
'''


Expand Down
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-France"
version = "169.3.0"
version = "169.3.1"
description = "OpenFisca Rules as Code model for France."
readme = "README.md"
keywords = ["microsimulation", "tax", "benefit", "rac", "rules-as-code", "france"]
Expand Down

0 comments on commit 0639cfa

Please sign in to comment.