Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from CircleCI to GitHub Actions #115

Merged
merged 42 commits into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
14fbb3d
Add Github Actions config
HAEKADI Sep 2, 2021
aeca6c3
Correct lint errors
HAEKADI Sep 2, 2021
2361b2b
Add openfisca tests path
HAEKADI Sep 2, 2021
2d605cf
Correct openfisca test path
HAEKADI Sep 2, 2021
f6b3379
Corrent worfklow lint errors
HAEKADI Sep 2, 2021
378b748
Correct linting errors
HAEKADI Sep 2, 2021
7ab9932
Add linting scripts
HAEKADI Sep 2, 2021
62a10fd
Delete comment
HAEKADI Sep 2, 2021
5b42f60
Test linting solution
HAEKADI Sep 8, 2021
3a98085
Remove install job
HAEKADI Sep 15, 2021
eff777d
Cache dist directory
HAEKADI Sep 15, 2021
25bf218
Add dist cache to deploy
HAEKADI Sep 15, 2021
228d9bb
Remove circleci files
HAEKADI Sep 15, 2021
bc0c1c0
Fix yaml bug
HAEKADI Sep 15, 2021
1f2fba4
Add branch ref to cache key
HAEKADI Sep 22, 2021
bfb5496
Add super-linter
HAEKADI Sep 22, 2021
e87fd12
Delete linting scripts
HAEKADI Sep 22, 2021
d88a3ae
Revert "Add super-linter"
HAEKADI Sep 23, 2021
6f6c140
Revert "Delete linting scripts"
HAEKADI Sep 23, 2021
46af0dc
Update changelog
HAEKADI Sep 23, 2021
3272c75
Fix syntax error in shell script
HAEKADI Sep 23, 2021
4b4f4e8
Add branch ref to cache in deploy
HAEKADI Sep 23, 2021
7678037
Remove pipe in test-yaml
HAEKADI Sep 23, 2021
d07845a
Remove quotes
HAEKADI Sep 23, 2021
0bfc045
Remove circleci mention
HAEKADI Sep 23, 2021
0a34b7b
Remove step output from check-for-functional-changes
HAEKADI Sep 23, 2021
dfe5bad
Update changelog
HAEKADI Sep 23, 2021
b751977
Change deploy branch to master
HAEKADI Sep 23, 2021
640ba01
Remove pypi password comment
HAEKADI Sep 23, 2021
06472a6
Specify Python version patch
HAEKADI Sep 23, 2021
a49f39f
Update CHANGELOG details
HAEKADI Sep 24, 2021
c626cd9
Update changelog
HAEKADI Sep 24, 2021
337a558
Rename workflow when executing bootstrap script
HAEKADI Sep 24, 2021
510af1f
Delete cache hit condition
HAEKADI Sep 30, 2021
58092b6
Add commit SHA to cache key
HAEKADI Sep 30, 2021
5aa082c
Change expression order in cache key
HAEKADI Sep 30, 2021
b24e584
Add restore keys to build cache
HAEKADI Sep 30, 2021
35c7ce0
Remove branch ref from cache key
HAEKADI Sep 30, 2021
dddfdf4
Add Python patch comment
HAEKADI Oct 18, 2021
b1d485a
Add step output condition to deploy
HAEKADI Oct 19, 2021
2eba652
Rename build and release cache keys
HAEKADI Oct 19, 2021
b1dc0c6
Update CHANGELOG
HAEKADI Oct 21, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 0 additions & 117 deletions .circleci/config.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#! /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
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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /usr/bin/env bash

if [[ $CIRCLE_BRANCH == master ]]
if [[ ${GITHUB_REF#refs/heads/} == master ]]
then
echo "No need for a version check on master."
exit 0
Expand All @@ -12,7 +12,7 @@ then
exit 0
fi

current_version=`python setup.py --version`
current_version=$(python setup.py --version)

if git rev-parse --verify --quiet $current_version
then
Expand Down
11 changes: 11 additions & 0 deletions .github/lint-changed-python-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! /usr/bin/env bash

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

if ! changes=$(git diff-index --name-only --diff-filter=ACMR --exit-code $last_tagged_commit -- "*.py")
then
echo "Linting the following Python files:"
echo $changes
flake8 $changes
else echo "No changed Python files to lint"
fi
11 changes: 11 additions & 0 deletions .github/lint-changed-yaml-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! /usr/bin/env bash

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

if ! changes=$(git diff-index --name-only --diff-filter=ACMR --exit-code $last_tagged_commit -- "tests/*.yaml")
then
echo "Linting the following changed YAML tests:"
echo $changes
yamllint $changes
else echo "No changed YAML tests to lint"
fi
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
156 changes: 156 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
name: Country-Template

on: [ push ]

jobs:
build:
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.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
with:
path: ${{ env.pythonLocation }}
key: build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }} # Cache the entire build Python environment
restore-keys: |
build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}
build-${{ env.pythonLocation }}-
- name: Build package
run: make build
- name: Cache release
id: restore-release
uses: actions/cache@v2
with:
path: dist
key: release-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }}

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.12
HAEKADI marked this conversation as resolved.
Show resolved Hide resolved
- name: Cache build
id: restore-build
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }}
- 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
needs: [ build ]
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7.12
- name: Cache build
id: restore-build
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }}
- run: openfisca test --country-package openfisca_country_template openfisca_country_template/tests

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.12
- name: Cache build
id: restore-build
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }}
- 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.12
- 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.12
- id: stop-early
run: if "${GITHUB_WORKSPACE}/.github/has-functional-changes.sh" ; then echo "::set-output name=status::success" ; fi
HAEKADI marked this conversation as resolved.
Show resolved Hide resolved

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 }}
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.12
- name: Cache build
id: restore-build
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }}
- name: Cache release
id: restore-release
uses: actions/cache@v2
with:
path: dist
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
run: "${GITHUB_WORKSPACE}/.github/publish-git-tag.sh"
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Changelog

### 3.12.10 - [#115](https://github.com/openfisca/country-template/pull/115)
## 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.
* Details:
Expand Down
5 changes: 3 additions & 2 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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|$COUNTRY_NAME|g" README.md setup.py .github/PULL_REQUEST_TEMPLATE.md CONTRIBUTING.md $all_module_files
# 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
HAEKADI marked this conversation as resolved.
Show resolved Hide resolved
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/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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down