-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #132 from openfisca/github_actions
Migrate france action to tunisia
- Loading branch information
Showing
56 changed files
with
1,090 additions
and
568 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
############################################################################### | ||
## File for Anaconda.org | ||
## It use Jinja2 templating code to retreive information from setup.py | ||
############################################################################### | ||
|
||
{% set name = "OpenFisca-Tunisia" %} | ||
{% set data = load_setup_py_data() %} | ||
{% set version = data.get('version') %} | ||
|
||
package: | ||
name: {{ name|lower }} | ||
version: {{ version }} | ||
|
||
source: | ||
path: .. | ||
|
||
build: | ||
noarch: python | ||
number: 0 | ||
script: "{{ PYTHON }} -m pip install . -vv" | ||
|
||
requirements: | ||
host: | ||
- python | ||
- pip | ||
run: | ||
{% for req in data.get('install_requires', []) %} | ||
- {{ req }} | ||
{% endfor %} | ||
# - python >=3.9,<4.0 | ||
# - OpenFisca-Core >=40,<41 | ||
|
||
|
||
test: | ||
imports: | ||
- openfisca_tunisia | ||
requires: | ||
- pip | ||
commands: | ||
- pip check | ||
|
||
outputs: | ||
- name: openfisca-tunisia | ||
|
||
- name: openfisca-tunisia-dev | ||
build: | ||
noarch: python | ||
requirements: | ||
host: | ||
- python | ||
run: | ||
- python >=3.9,<4.0 | ||
{% for req in data.get('dev_requirements', []) %} | ||
- {{ req }} | ||
{% endfor %} | ||
- {{ pin_subpackage('openfisca-tunisia', exact=True) }} | ||
|
||
about: | ||
home: https://fr.openfisca.org/ | ||
license_family: AGPL | ||
license: AGPL-3.0-only | ||
license_file: LICENSE.AGPL.txt | ||
summary: "Tunisian tax and benefit system for OpenFisca" | ||
description: | | ||
OpenFisca is a versatile microsimulation free software. | ||
This repository contains the OpenFisca model of the Tunisia tax and benefit system. | ||
doc_url: https://fr.openfisca.org/ | ||
dev_url: https://github.com/openfisca/openfisca-tunisia/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Hello hello ! | ||
|
||
Je suis le fan numéro un d'OpenFisca, mais je viens de rencontrer un problème. | ||
|
||
### Qu'ai-je fait ? | ||
|
||
|
||
### À quoi m'attendais-je ? | ||
|
||
|
||
### Que s'est-il passé en réalité ? | ||
|
||
|
||
### Voici des informations qui peuvent aider à reproduire le problème : | ||
|
||
|
||
### Contexte | ||
|
||
Je m'identifie plus en tant que : | ||
|
||
- [ ] Contributeur·e : je contribue à OpenFisca Tunisia. | ||
- [ ] Développeur·e : je crée des outils qui utilisent OpenFisca Tunisia. | ||
- [ ] Économiste : je réalise des simulations avec des données. | ||
- [ ] Mainteneur·e : j'intègre les contributions à OpenFisca Tunisia. | ||
- [ ] Autre : _(ajoutez une description du contexte dans lequel vous utilisez OpenFisca)_. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Merci de contribuer à OpenFisca ! Effacez cette ligne ainsi que, pour chaque ligne ci-dessous, les cas ne correspondant pas à votre contribution :) | ||
|
||
* Évolution du système socio-fiscal. | Amélioration technique. | Correction d'un crash. | Changement mineur. | ||
* Périodes concernées : toutes. | jusqu'au JJ/MM/AAAA. | à partir du JJ/MM/AAAA. | ||
* Zones impactées : `chemin/vers/le/fichier/contenant/les/variables/impactées`. | ||
* Détails : | ||
- Description de la fonctionnalité ajoutée ou du nouveau comportement adopté. | ||
- Cas dans lesquels une erreur était constatée. | ||
|
||
- - - - | ||
|
||
Ces changements (effacez les lignes ne correspondant pas à votre cas) : | ||
|
||
- Modifient l'API publique d'OpenFisca Tunisia (par exemple renommage ou suppression de variables). | ||
- Ajoutent une fonctionnalité (par exemple ajout d'une variable). | ||
- Corrigent ou améliorent un calcul déjà existant. | ||
- Modifient des éléments non fonctionnels de ce dépôt (par exemple modification du README). | ||
|
||
- - - - | ||
|
||
Quelques conseils à prendre en compte : | ||
|
||
- [ ] Jetez un coup d'œil au [guide de contribution](https://github.com/openfisca/openfisca-tunisia/blob/master/CONTRIBUTING.md). | ||
- [ ] Regardez s'il n'y a pas une [proposition introduisant ces mêmes changements](https://github.com/openfisca/openfisca-tunisia/pulls). | ||
- [ ] Documentez votre contribution avec des références législatives. | ||
- [ ] Mettez à jour ou ajoutez des tests correspondant à votre contribution. | ||
- [ ] Augmentez le [numéro de version](https://speakerdeck.com/mattisg/git-session-2-strategies?slide=81) dans [`setup.py`](https://github.com/openfisca/openfisca-tunisia/blob/master/setup.py). | ||
- [ ] Mettez à jour le [`CHANGELOG.md`](https://github.com/openfisca/openfisca-tunisia/blob/master/CHANGELOG.md). | ||
- [ ] Assurez-vous de bien décrire votre contribution, comme indiqué ci-dessus | ||
|
||
Et surtout, n'hésitez pas à demander de l'aide ! :) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import re | ||
|
||
# This script fetches and prints the minimal versions of Openfisca-Core and Openfisca-Tunisia | ||
# dependencies in order to ensure their compatibility during CI testing | ||
with open('./setup.py') as file: | ||
for line in file: | ||
version = re.search(r'(Core|Tunisia)\s*>=\s*([\d\.]*)', line) | ||
if version: | ||
print(f'Openfisca-{version[1]}=={version[2]}') # noqa: T201 <- This is to avoid flake8 print detection. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import argparse | ||
import requests | ||
import logging | ||
|
||
|
||
logging.basicConfig(level=logging.INFO) | ||
|
||
|
||
def get_info(package_name: str = '') -> dict: | ||
''' | ||
Get minimal informations needed by .conda/meta.yaml from PyPi JSON API. | ||
::package_name:: Name of package to get infos from. | ||
::return:: A dict with last_version, url and sha256 | ||
''' | ||
if package_name == '': | ||
raise ValueError('Package name not provided.') | ||
resp = requests.get(f'https://pypi.org/pypi/{package_name}/json').json() | ||
version = resp['info']['version'] | ||
for v in resp['releases'][version]: | ||
if v['packagetype'] == 'sdist': # for .tag.gz | ||
return { | ||
'last_version': version, | ||
'url': v['url'], | ||
'sha256': v['digests']['sha256'] | ||
} | ||
|
||
|
||
def replace_in_file(filepath: str, info: dict): | ||
''' | ||
::filepath:: Path to meta.yaml, with filename | ||
::info:: Dict with information to populate | ||
''' | ||
with open(filepath, 'rt') as fin: | ||
meta = fin.read() | ||
# Replace with info from PyPi | ||
meta = meta.replace('PYPI_VERSION', info['last_version']) | ||
meta = meta.replace('PYPI_URL', info['url']) | ||
meta = meta.replace('PYPI_SHA256', info['sha256']) | ||
with open(filepath, 'wt') as fout: | ||
fout.write(meta) | ||
logging.info(f'File {filepath} has been updated with informations from PyPi.') | ||
|
||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('-p', '--package', type=str, default='', required=True, help='The name of the package') | ||
parser.add_argument('-f', '--filename', type=str, default='.conda/meta.yaml', help='Path to meta.yaml, with filename') | ||
args = parser.parse_args() | ||
info = get_info(args.package) | ||
logging.info(f'Information of the last published PyPi package : {info}') | ||
replace_in_file(args.filename, info) |
2 changes: 1 addition & 1 deletion
2
.circleci/has-functional-changes.sh → .github/has-functional-changes.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.circleci/is-version-number-acceptable.sh → .github/is-version-number-acceptable.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#! /usr/bin/env bash | ||
|
||
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 ! changes=$(git diff-index --name-only --diff-filter=ACMR --exit-code $last_tagged_commit -- "*.py") | ||
then | ||
echo "Linting the following Python files:" | ||
echo $changes | ||
flake8 $changes | ||
else echo "No changed Python files to lint" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#! /usr/bin/env bash | ||
|
||
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 ! changes=$(git diff-index --name-only --diff-filter=ACMR --exit-code $last_tagged_commit -- "tests/*.yaml") | ||
then | ||
echo "Linting the following changed YAML tests:" | ||
echo $changes | ||
yamllint $changes | ||
else echo "No changed YAML tests to lint" | ||
fi |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import sys | ||
from glob import glob | ||
|
||
|
||
def split_tests(number_of_files, CI_NODE_TOTAL, CI_NODE_INDEX, test_files_list): | ||
test_files_sublist = [] | ||
|
||
for file_index in range(number_of_files): | ||
file_number = file_index % CI_NODE_TOTAL | ||
if file_number == CI_NODE_INDEX: | ||
test_files_sublist.append(test_files_list[file_index]) | ||
|
||
tests_to_run_string = ' '.join(test_files_sublist) | ||
|
||
return tests_to_run_string | ||
|
||
|
||
if __name__ == '__main__': | ||
CI_NODE_TOTAL, CI_NODE_INDEX = int(sys.argv[1]), int(sys.argv[2]) | ||
test_files_list = glob('tests/**/*.yaml', recursive=True) + glob('tests/**/*.yml', recursive=True) | ||
number_of_files = len(test_files_list) | ||
sys.stdout.write(split_tests(number_of_files, CI_NODE_TOTAL, CI_NODE_INDEX, test_files_list)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#! /usr/bin/env bash | ||
|
||
PORT=5000 | ||
ENDPOINT=spec | ||
|
||
openfisca serve --country-package openfisca_tunisia --port $PORT --workers 1 & | ||
server_pid=$! | ||
|
||
curl --retry-connrefused --retry 10 --retry-delay 5 --fail http://127.0.0.1:$PORT/$ENDPOINT | python -m json.tool > /dev/null | ||
result=$? | ||
|
||
kill $server_pid | ||
|
||
exit $? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Validate YAML | ||
|
||
on: | ||
push: | ||
workflow_dispatch: | ||
pull_request: | ||
types: [opened, reopened] | ||
|
||
jobs: | ||
validate_yaml: | ||
uses: tax-benefit/actions/.github/workflows/validate_yaml.yml@v1 | ||
with: | ||
parameters_path: "openfisca_tunisia/parameters" | ||
secrets: | ||
token: ${{ secrets.CONTROL_CENTER_TOKEN }} |
Oops, something went wrong.