From 14fbb3d57e198c4012f2e3959e0346d740f33569 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Thu, 2 Sep 2021 09:55:09 +0200 Subject: [PATCH 01/42] Add Github Actions config --- .github/has-functional-changes.sh | 12 ++ .github/is-version-number-acceptable.sh | 33 ++++++ .github/publish-git-tag.sh | 4 + .github/test-api.sh | 14 +++ .github/workflows/workflow.yml | 151 ++++++++++++++++++++++++ 5 files changed, 214 insertions(+) create mode 100755 .github/has-functional-changes.sh create mode 100755 .github/is-version-number-acceptable.sh create mode 100755 .github/publish-git-tag.sh create mode 100755 .github/test-api.sh create mode 100644 .github/workflows/workflow.yml diff --git a/.github/has-functional-changes.sh b/.github/has-functional-changes.sh new file mode 100755 index 00000000..b787de99 --- /dev/null +++ b/.github/has-functional-changes.sh @@ -0,0 +1,12 @@ +#! /usr/bin/env bash + +IGNORE_DIFF_ON="README.md CONTRIBUTING.md Makefile .gitignore .circleci/* .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 diff --git a/.github/is-version-number-acceptable.sh b/.github/is-version-number-acceptable.sh new file mode 100755 index 00000000..0f704a93 --- /dev/null +++ b/.github/is-version-number-acceptable.sh @@ -0,0 +1,33 @@ +#! /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 + +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 master." + echo "Look at the CONTRIBUTING.md file to learn how to write the changelog." + exit 2 +fi diff --git a/.github/publish-git-tag.sh b/.github/publish-git-tag.sh new file mode 100755 index 00000000..4450357c --- /dev/null +++ b/.github/publish-git-tag.sh @@ -0,0 +1,4 @@ +#! /usr/bin/env bash + +git tag `python setup.py --version` +git push --tags # update the repository version diff --git a/.github/test-api.sh b/.github/test-api.sh new file mode 100755 index 00000000..40edecfd --- /dev/null +++ b/.github/test-api.sh @@ -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 $? diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 00000000..e395751b --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,151 @@ +name: Country Template + +on: [ push ] + +jobs: + install: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: Cache install + id: restore-install + uses: actions/cache@v2 + with: + path: ${{ env.pythonLocation }} + key: ${{ env.pythonLocation }}-install-${{ hashFiles('setup.py') }} # Cache the entire install Python environment + - name: Install dependencies + if: steps.restore-install.outputs.cache-hit != 'true' + run: make install + + lint-files: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Fetch all the tags + - name: Lint Code Base + uses: github/super-linter@v4 + env: + VALIDATE_ALL_CODEBASE: false # Only new or edited files + IGNORE_GITIGNORED_FILES: true + + build: + runs-on: ubuntu-latest + needs: [ install ] + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: Cache build + id: restore-build + uses: actions/cache@v2 + with: + path: ${{ env.pythonLocation }} + key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} # Cache the entire build Python environment + - name: Build package + if: steps.restore-build.outputs.cache-hit != 'true' + run: make build + + test-yaml: + runs-on: ubuntu-latest + needs: [ build ] + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: Cache build + id: restore-build + uses: actions/cache@v2 + with: + path: ${{ env.pythonLocation }} + key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} + - run: | + openfisca test + + test-api: + runs-on: ubuntu-latest + needs: [ build ] + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: Cache build + id: restore-build + uses: actions/cache@v2 + with: + path: ${{ env.pythonLocation }} + key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} + - name: Test the Web API + run: "${GITHUB_WORKSPACE}/.github/test-api.sh" + + check-version-and-changelog: + runs-on: ubuntu-latest + needs: [ lint-files, test-yaml, test-api ] # Last job to run + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Fetch all the tags + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - 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-latest + 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@v2 + with: + fetch-depth: 0 # Fetch all the tags + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - id: stop-early + run: if "${GITHUB_WORKSPACE}/.github/has-functional-changes.sh" ; then echo "::set-output name=status::success" ; fi + + deploy: + runs-on: ubuntu-latest + needs: [ check-for-functional-changes ] + if: needs.check-for-functional-changes.outputs.status == 'success' + env: + PYPI_USERNAME: openfisca-bot + PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} # PYPI_PASSWORD: this value should be set in GitHub secrets! + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Fetch all the tags + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: Cache build + id: restore-build + uses: actions/cache@v2 + with: + path: ${{ env.pythonLocation }} + key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} + - 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" From aeca6c3fff3b2880a0fe78a36600bb2cbcb6d91f Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Thu, 2 Sep 2021 10:10:56 +0200 Subject: [PATCH 02/42] Correct lint errors --- .github/has-functional-changes.sh | 4 ++-- .github/is-version-number-acceptable.sh | 6 +++--- .github/publish-git-tag.sh | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/has-functional-changes.sh b/.github/has-functional-changes.sh index b787de99..3bfbaa76 100755 --- a/.github/has-functional-changes.sh +++ b/.github/has-functional-changes.sh @@ -2,9 +2,9 @@ IGNORE_DIFF_ON="README.md CONTRIBUTING.md Makefile .gitignore .circleci/* .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 +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. +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 diff --git a/.github/is-version-number-acceptable.sh b/.github/is-version-number-acceptable.sh index 0f704a93..6fe4a188 100755 --- a/.github/is-version-number-acceptable.sh +++ b/.github/is-version-number-acceptable.sh @@ -12,12 +12,12 @@ then exit 0 fi -current_version=`python setup.py --version` +current_version=$(python setup.py --version) -if git rev-parse --verify --quiet $current_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 + 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." diff --git a/.github/publish-git-tag.sh b/.github/publish-git-tag.sh index 4450357c..ea0eb489 100755 --- a/.github/publish-git-tag.sh +++ b/.github/publish-git-tag.sh @@ -1,4 +1,4 @@ #! /usr/bin/env bash -git tag `python setup.py --version` +git tag $(python setup.py --version) git push --tags # update the repository version From 2361b2b03c8877584d9b4c57cf66b87eb4ec5d93 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Thu, 2 Sep 2021 10:11:25 +0200 Subject: [PATCH 03/42] Add openfisca tests path --- .github/workflows/workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index e395751b..5b9dbeb9 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -70,7 +70,7 @@ jobs: path: ${{ env.pythonLocation }} key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} - run: | - openfisca test + openfisca test tests test-api: runs-on: ubuntu-latest From 2d605cf87eb5731dfc3dc0c0a42a021eda8d8492 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Thu, 2 Sep 2021 10:15:11 +0200 Subject: [PATCH 04/42] Correct openfisca test path --- .github/workflows/workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 5b9dbeb9..06e71218 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -70,7 +70,7 @@ jobs: path: ${{ env.pythonLocation }} key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} - run: | - openfisca test tests + openfisca test --country-package openfisca_country_template openfisca_country_template/tests test-api: runs-on: ubuntu-latest From f6b3379fcfba554e374c551a97aae822a0469769 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Thu, 2 Sep 2021 10:30:56 +0200 Subject: [PATCH 05/42] Corrent worfklow lint errors --- .github/workflows/workflow.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 06e71218..4ef49a71 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -33,6 +33,7 @@ jobs: env: VALIDATE_ALL_CODEBASE: false # Only new or edited files IGNORE_GITIGNORED_FILES: true + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} build: runs-on: ubuntu-latest @@ -88,7 +89,7 @@ jobs: path: ${{ env.pythonLocation }} key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} - name: Test the Web API - run: "${GITHUB_WORKSPACE}/.github/test-api.sh" + run: $"{GITHUB_WORKSPACE}/.github/test-api.sh" check-version-and-changelog: runs-on: ubuntu-latest @@ -102,7 +103,7 @@ jobs: with: python-version: 3.7 - name: Check version number has been properly updated - run: "${GITHUB_WORKSPACE}/.github/is-version-number-acceptable.sh" + 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. @@ -146,6 +147,6 @@ jobs: path: ${{ env.pythonLocation }} key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} - name: Upload a Python package to PyPi - run: twine upload dist/* --username $PYPI_USERNAME --password $PYPI_PASSWORD + run: twine upload dist/* --username "$PYPI_USERNAME" --password "$PYPI_PASSWORD" - name: Publish a git tag - run: "${GITHUB_WORKSPACE}/.github/publish-git-tag.sh" + run: $"{GITHUB_WORKSPACE}/.github/publish-git-tag.sh" From 378b74847e68ca202dde671bb093c64c1799365c Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Thu, 2 Sep 2021 10:44:47 +0200 Subject: [PATCH 06/42] Correct linting errors --- .github/workflows/workflow.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 4ef49a71..a1048f2e 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -89,7 +89,7 @@ jobs: path: ${{ env.pythonLocation }} key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} - name: Test the Web API - run: $"{GITHUB_WORKSPACE}/.github/test-api.sh" + run: "${GITHUB_WORKSPACE}"/.github/test-api.sh check-version-and-changelog: runs-on: ubuntu-latest @@ -103,7 +103,7 @@ jobs: with: python-version: 3.7 - name: Check version number has been properly updated - run: $"{GITHUB_WORKSPACE}/.github/is-version-number-acceptable.sh" + 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. @@ -149,4 +149,4 @@ jobs: - 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" + run: "${GITHUB_WORKSPACE}/.github/publish-git-tag.sh" From 7ab99320745fc2d600460498d1c90f9098845377 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Thu, 2 Sep 2021 11:29:28 +0200 Subject: [PATCH 07/42] Add linting scripts --- .github/lint-changed-python-files.sh | 11 +++++++++++ .github/lint-changed-yaml-tests.sh | 11 +++++++++++ .github/workflows/workflow.yml | 27 +++++++++++++++++++-------- 3 files changed, 41 insertions(+), 8 deletions(-) create mode 100755 .github/lint-changed-python-files.sh create mode 100755 .github/lint-changed-yaml-tests.sh diff --git a/.github/lint-changed-python-files.sh b/.github/lint-changed-python-files.sh new file mode 100755 index 00000000..72d8aad6 --- /dev/null +++ b/.github/lint-changed-python-files.sh @@ -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 diff --git a/.github/lint-changed-yaml-tests.sh b/.github/lint-changed-yaml-tests.sh new file mode 100755 index 00000000..16e99432 --- /dev/null +++ b/.github/lint-changed-yaml-tests.sh @@ -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 diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index a1048f2e..00761b17 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -24,16 +24,27 @@ jobs: lint-files: runs-on: ubuntu-latest + needs: [ install ] steps: - uses: actions/checkout@v2 with: fetch-depth: 0 # Fetch all the tags - - name: Lint Code Base - uses: github/super-linter@v4 - env: - VALIDATE_ALL_CODEBASE: false # Only new or edited files - IGNORE_GITIGNORED_FILES: true - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: Cache install + id: restore-install + uses: actions/cache@v2 + with: + path: ${{ env.pythonLocation }} + key: ${{ env.pythonLocation }}-install-${{ hashFiles('setup.py') }} + - 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" build: runs-on: ubuntu-latest @@ -89,7 +100,7 @@ jobs: path: ${{ env.pythonLocation }} key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} - name: Test the Web API - run: "${GITHUB_WORKSPACE}"/.github/test-api.sh + run: "${GITHUB_WORKSPACE}/.github/test-api.sh" check-version-and-changelog: runs-on: ubuntu-latest @@ -103,7 +114,7 @@ jobs: with: python-version: 3.7 - name: Check version number has been properly updated - run: "${GITHUB_WORKSPACE}/.github/is-version-number-acceptable.sh" + 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. From 62a10fd2b5f9502da62eab3428a2cf45766bd066 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Thu, 2 Sep 2021 11:40:18 +0200 Subject: [PATCH 08/42] Delete comment --- .github/workflows/workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 00761b17..2492bf30 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -114,7 +114,7 @@ jobs: with: python-version: 3.7 - name: Check version number has been properly updated - run: "${GITHUB_WORKSPACE}/.github/is-version-number-acceptable.sh" # + 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. From 5b42f60db9464819c3ed711854c096fd5a945938 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Wed, 8 Sep 2021 12:10:09 +0200 Subject: [PATCH 09/42] Test linting solution --- .github/workflows/workflow.yml | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 2492bf30..daa82b77 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -24,27 +24,16 @@ jobs: lint-files: runs-on: ubuntu-latest - needs: [ install ] steps: - uses: actions/checkout@v2 with: fetch-depth: 0 # Fetch all the tags - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.7 - - name: Cache install - id: restore-install - uses: actions/cache@v2 - with: - path: ${{ env.pythonLocation }} - key: ${{ env.pythonLocation }}-install-${{ hashFiles('setup.py') }} - - 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" + - name: Lint Code Base + uses: github/super-linter@v4 + env: + VALIDATE_ALL_CODEBASE: false # Only new or edited files + IGNORE_GITIGNORED_FILES: true + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} build: runs-on: ubuntu-latest @@ -100,7 +89,7 @@ jobs: path: ${{ env.pythonLocation }} key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} - name: Test the Web API - run: "${GITHUB_WORKSPACE}/.github/test-api.sh" + run: "${GITHUB_WORKSPACE}""/.github/test-api.sh" check-version-and-changelog: runs-on: ubuntu-latest @@ -114,7 +103,7 @@ jobs: with: python-version: 3.7 - name: Check version number has been properly updated - run: "${GITHUB_WORKSPACE}/.github/is-version-number-acceptable.sh" + 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. @@ -160,4 +149,4 @@ jobs: - 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" + run: "${GITHUB_WORKSPACE}""/.github/publish-git-tag.sh" From 3a9808590fc38f3511e2cd9d24b8a06ca9d6fd05 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Wed, 15 Sep 2021 10:23:38 +0200 Subject: [PATCH 10/42] Remove install job --- .github/workflows/workflow.yml | 40 ++++++++++++++-------------------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index daa82b77..353ef691 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -3,8 +3,9 @@ name: Country Template on: [ push ] jobs: - install: + build: runs-on: ubuntu-latest + needs: [ install ] steps: - name: Checkout uses: actions/checkout@v2 @@ -12,35 +13,23 @@ jobs: uses: actions/setup-python@v2 with: python-version: 3.7 - - name: Cache install - id: restore-install + - name: Cache build + id: restore-build uses: actions/cache@v2 with: path: ${{ env.pythonLocation }} - key: ${{ env.pythonLocation }}-install-${{ hashFiles('setup.py') }} # Cache the entire install Python environment - - name: Install dependencies - if: steps.restore-install.outputs.cache-hit != 'true' - run: make install + key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} # Cache the entire build Python environment + - name: Build package + if: steps.restore-build.outputs.cache-hit != 'true' + run: make build lint-files: runs-on: ubuntu-latest + needs: [ build ] steps: - uses: actions/checkout@v2 with: fetch-depth: 0 # Fetch all the tags - - name: Lint Code Base - uses: github/super-linter@v4 - env: - VALIDATE_ALL_CODEBASE: false # Only new or edited files - IGNORE_GITIGNORED_FILES: true - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - build: - runs-on: ubuntu-latest - needs: [ install ] - steps: - - name: Checkout - uses: actions/checkout@v2 - name: Set up Python uses: actions/setup-python@v2 with: @@ -50,10 +39,13 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.pythonLocation }} - key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} # Cache the entire build Python environment - - name: Build package - if: steps.restore-build.outputs.cache-hit != 'true' - run: make build + key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} + - 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-yaml: runs-on: ubuntu-latest From eff777dc75857feec7da6c4dbc3de2231c7daf14 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Wed, 15 Sep 2021 10:25:36 +0200 Subject: [PATCH 11/42] Cache dist directory --- .github/workflows/workflow.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 353ef691..6887dd6a 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -5,7 +5,6 @@ on: [ push ] jobs: build: runs-on: ubuntu-latest - needs: [ install ] steps: - name: Checkout uses: actions/checkout@v2 @@ -22,6 +21,12 @@ jobs: - name: Build package if: steps.restore-build.outputs.cache-hit != 'true' run: make build + - name: Cache build release + id: restore-build-release + uses: actions/cache@v2 + with: + path: dist + key: ${{ env.pythonLocation }}-build-release-${{ hashFiles('setup.py') }} lint-files: runs-on: ubuntu-latest From 25bf2189d0024d4e529afe569cc52f9ac4b3a8e4 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Wed, 15 Sep 2021 10:45:13 +0200 Subject: [PATCH 12/42] Add dist cache to deploy --- .github/workflows/workflow.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 6887dd6a..4aaf7e51 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -143,6 +143,12 @@ jobs: with: path: ${{ env.pythonLocation }} key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} + - name: Cache build release + id: restore-build-release + uses: actions/cache@v2 + with: + path: dist + key: ${{ env.pythonLocation }}-build-release-${{ hashFiles('setup.py') }} - name: Upload a Python package to PyPi run: twine upload dist/* --username "$PYPI_USERNAME" --password "$PYPI_PASSWORD" - name: Publish a git tag From 228d9bb4745e44adaf3650e28cbf1676d594a305 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Wed, 15 Sep 2021 10:49:12 +0200 Subject: [PATCH 13/42] Remove circleci files --- .circleci/config.yml | 117 ---------------------- .circleci/has-functional-changes.sh | 12 --- .circleci/is-version-number-acceptable.sh | 33 ------ .circleci/publish-git-tag.sh | 4 - .circleci/test-api.sh | 14 --- .github/has-functional-changes.sh | 2 +- 6 files changed, 1 insertion(+), 181 deletions(-) delete mode 100644 .circleci/config.yml delete mode 100755 .circleci/has-functional-changes.sh delete mode 100755 .circleci/is-version-number-acceptable.sh delete mode 100755 .circleci/publish-git-tag.sh delete mode 100755 .circleci/test-api.sh diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 4051e4dc..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,117 +0,0 @@ -# CircleCI 2.0 configuration file. See . -version: 2 -jobs: - build: - docker: - - image: python:3.7 - - steps: - - checkout - - - restore_cache: - key: v1-py3-deps-{{ checksum "setup.py" }} - - - run: - name: Create a virtualenv - command: | - mkdir -p /tmp/venv/country_template - python -m venv /tmp/venv/country_template - echo "source /tmp/venv/country_template/bin/activate" >> $BASH_ENV - - - run: - name: Install dependencies - command: | - make build - # pip install --editable git+https://github.com/openfisca/openfisca-core.git@BRANCH#egg=OpenFisca-Core[web-api] # use a specific branch of OpenFisca-Core - - - save_cache: - key: v1-py3-deps-{{ checksum "setup.py" }} - paths: - - /tmp/venv/country_template - - - save_cache: - key: v1-py3-build-{{ .Revision }} - paths: - - dist - - - run: - name: Run tests - command: make test - - check_version: - docker: - - image: python:3.7 - - steps: - - checkout - - - run: - name: Check version number has been properly updated - command: | - git fetch - .circleci/is-version-number-acceptable.sh - - test_api: - docker: - - image: python:3.7 - - steps: - - checkout - - - restore_cache: - key: v1-py3-deps-{{ checksum "setup.py" }} - - - run: - name: Activate virtualenv - command: echo "source /tmp/venv/country_template/bin/activate" >> $BASH_ENV - - - run: - name: Test the Web API - command: .circleci/test-api.sh - - deploy: - docker: - - image: python:3.7 - environment: - PYPI_USERNAME: openfisca-bot # Edit this value to replace it by your Pypi username - # PYPI_PASSWORD: this value is set in CircleCI's web interface; do not set it here, it is a secret! - - steps: - - checkout - - - restore_cache: - key: v1-py3-deps-{{ checksum "setup.py" }} - - - restore_cache: - key: v1-py3-build-{{ .Revision }} - - - run: - name: Check for functional changes - command: if ! .circleci/has-functional-changes.sh ; then circleci step halt ; fi - - - run: - name: Upload a Python package to Pypi - command: | - source /tmp/venv/country_template/bin/activate - twine upload dist/* --username $PYPI_USERNAME --password $PYPI_PASSWORD - - - run: - name: Publish a git tag - command: .circleci/publish-git-tag.sh - -workflows: - version: 2 - build_and_deploy: - jobs: - - build - - test_api: - requires: - - build - - check_version - - deploy: - requires: - - build - - check_version - filters: - branches: - only: master diff --git a/.circleci/has-functional-changes.sh b/.circleci/has-functional-changes.sh deleted file mode 100755 index b787de99..00000000 --- a/.circleci/has-functional-changes.sh +++ /dev/null @@ -1,12 +0,0 @@ -#! /usr/bin/env bash - -IGNORE_DIFF_ON="README.md CONTRIBUTING.md Makefile .gitignore .circleci/* .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 diff --git a/.circleci/is-version-number-acceptable.sh b/.circleci/is-version-number-acceptable.sh deleted file mode 100755 index ae370e2a..00000000 --- a/.circleci/is-version-number-acceptable.sh +++ /dev/null @@ -1,33 +0,0 @@ -#! /usr/bin/env bash - -if [[ $CIRCLE_BRANCH == 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 - -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 master." - echo "Look at the CONTRIBUTING.md file to learn how to write the changelog." - exit 2 -fi diff --git a/.circleci/publish-git-tag.sh b/.circleci/publish-git-tag.sh deleted file mode 100755 index 4450357c..00000000 --- a/.circleci/publish-git-tag.sh +++ /dev/null @@ -1,4 +0,0 @@ -#! /usr/bin/env bash - -git tag `python setup.py --version` -git push --tags # update the repository version diff --git a/.circleci/test-api.sh b/.circleci/test-api.sh deleted file mode 100755 index 40edecfd..00000000 --- a/.circleci/test-api.sh +++ /dev/null @@ -1,14 +0,0 @@ -#! /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 $? diff --git a/.github/has-functional-changes.sh b/.github/has-functional-changes.sh index 3bfbaa76..591dd346 100755 --- a/.github/has-functional-changes.sh +++ b/.github/has-functional-changes.sh @@ -1,6 +1,6 @@ #! /usr/bin/env bash -IGNORE_DIFF_ON="README.md CONTRIBUTING.md Makefile .gitignore .circleci/* .github/*" +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 From bc0c1c011f2c025b17eb9d4a4b7912f907f820f1 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Wed, 15 Sep 2021 10:50:43 +0200 Subject: [PATCH 14/42] Fix yaml bug --- .github/workflows/workflow.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 4aaf7e51..975d1d8a 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -86,7 +86,7 @@ jobs: path: ${{ env.pythonLocation }} key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} - name: Test the Web API - run: "${GITHUB_WORKSPACE}""/.github/test-api.sh" + run: "${GITHUB_WORKSPACE}/.github/test-api.sh" check-version-and-changelog: runs-on: ubuntu-latest @@ -100,7 +100,7 @@ jobs: with: python-version: 3.7 - name: Check version number has been properly updated - run: "${GITHUB_WORKSPACE}""/.github/is-version-number-acceptable.sh" + 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. @@ -152,4 +152,4 @@ jobs: - 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" + run: "${GITHUB_WORKSPACE}/.github/publish-git-tag.sh" From 1f2fba44537fea6c573a9dc7463c3ec72fc10ac0 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Wed, 22 Sep 2021 15:24:27 +0200 Subject: [PATCH 15/42] Add branch ref to cache key --- .github/workflows/workflow.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 975d1d8a..ac895cb7 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -17,7 +17,7 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.pythonLocation }} - key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} # Cache the entire build Python environment + key: ${{ github.ref }}${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} # Cache the entire build Python environment - name: Build package if: steps.restore-build.outputs.cache-hit != 'true' run: make build @@ -26,7 +26,7 @@ jobs: uses: actions/cache@v2 with: path: dist - key: ${{ env.pythonLocation }}-build-release-${{ hashFiles('setup.py') }} + key: ${{ github.ref }}${{ env.pythonLocation }}-build-release-${{ hashFiles('setup.py') }} lint-files: runs-on: ubuntu-latest @@ -44,7 +44,7 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.pythonLocation }} - key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} + key: ${{ github.ref }}${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} - run: make check-syntax-errors - run: make check-style - name: Lint Python files @@ -66,7 +66,7 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.pythonLocation }} - key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} + key: ${{ github.ref }}${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} - run: | openfisca test --country-package openfisca_country_template openfisca_country_template/tests @@ -84,7 +84,7 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.pythonLocation }} - key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} + key: ${{ github.ref }}${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} - name: Test the Web API run: "${GITHUB_WORKSPACE}/.github/test-api.sh" @@ -142,7 +142,7 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.pythonLocation }} - key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} + key: ${{ github.ref }}${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} - name: Cache build release id: restore-build-release uses: actions/cache@v2 From bfb5496324eeabe055b99694897896882ea20972 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Wed, 22 Sep 2021 15:39:16 +0200 Subject: [PATCH 16/42] Add super-linter --- .github/linters/setup.cfg | 31 +++++++++++++++++++++++++++++++ .github/workflows/workflow.yml | 29 ++++++++++++----------------- 2 files changed, 43 insertions(+), 17 deletions(-) create mode 100644 .github/linters/setup.cfg diff --git a/.github/linters/setup.cfg b/.github/linters/setup.cfg new file mode 100644 index 00000000..b4c7f08d --- /dev/null +++ b/.github/linters/setup.cfg @@ -0,0 +1,31 @@ +; D101: Variables already provide label/description +; D107: We do not document __init__ method +; D401: We do not require the imperative mood +; E128/133: We prefer hang-closing visual indents +; E251: We prefer `function(x = 1)` over `function(x=1)` +; E501: We do not enforce a maximum line length +; W503/4: We break lines before binary operators (Knuth's style) + +[flake8] +hang-closing = true +ignore = D101,D107,D401,E128,E251,E501,W503 +in-place = true +inline-quotes = " +multiline-quotes = """ +import-order-style = appnexus +no-accept-encodings = true +application-import-names = openfisca_country_template +application-package-names = openfisca_country_template,openfisca_extension_template + +; C0103: We (still) snake case variables and reforms +; C0115: Variables already provide label/description +; C0301: We do not enforce a maximum line length +; E0213: This requires changes in OpenFisca-Core +; E1101: False positive, as entities have members +; E1102: False positive, as entities are callable +; W0621: We name variable values the variable name +; W1203: We prefer to log with f-strings + +[pylint.message_control] +disable = C0103,C0115,C0301,E0213,E1101,E1102,W0621,W1203 +score = no \ No newline at end of file diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index ac895cb7..f458449c 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -30,27 +30,22 @@ jobs: lint-files: runs-on: ubuntu-latest - needs: [ build ] steps: - uses: actions/checkout@v2 with: fetch-depth: 0 # Fetch all the tags - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.7 - - name: Cache build - id: restore-build - uses: actions/cache@v2 - with: - path: ${{ env.pythonLocation }} - key: ${{ github.ref }}${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} - - 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" + - name: Lint Code Base + uses: github/super-linter/slim@v4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + IGNORE_GITIGNORED_FILES: true + VALIDATE_ALL_CODEBASE: false # Only new or edited files + VALIDATE_JSCPD: false # Copy/paste detection + VALIDATE_GITHUB_ACTIONS: false # Due to shellcheck SC2086 issues + VALIDATE_MARKDOWN: false # Due to multiple headings issue + VALIDATE_PYTHON_BLACK: false # Not using black + PYTHON_FLAKE8_CONFIG_FILE: setup.cfg + PYTHON_PYLINT_CONFIG_FILE: setup.cfg test-yaml: runs-on: ubuntu-latest From e87fd129dc084cf292f783348e8e2e698a077a7c Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Wed, 22 Sep 2021 15:50:30 +0200 Subject: [PATCH 17/42] Delete linting scripts --- .github/lint-changed-python-files.sh | 11 ----------- .github/lint-changed-yaml-tests.sh | 11 ----------- 2 files changed, 22 deletions(-) delete mode 100755 .github/lint-changed-python-files.sh delete mode 100755 .github/lint-changed-yaml-tests.sh diff --git a/.github/lint-changed-python-files.sh b/.github/lint-changed-python-files.sh deleted file mode 100755 index 72d8aad6..00000000 --- a/.github/lint-changed-python-files.sh +++ /dev/null @@ -1,11 +0,0 @@ -#! /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 diff --git a/.github/lint-changed-yaml-tests.sh b/.github/lint-changed-yaml-tests.sh deleted file mode 100755 index 16e99432..00000000 --- a/.github/lint-changed-yaml-tests.sh +++ /dev/null @@ -1,11 +0,0 @@ -#! /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 From d88a3ae8a1f65420b7dc3a2280d95213f870b6b9 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Thu, 23 Sep 2021 15:27:20 +0200 Subject: [PATCH 18/42] Revert "Add super-linter" This reverts commit 0773cff3354366ab3ecfc4818105b229658e5908. --- .github/linters/setup.cfg | 31 ------------------------------- .github/workflows/workflow.yml | 29 +++++++++++++++++------------ 2 files changed, 17 insertions(+), 43 deletions(-) delete mode 100644 .github/linters/setup.cfg diff --git a/.github/linters/setup.cfg b/.github/linters/setup.cfg deleted file mode 100644 index b4c7f08d..00000000 --- a/.github/linters/setup.cfg +++ /dev/null @@ -1,31 +0,0 @@ -; D101: Variables already provide label/description -; D107: We do not document __init__ method -; D401: We do not require the imperative mood -; E128/133: We prefer hang-closing visual indents -; E251: We prefer `function(x = 1)` over `function(x=1)` -; E501: We do not enforce a maximum line length -; W503/4: We break lines before binary operators (Knuth's style) - -[flake8] -hang-closing = true -ignore = D101,D107,D401,E128,E251,E501,W503 -in-place = true -inline-quotes = " -multiline-quotes = """ -import-order-style = appnexus -no-accept-encodings = true -application-import-names = openfisca_country_template -application-package-names = openfisca_country_template,openfisca_extension_template - -; C0103: We (still) snake case variables and reforms -; C0115: Variables already provide label/description -; C0301: We do not enforce a maximum line length -; E0213: This requires changes in OpenFisca-Core -; E1101: False positive, as entities have members -; E1102: False positive, as entities are callable -; W0621: We name variable values the variable name -; W1203: We prefer to log with f-strings - -[pylint.message_control] -disable = C0103,C0115,C0301,E0213,E1101,E1102,W0621,W1203 -score = no \ No newline at end of file diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index f458449c..ac895cb7 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -30,22 +30,27 @@ jobs: lint-files: runs-on: ubuntu-latest + needs: [ build ] steps: - uses: actions/checkout@v2 with: fetch-depth: 0 # Fetch all the tags - - name: Lint Code Base - uses: github/super-linter/slim@v4 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - IGNORE_GITIGNORED_FILES: true - VALIDATE_ALL_CODEBASE: false # Only new or edited files - VALIDATE_JSCPD: false # Copy/paste detection - VALIDATE_GITHUB_ACTIONS: false # Due to shellcheck SC2086 issues - VALIDATE_MARKDOWN: false # Due to multiple headings issue - VALIDATE_PYTHON_BLACK: false # Not using black - PYTHON_FLAKE8_CONFIG_FILE: setup.cfg - PYTHON_PYLINT_CONFIG_FILE: setup.cfg + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: Cache build + id: restore-build + uses: actions/cache@v2 + with: + path: ${{ env.pythonLocation }} + key: ${{ github.ref }}${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} + - 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-yaml: runs-on: ubuntu-latest From 6f6c14052721716cad2b04e521d5f4b54461b362 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Thu, 23 Sep 2021 15:27:51 +0200 Subject: [PATCH 19/42] Revert "Delete linting scripts" This reverts commit aaea4ddd6e0566609b5a1265d40f07a6da6fc4f4. --- .github/lint-changed-python-files.sh | 11 +++++++++++ .github/lint-changed-yaml-tests.sh | 11 +++++++++++ 2 files changed, 22 insertions(+) create mode 100755 .github/lint-changed-python-files.sh create mode 100755 .github/lint-changed-yaml-tests.sh diff --git a/.github/lint-changed-python-files.sh b/.github/lint-changed-python-files.sh new file mode 100755 index 00000000..72d8aad6 --- /dev/null +++ b/.github/lint-changed-python-files.sh @@ -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 diff --git a/.github/lint-changed-yaml-tests.sh b/.github/lint-changed-yaml-tests.sh new file mode 100755 index 00000000..16e99432 --- /dev/null +++ b/.github/lint-changed-yaml-tests.sh @@ -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 From 46af0dc63dadcbacd6890660709c98a027f84088 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Thu, 23 Sep 2021 16:24:10 +0200 Subject: [PATCH 20/42] Update changelog --- .github/workflows/workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index ac895cb7..5ecfd352 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -107,7 +107,7 @@ jobs: # The `deploy` job is dependent on the output of the `check-for-functional-changes`job. check-for-functional-changes: runs-on: ubuntu-latest - if: github.ref == 'refs/heads/master' # Only triggered for the `master` branch + if: github.ref == 'refs/heads/github-actions' # Only triggered for the `master` branch needs: [ check-version-and-changelog ] outputs: status: ${{ steps.stop-early.outputs.status }} From 3272c756fadb785cb601ec9f4f2ba2b1cab856cb Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Thu, 23 Sep 2021 16:30:09 +0200 Subject: [PATCH 21/42] Fix syntax error in shell script --- .github/has-functional-changes.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/has-functional-changes.sh b/.github/has-functional-changes.sh index 591dd346..dad80305 100755 --- a/.github/has-functional-changes.sh +++ b/.github/has-functional-changes.sh @@ -4,7 +4,7 @@ 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. +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 From 4b4f4e8db9b4f40e15156bdec0e11b4b8efc2634 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Thu, 23 Sep 2021 16:35:36 +0200 Subject: [PATCH 22/42] Add branch ref to cache in deploy --- .github/workflows/workflow.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 5ecfd352..6bdae580 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -148,8 +148,8 @@ jobs: uses: actions/cache@v2 with: path: dist - key: ${{ env.pythonLocation }}-build-release-${{ hashFiles('setup.py') }} + key: ${{ github.ref }}${{ env.pythonLocation }}-build-release-${{ hashFiles('setup.py') }} - name: Upload a Python package to PyPi - run: twine upload dist/* --username "$PYPI_USERNAME" --password "$PYPI_PASSWORD" + run: twine upload dist/* --username $PYPI_USERNAME --password $PYPI_PASSWORD - name: Publish a git tag run: "${GITHUB_WORKSPACE}/.github/publish-git-tag.sh" From 76780379ee9941d21a8e26f5ab34dfa18752130c Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Thu, 23 Sep 2021 16:38:56 +0200 Subject: [PATCH 23/42] Remove pipe in test-yaml --- .github/workflows/workflow.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 6bdae580..34c5afd3 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -67,8 +67,7 @@ jobs: with: path: ${{ env.pythonLocation }} key: ${{ github.ref }}${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} - - run: | - openfisca test --country-package openfisca_country_template openfisca_country_template/tests + - run: openfisca test --country-package openfisca_country_template openfisca_country_template/tests test-api: runs-on: ubuntu-latest From d07845ae148cf7a83de99d7e0ca4e15ec870394a Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Thu, 23 Sep 2021 16:40:02 +0200 Subject: [PATCH 24/42] Remove quotes --- .github/is-version-number-acceptable.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/is-version-number-acceptable.sh b/.github/is-version-number-acceptable.sh index 6fe4a188..b22a5966 100755 --- a/.github/is-version-number-acceptable.sh +++ b/.github/is-version-number-acceptable.sh @@ -14,10 +14,10 @@ fi current_version=$(python setup.py --version) -if git rev-parse --verify --quiet "$current_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" + 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." From 0bfc045e5b4bacf2c5719379e3617a9e4461b793 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Thu, 23 Sep 2021 16:47:39 +0200 Subject: [PATCH 25/42] Remove circleci mention --- bootstrap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap.sh b/bootstrap.sh index 5a1f459e..003e1278 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -36,7 +36,7 @@ all_module_files=`find openfisca_country_template -type f` set -x # Use intermediate backup files (`-i`) with a weird syntax due to lack of portable 'no backup' option. See https://stackoverflow.com/q/5694228/594053. -sed -i.template "s|country_template|$lowercase_country_name|g" README.md setup.py .circleci/config.yml Makefile MANIFEST.in $all_module_files +sed -i.template "s|country_template|$lowercase_country_name|g" README.md setup.py .github/workflows/workflow.yml Makefile MANIFEST.in $all_module_files sed -i.template "s|Country-Template|$COUNTRY_NAME|g" README.md setup.py .github/PULL_REQUEST_TEMPLATE.md CONTRIBUTING.md $all_module_files sed -i.template -e "3,${last_bootstrapping_line_number}d" README.md # remove instructions lines sed -i.template "s|country-template|$lowercase_country_name|g" README.md From 0a34b7bfea5cfc92ef7407c0f18b6674db5e7793 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Thu, 23 Sep 2021 17:09:27 +0200 Subject: [PATCH 26/42] Remove step output from check-for-functional-changes --- .github/workflows/workflow.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 34c5afd3..79a88dfe 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -119,12 +119,11 @@ jobs: with: python-version: 3.7 - id: stop-early - run: if "${GITHUB_WORKSPACE}/.github/has-functional-changes.sh" ; then echo "::set-output name=status::success" ; fi + run: "${GITHUB_WORKSPACE}/.github/has-functional-changes.sh" deploy: runs-on: ubuntu-latest needs: [ check-for-functional-changes ] - if: needs.check-for-functional-changes.outputs.status == 'success' env: PYPI_USERNAME: openfisca-bot PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} # PYPI_PASSWORD: this value should be set in GitHub secrets! From dfe5badf69fba013bb0b1fc47a166a6e18f0c702 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Thu, 23 Sep 2021 17:15:08 +0200 Subject: [PATCH 27/42] Update changelog --- .github/has-functional-changes.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/has-functional-changes.sh b/.github/has-functional-changes.sh index dad80305..517fbd6d 100755 --- a/.github/has-functional-changes.sh +++ b/.github/has-functional-changes.sh @@ -4,7 +4,7 @@ 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. +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 From b751977473405de4d363b6a223f62d1f7ac4dad8 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Thu, 23 Sep 2021 17:21:53 +0200 Subject: [PATCH 28/42] Change deploy branch to master --- .github/workflows/workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 79a88dfe..e275ad91 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -106,7 +106,7 @@ jobs: # The `deploy` job is dependent on the output of the `check-for-functional-changes`job. check-for-functional-changes: runs-on: ubuntu-latest - if: github.ref == 'refs/heads/github-actions' # Only triggered for the `master` branch + if: github.ref == 'refs/heads/master' # Only triggered for the `master` branch needs: [ check-version-and-changelog ] outputs: status: ${{ steps.stop-early.outputs.status }} From 640ba01bb9f2fc2b3a54403fc66952458619e561 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Thu, 23 Sep 2021 17:27:40 +0200 Subject: [PATCH 29/42] Remove pypi password comment --- .github/workflows/workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index e275ad91..5c5898aa 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -126,7 +126,7 @@ jobs: needs: [ check-for-functional-changes ] env: PYPI_USERNAME: openfisca-bot - PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} # PYPI_PASSWORD: this value should be set in GitHub secrets! + PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} steps: - uses: actions/checkout@v2 with: From 06472a60186b0e3b1e1763cddb847770f32d4984 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Thu, 23 Sep 2021 17:30:07 +0200 Subject: [PATCH 30/42] Specify Python version patch --- .github/workflows/workflow.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 5c5898aa..f2eac521 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -11,7 +11,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.7 + python-version: 3.7.12 - name: Cache build id: restore-build uses: actions/cache@v2 @@ -38,7 +38,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.7 + python-version: 3.7.12 - name: Cache build id: restore-build uses: actions/cache@v2 @@ -60,7 +60,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.7 + python-version: 3.7.12 - name: Cache build id: restore-build uses: actions/cache@v2 @@ -77,7 +77,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.7 + python-version: 3.7.12 - name: Cache build id: restore-build uses: actions/cache@v2 @@ -97,7 +97,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.7 + python-version: 3.7.12 - name: Check version number has been properly updated run: "${GITHUB_WORKSPACE}/.github/is-version-number-acceptable.sh" @@ -117,7 +117,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.7 + python-version: 3.7.12 - id: stop-early run: "${GITHUB_WORKSPACE}/.github/has-functional-changes.sh" @@ -134,7 +134,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.7 + python-version: 3.7.12 - name: Cache build id: restore-build uses: actions/cache@v2 From a49f39fcb52d1cf8276e900fec200df98f60b504 Mon Sep 17 00:00:00 2001 From: Hajar AIT EL KADI <48837850+HAEKADI@users.noreply.github.com> Date: Fri, 24 Sep 2021 12:15:30 +0200 Subject: [PATCH 31/42] Update CHANGELOG details Co-authored-by: Matti Schneider --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a83ea33..72fc20a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -### 3.12.10 - [#115](https://github.com/openfisca/country-template/pull/115) +### 3.12.10 - [#119](https://github.com/openfisca/country-template/pull/119) * Technical improvement. * Details: From c626cd9522fc7010d015c36c07f9c1295f1608cf Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Fri, 24 Sep 2021 14:14:29 +0200 Subject: [PATCH 32/42] Update changelog --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 4bbed210..b90d490e 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup( name = "OpenFisca-Country-Template", - version = "3.12.10", + version = "3.13.0", author = "OpenFisca Team", author_email = "contact@openfisca.org", classifiers = [ From 337a558ae8d249ebb80221af2b81a828e5a8a1f6 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Fri, 24 Sep 2021 20:16:11 +0200 Subject: [PATCH 33/42] Rename workflow when executing bootstrap script --- .github/workflows/workflow.yml | 2 +- bootstrap.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index f2eac521..5e157232 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -1,4 +1,4 @@ -name: Country Template +name: Country-Template on: [ push ] diff --git a/bootstrap.sh b/bootstrap.sh index 003e1278..0bb1b983 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -36,8 +36,9 @@ all_module_files=`find openfisca_country_template -type f` set -x # Use intermediate backup files (`-i`) with a weird syntax due to lack of portable 'no backup' option. See https://stackoverflow.com/q/5694228/594053. +# If you're using MacOS, add LC_ALL=C before sed https://stackoverflow.com/questions/19242275/re-error-illegal-byte-sequence-on-mac-os-x/19770395#19770395 sed -i.template "s|country_template|$lowercase_country_name|g" README.md setup.py .github/workflows/workflow.yml Makefile MANIFEST.in $all_module_files -sed -i.template "s|Country-Template|$COUNTRY_NAME|g" README.md setup.py .github/PULL_REQUEST_TEMPLATE.md CONTRIBUTING.md $all_module_files +sed -i.template "s|Country-Template|$COUNTRY_NAME|g" README.md setup.py .github/workflows/workflow.yml .github/PULL_REQUEST_TEMPLATE.md CONTRIBUTING.md $all_module_files sed -i.template -e "3,${last_bootstrapping_line_number}d" README.md # remove instructions lines sed -i.template "s|country-template|$lowercase_country_name|g" README.md sed -i.template "s|https://github.com/openfisca/openfisca-country-template|$URL|g" setup.py From 510af1fe95125e36e09647558b8e74c33cb18bd4 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Thu, 30 Sep 2021 09:46:56 +0200 Subject: [PATCH 34/42] Delete cache hit condition --- .github/workflows/workflow.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 5e157232..4a6fb3b2 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -19,7 +19,6 @@ jobs: path: ${{ env.pythonLocation }} key: ${{ github.ref }}${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} # Cache the entire build Python environment - name: Build package - if: steps.restore-build.outputs.cache-hit != 'true' run: make build - name: Cache build release id: restore-build-release From 58092b6918f1b9d142477c9037c38703092db680 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Thu, 30 Sep 2021 09:48:10 +0200 Subject: [PATCH 35/42] Add commit SHA to cache key --- .github/workflows/workflow.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 4a6fb3b2..d44c789c 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -17,7 +17,7 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.pythonLocation }} - key: ${{ github.ref }}${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} # Cache the entire build Python environment + key: ${{ github.ref }}${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.sha }} # Cache the entire build Python environment - name: Build package run: make build - name: Cache build release @@ -25,7 +25,7 @@ jobs: uses: actions/cache@v2 with: path: dist - key: ${{ github.ref }}${{ env.pythonLocation }}-build-release-${{ hashFiles('setup.py') }} + key: ${{ github.ref }}${{ env.pythonLocation }}-build-release-${{ hashFiles('setup.py') }}-${{ github.sha }} lint-files: runs-on: ubuntu-latest @@ -43,7 +43,7 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.pythonLocation }} - key: ${{ github.ref }}${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} + key: ${{ github.ref }}${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.sha }} - run: make check-syntax-errors - run: make check-style - name: Lint Python files @@ -65,7 +65,7 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.pythonLocation }} - key: ${{ github.ref }}${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} + key: ${{ github.ref }}${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.sha }} - run: openfisca test --country-package openfisca_country_template openfisca_country_template/tests test-api: @@ -82,7 +82,7 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.pythonLocation }} - key: ${{ github.ref }}${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} + key: ${{ github.ref }}${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.sha }} - name: Test the Web API run: "${GITHUB_WORKSPACE}/.github/test-api.sh" @@ -139,13 +139,13 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.pythonLocation }} - key: ${{ github.ref }}${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} + key: ${{ github.ref }}${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.sha }} - name: Cache build release id: restore-build-release uses: actions/cache@v2 with: path: dist - key: ${{ github.ref }}${{ env.pythonLocation }}-build-release-${{ hashFiles('setup.py') }} + key: ${{ github.ref }}${{ env.pythonLocation }}-build-release-${{ hashFiles('setup.py') }}-${{ github.sha }} - name: Upload a Python package to PyPi run: twine upload dist/* --username $PYPI_USERNAME --password $PYPI_PASSWORD - name: Publish a git tag From 5aa082ca508ea241ef8b2cc05fd35dd506bab007 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Thu, 30 Sep 2021 09:51:11 +0200 Subject: [PATCH 36/42] Change expression order in cache key --- .github/workflows/workflow.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index d44c789c..642dede9 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -17,7 +17,7 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.pythonLocation }} - key: ${{ github.ref }}${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.sha }} # Cache the entire build Python environment + key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.ref }}-${{ github.sha }} # Cache the entire build Python environment - name: Build package run: make build - name: Cache build release @@ -25,7 +25,7 @@ jobs: uses: actions/cache@v2 with: path: dist - key: ${{ github.ref }}${{ env.pythonLocation }}-build-release-${{ hashFiles('setup.py') }}-${{ github.sha }} + key: ${{ env.pythonLocation }}-release-build-${{ hashFiles('setup.py') }}-${{ github.ref }}-${{ github.sha }} lint-files: runs-on: ubuntu-latest @@ -43,7 +43,7 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.pythonLocation }} - key: ${{ github.ref }}${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.sha }} + key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.ref }}-${{ github.sha }} - run: make check-syntax-errors - run: make check-style - name: Lint Python files @@ -65,7 +65,7 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.pythonLocation }} - key: ${{ github.ref }}${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.sha }} + key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.ref }}-${{ github.sha }} - run: openfisca test --country-package openfisca_country_template openfisca_country_template/tests test-api: @@ -82,7 +82,7 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.pythonLocation }} - key: ${{ github.ref }}${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.sha }} + key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.ref }}-${{ github.sha }} - name: Test the Web API run: "${GITHUB_WORKSPACE}/.github/test-api.sh" @@ -139,13 +139,13 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.pythonLocation }} - key: ${{ github.ref }}${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.sha }} + key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.ref }}-${{ github.sha }} - name: Cache build release id: restore-build-release uses: actions/cache@v2 with: path: dist - key: ${{ github.ref }}${{ env.pythonLocation }}-build-release-${{ hashFiles('setup.py') }}-${{ github.sha }} + key: ${{ env.pythonLocation }}-release-build-${{ hashFiles('setup.py') }}-${{ github.ref }}-${{ github.sha }} - name: Upload a Python package to PyPi run: twine upload dist/* --username $PYPI_USERNAME --password $PYPI_PASSWORD - name: Publish a git tag From b24e584a27c5b685ea399349d8319be336b0acb8 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Thu, 30 Sep 2021 09:51:54 +0200 Subject: [PATCH 37/42] Add restore keys to build cache --- .github/workflows/workflow.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 642dede9..bc339b44 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -18,6 +18,10 @@ jobs: with: path: ${{ env.pythonLocation }} key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.ref }}-${{ github.sha }} # Cache the entire build Python environment + restore-keys: | + ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.ref }} + ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} + ${{ env.pythonLocation }}-build- - name: Build package run: make build - name: Cache build release From 35c7ce0853f2131aada28994b1191046f23124f7 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Thu, 30 Sep 2021 12:05:06 +0200 Subject: [PATCH 38/42] Remove branch ref from cache key --- .github/workflows/workflow.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index bc339b44..9ec70575 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -17,9 +17,8 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.pythonLocation }} - key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.ref }}-${{ github.sha }} # Cache the entire build Python environment + key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.sha }} # Cache the entire build Python environment restore-keys: | - ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.ref }} ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} ${{ env.pythonLocation }}-build- - name: Build package @@ -29,7 +28,7 @@ jobs: uses: actions/cache@v2 with: path: dist - key: ${{ env.pythonLocation }}-release-build-${{ hashFiles('setup.py') }}-${{ github.ref }}-${{ github.sha }} + key: ${{ env.pythonLocation }}-release-build-${{ hashFiles('setup.py') }}-${{ github.sha }} lint-files: runs-on: ubuntu-latest @@ -47,7 +46,7 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.pythonLocation }} - key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.ref }}-${{ github.sha }} + key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.sha }} - run: make check-syntax-errors - run: make check-style - name: Lint Python files @@ -69,7 +68,7 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.pythonLocation }} - key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.ref }}-${{ github.sha }} + key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.sha }} - run: openfisca test --country-package openfisca_country_template openfisca_country_template/tests test-api: @@ -86,7 +85,7 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.pythonLocation }} - key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.ref }}-${{ github.sha }} + key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.sha }} - name: Test the Web API run: "${GITHUB_WORKSPACE}/.github/test-api.sh" @@ -143,13 +142,13 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.pythonLocation }} - key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.ref }}-${{ github.sha }} + key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.sha }} - name: Cache build release id: restore-build-release uses: actions/cache@v2 with: path: dist - key: ${{ env.pythonLocation }}-release-build-${{ hashFiles('setup.py') }}-${{ github.ref }}-${{ github.sha }} + key: ${{ env.pythonLocation }}-release-build-${{ hashFiles('setup.py') }}-${{ github.sha }} - name: Upload a Python package to PyPi run: twine upload dist/* --username $PYPI_USERNAME --password $PYPI_PASSWORD - name: Publish a git tag From dddfdf41cb4d5aed2d143b4d4ca668252f36b91c Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Mon, 18 Oct 2021 15:50:28 +0200 Subject: [PATCH 39/42] Add Python patch comment --- .github/workflows/workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 9ec70575..eceffaee 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -11,7 +11,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.7.12 + python-version: 3.7.12 # Patch version must be specified to avoid any cache confusion, since the cache key depends on the full Python version - name: Cache build id: restore-build uses: actions/cache@v2 From b1d485a1c9797b9b98a768fb0669b31a9eae290d Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Tue, 19 Oct 2021 14:14:31 +0200 Subject: [PATCH 40/42] Add step output condition to deploy --- .github/workflows/workflow.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index eceffaee..b2a169be 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -11,7 +11,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.7.12 # Patch version must be specified to avoid any cache confusion, since the cache key depends on the full Python version + python-version: 3.7.12 # Patch version must be specified to avoid any cache confusion, since the cache key depends on the full Python version. Any potentiel difference in patches between jobs will lead to a cache not found error. - name: Cache build id: restore-build uses: actions/cache@v2 @@ -121,11 +121,12 @@ jobs: with: python-version: 3.7.12 - id: stop-early - run: "${GITHUB_WORKSPACE}/.github/has-functional-changes.sh" + run: if "${GITHUB_WORKSPACE}/.github/has-functional-changes.sh" ; then echo "::set-output name=status::success" ; fi deploy: runs-on: ubuntu-latest needs: [ check-for-functional-changes ] + if: needs.check-for-functional-changes.outputs.status == 'success' env: PYPI_USERNAME: openfisca-bot PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} From 2eba6526794bea44817ff96aa1cf77cd17de0c96 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Tue, 19 Oct 2021 14:23:22 +0200 Subject: [PATCH 41/42] Rename build and release cache keys --- .github/workflows/workflow.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index b2a169be..f32bf232 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -17,18 +17,18 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.pythonLocation }} - key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.sha }} # Cache the entire build Python environment + key: build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }} # Cache the entire build Python environment restore-keys: | - ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }} - ${{ env.pythonLocation }}-build- + build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }} + build-${{ env.pythonLocation }}- - name: Build package run: make build - - name: Cache build release - id: restore-build-release + - name: Cache release + id: restore-release uses: actions/cache@v2 with: path: dist - key: ${{ env.pythonLocation }}-release-build-${{ hashFiles('setup.py') }}-${{ github.sha }} + key: release-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }} lint-files: runs-on: ubuntu-latest @@ -46,7 +46,7 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.pythonLocation }} - key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.sha }} + key: build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }} - run: make check-syntax-errors - run: make check-style - name: Lint Python files @@ -68,7 +68,7 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.pythonLocation }} - key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.sha }} + key: build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }} - run: openfisca test --country-package openfisca_country_template openfisca_country_template/tests test-api: @@ -85,7 +85,7 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.pythonLocation }} - key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.sha }} + key: build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }} - name: Test the Web API run: "${GITHUB_WORKSPACE}/.github/test-api.sh" @@ -143,13 +143,13 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.pythonLocation }} - key: ${{ env.pythonLocation }}-build-${{ hashFiles('setup.py') }}-${{ github.sha }} - - name: Cache build release - id: restore-build-release + key: build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }} + - name: Cache release + id: restore-release uses: actions/cache@v2 with: path: dist - key: ${{ env.pythonLocation }}-release-build-${{ hashFiles('setup.py') }}-${{ github.sha }} + key: release-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }} - name: Upload a Python package to PyPi run: twine upload dist/* --username $PYPI_USERNAME --password $PYPI_PASSWORD - name: Publish a git tag From b1dc0c63b10e39f77aa2e2deb32b56842e4acf6c Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Thu, 21 Oct 2021 11:51:13 +0200 Subject: [PATCH 42/42] Update CHANGELOG --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72fc20a2..c2ba2bcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 3.13.0 - [#115](https://github.com/openfisca/country-template/pull/115) + +* Technical improvement. +* Details: + - Switch continuous integration pipeline from CircleCI to GitHub Actions + ### 3.12.10 - [#119](https://github.com/openfisca/country-template/pull/119) * Technical improvement.