Skip to content

Commit

Permalink
Merge pull request #150 from openfisca/msa_release_gaston
Browse files Browse the repository at this point in the history
Réintégration de la version 4.0.2 dans la branche MSA
  • Loading branch information
JoDuGa authored Aug 16, 2023
2 parents ea6a99c + 1821e01 commit ba4853e
Show file tree
Hide file tree
Showing 12 changed files with 237 additions and 52 deletions.
28 changes: 0 additions & 28 deletions .circleci/config.yml

This file was deleted.

8 changes: 8 additions & 0 deletions .github/get_minimal_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import re


with open('./setup.py') as file:
for line in file:
version = re.search(r'(Core|France)\s*>=\s*([\d\.]*)', line)
if version:
print(f'Openfisca-{version[1]}=={version[2]}')
12 changes: 12 additions & 0 deletions .github/has-functional-changes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! /usr/bin/env bash

IGNORE_DIFF_ON="README.md CONTRIBUTING.md Makefile .gitignore .github/*"

last_tagged_commit=`git describe --tags --abbrev=0 --first-parent` # --first-parent ensures we don't follow tags not published in master through an unlikely intermediary merge commit

if git diff-index --name-only --exit-code $last_tagged_commit -- . `echo " $IGNORE_DIFF_ON" | sed 's/ / :(exclude)/g'` # Check if any file that has not be listed in IGNORE_DIFF_ON has changed since the last tag was published.
then
echo "No functional changes detected."
exit 1
else echo "The functional files above were changed."
fi
25 changes: 25 additions & 0 deletions .github/is-version-number-acceptable.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#! /usr/bin/env bash

if [[ ${GITHUB_REF#refs/heads/} == master ]]
then
echo "No need for a version check on master."
exit 0
fi

if ! $(dirname "$BASH_SOURCE")/has-functional-changes.sh
then
echo "No need for a version update."
exit 0
fi

current_version=`python setup.py --version`

if git rev-parse --verify --quiet $current_version
then
echo "Version $current_version already exists in commit:"
git --no-pager log -1 $current_version
echo
echo "Update the version number in setup.py before merging this branch into master."
echo "Look at the CONTRIBUTING.md file to learn how the version number should be updated."
exit 1
fi
4 changes: 4 additions & 0 deletions .github/publish-git-tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#! /usr/bin/env bash

git tag `python setup.py --version`
git push --tags # update the repository version
136 changes: 136 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
name: OpenFisca Paris

on:
push:
branches:
- master
pull_request:

jobs:
build:
runs-on: ubuntu-20.04
strategy:
matrix:
openfisca-dependencies: [minimal, maximal]
python-version: ["3.9.9", "3.10.6"]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache build
id: restore-build
uses: actions/cache@v3
with:
path: ${{ env.pythonLocation }}
key: build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }}-${{ matrix.openfisca-dependencies }}
restore-keys: | # in case of a cache miss (systematically unless the same commit is built repeatedly), the keys below will be used to restore dependencies from previous builds, and the cache will be stored at the end of the job, making up-to-date dependencies available for all jobs of the workflow; see more at https://docs.github.com/en/actions/advanced-guides/caching-dependencies-to-speed-up-workflows#example-using-the-cache-action
build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}
build-${{ env.pythonLocation }}-
- name: Install test dependancies
run: make install-test
- name: Build package
run: make build
- name: Minimal version
if: matrix.openfisca-dependencies == 'minimal'
run: | # Installs the OpenFisca dependencies minimal version from setup.py
pip install $(python ${GITHUB_WORKSPACE}/.github/get_minimal_version.py)
- name: Cache release
id: restore-release
uses: actions/cache@v3
with:
path: dist
key: release-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }}-${{ matrix.openfisca-dependencies }}
test-yaml:
runs-on: ubuntu-20.04
strategy:
matrix:
openfisca-dependencies: [minimal, maximal]
needs: [ build ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9.9
- name: Cache build
id: restore-build
uses: actions/cache@v3
with:
path: ${{ env.pythonLocation }}
key: build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }}-${{ matrix.openfisca-dependencies }}
- name: Run YAML test
run: |
openfisca test tests --country-package openfisca_france --extensions openfisca_paris
check-version:
runs-on: ubuntu-20.04
needs: [ test-yaml ] # Last job to run
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all the tags
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9.9
- name: Check version number has been properly updated
run: "${GITHUB_WORKSPACE}/.github/is-version-number-acceptable.sh"

