-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch from CircleCI to GitHub Actions
Merge pull request #115 from openfisca/github-actions
- Loading branch information
Showing
11 changed files
with
194 additions
and
126 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
.circleci/has-functional-changes.sh → .github/has-functional-changes.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#! /usr/bin/env bash | ||
|
||
last_tagged_commit=`git describe --tags --abbrev=0 --first-parent` # --first-parent ensures we don't follow tags not published in master through an unlikely intermediary merge commit | ||
|
||
if ! changes=$(git diff-index --name-only --diff-filter=ACMR --exit-code $last_tagged_commit -- "*.py") | ||
then | ||
echo "Linting the following Python files:" | ||
echo $changes | ||
flake8 $changes | ||
else echo "No changed Python files to lint" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#! /usr/bin/env bash | ||
|
||
last_tagged_commit=`git describe --tags --abbrev=0 --first-parent` # --first-parent ensures we don't follow tags not published in master through an unlikely intermediary merge commit | ||
|
||
if ! changes=$(git diff-index --name-only --diff-filter=ACMR --exit-code $last_tagged_commit -- "tests/*.yaml") | ||
then | ||
echo "Linting the following changed YAML tests:" | ||
echo $changes | ||
yamllint $changes | ||
else echo "No changed YAML tests to lint" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 | ||
- 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 | ||
|
||
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters