Skip to content

Corrections lint, refacto calcul seuils revenus #8639

Corrections lint, refacto calcul seuils revenus

Corrections lint, refacto calcul seuils revenus #8639

Workflow file for this run

name: OpenFisca France
on:
push:
pull_request:
types: [opened, reopened]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: ["ubuntu-20.04"] # On peut ajouter "macos-latest" si besoin
python-version: ["3.9.9", "3.10.6"]
openfisca-dependencies: [minimal, maximal]
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.os }}-${{ 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') }}-${{ matrix.os }}
build-${{ env.pythonLocation }}-${{ matrix.os }}
- 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.os }}-${{ matrix.openfisca-dependencies }}
lint-files:
runs-on: ubuntu-20.04
strategy:
matrix:
dependencies-version: [maximal]
needs: [ build ]
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 }}-ubuntu-20.04-${{ matrix.dependencies-version }}
- run: make check-syntax-errors
- run: make check-style
- name: Lint Python files
run: "${GITHUB_WORKSPACE}/.github/lint-changed-python-files.sh"
- name: Lint YAML tests
run: "${GITHUB_WORKSPACE}/.github/lint-changed-yaml-tests.sh"
test-python:
runs-on: ${{ matrix.os }}
needs: [ build ]
strategy:
fail-fast: true
matrix:
os: [ "ubuntu-20.04" ] # On peut ajouter "macos-latest" si besoin
python-version: ["3.9.9", "3.10.6"]
openfisca-dependencies: [minimal, maximal]
steps:
- 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.os }}-${{ matrix.openfisca-dependencies }}
- run: |
shopt -s globstar
openfisca test tests/**/*.py
if: matrix.openfisca-dependencies != 'minimal' || matrix.python-version != '3.9.9'
test-path-length:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9.9
- name: Test max path length
run: make check-path-length
test-yaml:
runs-on: ubuntu-20.04
needs: [ build ]
strategy:
fail-fast: false
matrix:
# Set N number of parallel jobs to run tests on. Here we use 10 jobs
# Remember to update ci_node_index below to 0..N-1
ci_node_total: [ 10 ]
ci_node_index: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
openfisca-dependencies: [minimal, maximal]
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 }}-ubuntu-20.04-${{ matrix.openfisca-dependencies }}
- name: Split YAML tests
id: yaml-test
env:
CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
CI_NODE_INDEX: ${{ matrix.ci_node_index }}
run: |
echo "TEST_FILES_SUBLIST=$(python "${GITHUB_WORKSPACE}/.github/split_tests.py" ${CI_NODE_TOTAL} ${CI_NODE_INDEX})" >> $GITHUB_ENV
- name: Run YAML test
run: |
openfisca test ${TEST_FILES_SUBLIST}
test-api:
runs-on: ubuntu-20.04
strategy:
matrix:
dependencies-version: [maximal]
needs: [ build ]
steps:
- 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 }}-ubuntu-20.04-${{ matrix.dependencies-version }}
- name: Test the Web API
run: "${GITHUB_WORKSPACE}/.github/test-api.sh"
check-version-and-changelog:
runs-on: ubuntu-20.04
needs: [ lint-files, test-python, test-yaml, test-api ] # 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-and-changelog ]
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:
dependencies-version: [maximal]
needs: [ check-for-functional-changes ]
if: needs.check-for-functional-changes.outputs.status == 'success'
env:
PYPI_USERNAME: __token__
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
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 }}-ubuntu-20.04-${{ matrix.dependencies-version }}
- name: Cache release
id: restore-release
uses: actions/cache@v3
with:
path: dist
key: release-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }}-ubuntu-20.04-${{ matrix.dependencies-version }}
- name: Upload a Python package to PyPi
run: twine upload dist/* --username $PYPI_USERNAME --password $PYPI_TOKEN
- name: Publish a git tag
run: "${GITHUB_WORKSPACE}/.github/publish-git-tag.sh"
build-conda:
runs-on: "ubuntu-20.04"
needs: [ check-version-and-changelog ]
# Do not build on master, the artifact will be used
if: github.ref != 'refs/heads/master'
steps:
- uses: conda-incubator/setup-miniconda@v2
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@v3
- name: Update meta.yaml
run: |
python3 -m pip install requests argparse
# Sleep to allow PyPi to update its API
sleep 60
python3 .github/get_pypi_info.py -p OpenFisca-France
- name: Get version
run: echo "PACKAGE_VERSION=$(python3 ./setup.py --version)" >> $GITHUB_ENV
- name: Conda Config
run: |
conda install conda-build anaconda-client
conda info
- name: Build Conda package
run: conda build -c openfisca -c conda-forge --croot /tmp/conda .conda
- name: Upload Conda build
uses: actions/upload-artifact@v3
with:
name: conda-build-${{ env.PACKAGE_VERSION }}-${{ github.sha }}
path: /tmp/conda
retention-days: 30
test-on-windows:
runs-on: "windows-latest"
needs: [ build-conda ]
steps:
- uses: conda-incubator/setup-miniconda@v2
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@v3
- 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
publish-to-conda:
runs-on: "ubuntu-20.04"
needs: [ deploy ]
steps:
- uses: conda-incubator/setup-miniconda@v2
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@v3
- name: Get version
run: echo "PACKAGE_VERSION=$(python3 ./setup.py --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
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
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