# GitHub Actions does not have a halt job option, to stop from deploying if no functional changes were found.
# We build a separate job to substitute the halt option.
# The `deploy` job is dependent on the output of the `check-for-functional-changes` job.
check-for-functional-changes:
runs-on: ubuntu-20.04
if: github.ref == 'refs/heads/master' # Only triggered for the `master` branch
needs: [ check-version ]
outputs:
status: ${{ steps.stop-early.outputs.status }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all the tags
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9.9
- id: stop-early
run: if "${GITHUB_WORKSPACE}/.github/has-functional-changes.sh" ; then echo "::set-output name=status::success" ; fi

deploy:
runs-on: ubuntu-20.04
strategy:
matrix:
openfisca-dependencies: [maximal]
needs: [ check-for-functional-changes ]
if: needs.check-for-functional-changes.outputs.status == 'success'
env:
PYPI_USERNAME: openfisca-bot
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all the tags
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9.9
- name: Cache build
id: restore-build
uses: actions/cache@v3
with:
path: ${{ env.pythonLocation }}
key: build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }}-${{ matrix.openfisca-dependencies }}
- name: Cache release
id: restore-release
uses: actions/cache@v3
with:
path: dist
key: release-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }}-${{ matrix.openfisca-dependencies }}
- name: Upload a Python package to PyPi
run: twine upload dist/* --username $PYPI_USERNAME --password $PYPI_PASSWORD
- name: Publish a git tag
run: "${GITHUB_WORKSPACE}/.github/publish-git-tag.sh"
25 changes: 22 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,25 @@ clean:
rm -rf build dist
find . -name '*.pyc' -exec rm \{\} \;

install:
pip install --upgrade pip wheel
pip install --editable .[test] --upgrade
deps:
pip install --upgrade pip build twine

install-test:
pip install --editable ".[test]"

install: deps
@# Install OpenFisca-Paris for development.
@# `make install` installs the editable version of OpenFisca-Paris.
@# This allows contributors to test as they code.
pip install --editable . --upgrade

build: clean deps
@# Install OpenFisca-Paris for deployment and publishing.
@# `make build` allows us to be be sure tests are run against the packaged version
@# of OpenFisca-Paris, the same we put in the hands of users and reusers.
python -m build
pip uninstall --yes openfisca-paris
find dist -name "*.whl" -exec pip install {} \;

test:
openfisca test tests --country-package openfisca_france --extension openfisca_paris
4 changes: 2 additions & 2 deletions openfisca_paris/personnes_agees/paris_logement.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class paris_logement_pa_plafond(Variable):
reference = "article II.2.1.b/2 du règlement municipal du CASVP"

def formula(famille, period, parameters):
salaire_minimum = parameters(period).marche_travail.salaire_minimum
smic_brut_mensuel = salaire_minimum.smic_h_b * salaire_minimum.nb_heure_travail_mensuel
salaire_minimum = parameters(period).marche_travail.salaire_minimum.smic
smic_brut_mensuel = salaire_minimum.smic_b_horaire * salaire_minimum.nb_heures_travail_mensuel

# Utilisation des valeurs indicatives de service-public.fr pour passer du SMIC brut au SMIC net
# https://www.service-public.fr/particuliers/vosdroits/F2300
Expand Down
5 changes: 3 additions & 2 deletions openfisca_paris/personnes_agees/personnes_agees.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def formula(famille, period, parameters):
personne_agee = famille.members('paris_personne_agee', period)
personnes_agees_famille = famille.any(personne_agee)
en_couple = famille('en_couple', period)
aspa = parameters(period).prestations.minima_sociaux.aspa
aspa_montant_maximum_annuel = parameters(period).prestations_sociales.solidarite_insertion.minimum_vieillesse.aspa.montant_maximum_annuel


return personnes_agees_famille * (en_couple * aspa.montant_annuel_couple + not_(en_couple) * aspa.montant_annuel_seul) / 12
return personnes_agees_famille * (en_couple * aspa_montant_maximum_annuel.couples + not_(en_couple) * aspa_montant_maximum_annuel.personnes_seules) / 12
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def formula(individu, period, parameters):
param_plafond = parameters(period).paris.personnes_handicapees.paris_complement_sante.plafond
plafond_1 = param_plafond.personne_isolee

param_aah = parameters(period).prestations.minima_sociaux
param_aah = parameters(period).prestations_sociales.prestations_etat_de_sante.invalidite
plafond_2 = param_aah.aah.montant + param_aah.caah.majoration_vie_autonome

return personne_handicapee * (base_ressources <= max_(plafond_1, plafond_2))
Expand Down
6 changes: 3 additions & 3 deletions openfisca_paris/personnes_handicapees/psol.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ def formula(famille, period, parameters):

base_ressource = famille('paris_base_ressources_couple', period)

aspa = parameters(period).prestations.minima_sociaux.aspa
aah = parameters(period).prestations.minima_sociaux.aah
aspa_montant_maximum_annuel = parameters(period).prestations_sociales.solidarite_insertion.minimum_vieillesse.aspa.montant_maximum_annuel
aah = parameters(period).prestations_sociales.prestations_etat_de_sante.invalidite.aah
en_couple = famille('en_couple', period)
# ASPA est utilisé comme seuil de ressources pour
# les couples avec personne en situation de handicap
# faute d'AAH pour couple
montant_psol_handicap = ((en_couple * aspa.montant_annuel_couple) / 12 + not_(en_couple) * aah.montant)
montant_psol_handicap = ((en_couple * aspa_montant_maximum_annuel.couples) / 12 + not_(en_couple) * aah.montant)

return max_(montant_psol_handicap, base_ressource)

Expand Down
34 changes: 21 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages
from setuptools import setup, find_namespace_packages

setup(
name="Openfisca-Paris",
version="2.4.1",
version="4.0.2",
author="OpenFisca Team",
author_email="[email protected]",
classifiers=[
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: GNU Affero General Public License v3",
"Operating System :: POSIX",
"Programming Language :: Python",
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
"Topic :: Scientific/Engineering :: Information Analysis",
],
description="Plugin OpenFisca pour les aides sociales de la mairie de Paris",
keywords="benefit france paris microsimulation social tax",
license="http://www.fsf.org/licensing/licenses/agpl-3.0.html",
author="Mairie de Paris, Incubateur de Services Numériques (SGMAP)",
packages=find_packages(),

packages=find_namespace_packages(),
include_package_data=True,
install_requires=[
'OpenFisca-Core >= 35.2.0, < 36',
'OpenFisca-France >= 61, < 81'
'OpenFisca-Core >= 40.0.1, <= 41.0.0',
'OpenFisca-France >= 149.1.1, < 150',
],
extras_require = {
extras_require={
'test': [
'nose',
'pytest >= 5.4.2'
]
]
},
classifiers=[
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.7",
]
)

0 comments on commit ba4853e

Please sign in to comment.