generated from openfisca/country-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 414d481
Showing
61 changed files
with
4,040 additions
and
0 deletions.
There are no files selected for viewing
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,30 @@ | ||
Hi there! | ||
|
||
I really enjoy OpenFisca, but I recently encountered an issue. | ||
|
||
### Here is what I did: | ||
|
||
|
||
### Here is what I expected to happen: | ||
|
||
|
||
### Here is what actually happened: | ||
|
||
|
||
### Here is data (or links to it) that can help you reproduce this issue: | ||
|
||
|
||
|
||
## Context | ||
|
||
I identify more as a: | ||
|
||
- Analyst _(I make macroscopic computations on real populations)_. | ||
- Business expert _(I create tests and model legislation)_. | ||
- Commenter _(I make data visualisations)_. | ||
- Developer _(I create tools that use the existing OpenFisca code)_. | ||
- Historian _(I accumulate data based on past legislation values)_. | ||
- Lobbyist _(I model reforms to make them exist)_. | ||
- Producer _(I make computations on individual situations)_. | ||
|
||
(remove this line as well as all items in the list that don't fit your situation) |
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,17 @@ | ||
Thanks for contributing to OpenFisca ! Please remove this line, as well as, for each line below, the cases which are not relevant to your contribution :) | ||
|
||
* Tax and benefit system evolution. | Technical improvement. | Crash fix. | Minor change. | ||
* Impacted periods: all. | until DD/MM/YYYY. | from DD/MM/YYYY. | ||
* Impacted areas: `path/to/file/containing/impacted/variables` | ||
* Details: | ||
- New feature or new behaviour description | ||
- Cases for which an error was noticed | ||
|
||
- - - - | ||
|
||
These changes _(remove lines which are not relevant to your contribution)_: | ||
|
||
- Impact the OpenFisca-Country-Template public API (for instance renaming or removing a variable) | ||
- Add a new feature (for instance adding a variable) | ||
- Fix or improve an already existing calculation. | ||
- Change non-functional parts of this repository (for instance editing the README) |
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,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 main 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 |
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,39 @@ | ||
#! /usr/bin/env bash | ||
|
||
if [[ ${GITHUB_REF#refs/heads/} == main ]] | ||
then | ||
echo "No need for a version check on main." | ||
exit 0 | ||
fi | ||
|
||
if ! $(dirname "$BASH_SOURCE")/has-functional-changes.sh | ||
then | ||
echo "No need for a version update." | ||
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 | ||
|
||
if [[ ! $current_version ]] | ||
then | ||
echo "Error getting current version" | ||
exit 1 | ||
fi | ||
|
||
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 pyproject.toml before merging this branch into main." | ||
echo "Look at the CONTRIBUTING.md file to learn how the version number should be updated." | ||
exit 2 | ||
fi | ||
|
||
if ! $(dirname "$BASH_SOURCE")/has-functional-changes.sh | grep --quiet CHANGELOG.md | ||
then | ||
echo "CHANGELOG.md has not been modified, while functional changes were made." | ||
echo "Explain what you changed before merging this branch into main." | ||
echo "Look at the CONTRIBUTING.md file to learn how to write the changelog." | ||
exit 2 | ||
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,5 @@ | ||
#! /usr/bin/env bash | ||
|
||
current_version=$(grep '^version =' pyproject.toml | cut -d '"' -f 2) # parsing with tomllib is complicated, see https://github.com/python-poetry/poetry/issues/273 | ||
git tag $current_version | ||
git push --tags # update the repository version |
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_country_template --port $PORT & | ||
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,34 @@ | ||
name: Build | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
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: | ||
path: ${{ env.pythonLocation }} | ||
key: build-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }} # Cache the entire build Python environment | ||
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 }} |
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,70 @@ | ||
name: Deploy | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
jobs: | ||
validate: | ||
uses: "./.github/workflows/validate.yml" | ||
|
||
# GitHub Actions does not have a halt job option to stop from deploying if no functional changes were found. | ||
# We thus execute a separate deployment job depending on the output of this job. | ||
check-for-functional-changes: | ||
runs-on: ubuntu-22.04 | ||
outputs: | ||
status: ${{ steps.stop-early.outputs.status }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Fetch all the tags | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.9.12 | ||
- id: stop-early | ||
run: | | ||
if "${GITHUB_WORKSPACE}/.github/has-functional-changes.sh" | ||
then | ||
echo "status=success" >> $GITHUB_OUTPUT | ||
fi | ||
check-pypi-token: # Use intermediary job as secrets cannot be directly referenced in `if:` conditionals; see https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions#using-secrets-in-a-workflow | ||
runs-on: ubuntu-22.04 | ||
outputs: | ||
pypi_token_present: ${{ steps.check_token.outputs.pypi_token_present }} | ||
steps: | ||
- name: Check PyPI token is defined | ||
id: check_token | ||
run: | | ||
if [[ -n "${{ secrets.PYPI_TOKEN }}" ]] | ||
then | ||
echo "pypi_token_present=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "pypi_token_present=false" >> $GITHUB_OUTPUT | ||
fi | ||
deploy: | ||
runs-on: ubuntu-22.04 | ||
needs: [ validate, check-for-functional-changes, check-pypi-token ] | ||
if: needs.check-for-functional-changes.outputs.status == 'success' && needs.check-pypi-token.outputs.pypi_token_present == 'true' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.9.12 | ||
- name: Restore build | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ env.pythonLocation }} | ||
key: build-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }} | ||
- name: Restore built package | ||
uses: actions/cache@v4 | ||
with: | ||
path: dist | ||
key: release-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }} | ||
- name: Upload a Python package to PyPi | ||
run: twine upload dist/* --username __token__ --password ${{ secrets.PYPI_TOKEN }} | ||
- name: Publish a git tag | ||
run: "${GITHUB_WORKSPACE}/.github/publish-git-tag.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: First time setup | ||
|
||
on: | ||
create: | ||
workflow_dispatch: | ||
|
||
permissions: | ||
actions: write | ||
checks: write | ||
contents: write | ||
|
||
jobs: | ||
first-time-setup: | ||
# Ensure this job does not run on the template repository or when the repository is forked | ||
if: ${{ !github.event.repository.is_template && !github.event.repository.fork }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Infer jurisdiction name from repository name | ||
run: | | ||
echo "TITLE_CASE_JURISDICTION_NAME=$(echo ${{ github.event.repository.name }} | sed 's/openfisca-//' | sed 's/[-|_]/ /g' | awk '{for (i=1; i<=NF; i++) $i=toupper(substr($i,1,1)) substr($i,2)} 1')" >> $GITHUB_ENV | ||
- name: Execute the first-time-setup script | ||
run: CI=true JURISDICTION_NAME="$TITLE_CASE_JURISDICTION_NAME" REPOSITORY_URL="${{ github.repositoryUrl }}" ./first-time-setup.sh | ||
|
||
- name: Commit changes | ||
uses: stefanzweifel/git-auto-commit-action@v5 | ||
with: | ||
commit_message: "Customise country-template through CI" | ||
tagging_message: "0.0.1" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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,101 @@ | ||
name: Validate | ||
|
||
on: | ||
pull_request: | ||
types: [ assigned, opened, reopened, synchronize, ready_for_review ] | ||
workflow_call: | ||
|
||
jobs: | ||
build: | ||
uses: "./.github/workflows/build.yml" | ||
|
||
lint-files: | ||
runs-on: ubuntu-22.04 | ||
needs: [ build ] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install Tox | ||
run: pipx install tox | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.9.12 | ||
|
||
- name: Lint files | ||
run: tox -r -e lint | ||
|
||
test-yaml: | ||
runs-on: ubuntu-22.04 | ||
needs: [ build ] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install Tox | ||
run: pipx install tox | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.9.12 | ||
|
||
- name: Test files | ||
run: tox -r -e py39 | ||
|
||
test-dist: | ||
runs-on: ubuntu-22.04 | ||
needs: [ build ] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.9.12 | ||
|
||
- name: Restore built package | ||
uses: actions/cache@v4 | ||
with: | ||
path: dist | ||
key: release-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }} | ||
|
||
- name: Test the built package | ||
run: | | ||
pip install twine | ||
twine check dist/* | ||
test-api: | ||
runs-on: ubuntu-22.04 | ||
needs: [ build ] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.9.12 | ||
|
||
- name: Restore build | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ env.pythonLocation }} | ||
key: build-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }} | ||
|
||
- name: Test the Web API | ||
run: "${GITHUB_WORKSPACE}/.github/test-api.sh" | ||
|
||
check-version-and-changelog: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Fetch all the tags | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.9.12 | ||
|
||
- name: Check version number has been properly updated | ||
run: "${GITHUB_WORKSPACE}/.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Python builds | ||
|
||
*.egg-info | ||
*.pyc | ||
build | ||
dist | ||
.venv | ||
|
||
# Editors | ||
|
||
.idea | ||
.project | ||
.pydevproject | ||
.python-version | ||
.settings | ||
.spyderproject | ||
.vscode | ||
|
||
# OS stuff | ||
|
||
.DS_Store | ||
*~ |
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,6 @@ | ||
--- | ||
|
||
extends: relaxed | ||
|
||
rules: | ||
line-length: disable |
Oops, something went wrong.