-
Notifications
You must be signed in to change notification settings - Fork 16
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
Automate template setup process via CI for GitHub users #143
Merged
Merged
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
25f6f85
Allow to bypass steps on CI with `CI` env variable
Ndpnt c29c903
Avoid modifying main workflow in bootstrap script
Ndpnt 5f54fae
Perform bootstrapping when used as GitHub template
Ndpnt 176574b
Use a less technical naming for better accessibility
Ndpnt 668beab
Update documentation
Ndpnt 00260ce
Unify commit message with first-time-setup script
Ndpnt 4361f2a
Decompose monolithic workflow into specialized workflows
Ndpnt a6d1175
Remove obsolete dependency
Ndpnt 24d6c03
Update job condition
Ndpnt 721d53f
Add changelog entry
Ndpnt ee2baed
Update version
Ndpnt 90a7d70
Improve documentation
Ndpnt 6397718
Title case the jurisdiction name
Ndpnt 7b3e90f
Allow to manually trigger first time setup workflow
Ndpnt de9206f
Improve documentation
Ndpnt e1924a8
Remove spaces
Ndpnt fd141ad
Fix typos and improve some phrasings
MattiSG c906b86
Improve wording
Ndpnt 5c65f27
Fix condition
Ndpnt dcec073
Unify syntax
Ndpnt fdeb428
Add comment
Ndpnt 6b5f74d
Delete file via Git to ensure the removal will be committed
Ndpnt 718255e
Merge remote-tracking branch 'openfisca/main'
Ndpnt 93bb53e
Update stefanzweifel/git-auto-commit-action to v5
Ndpnt 1238ffb
Remove obsolete IDs
Ndpnt faea0bc
Improve naming
Ndpnt 01be175
Remove obsolete checkout option
Ndpnt 0dcdbcf
Remove manual trigger on `build` and `validate` workflows
Ndpnt 4130dfe
Update Ubuntu to `v22.04` on CI
Ndpnt 7d13315
Update CI dependency `actions/setup-python` to `v5`
Ndpnt b3e4ebb
Update Python to `v3.9.12` on CI
Ndpnt 71b05d3
Update CI dependency `actions/checkout` to `v4`
Ndpnt 830be46
Update CI dependency `actions/cache` to `v4`
Ndpnt ce8f18d
Merge pull request #11 from Ndpnt/update-actions-dependencies
Ndpnt 6df2cb8
Update changelog
Ndpnt 3e01209
Improve copywriting
MattiSG 5b43f1a
Fix step name
Ndpnt 50b8408
Trigger deployment on any push to `main`
Ndpnt dd4f13b
Simplify code
Ndpnt 3f35133
Use consistent line breaks across workflows
Ndpnt 73ba03b
Reduce logs
Ndpnt e70eaf8
Improve job name
Ndpnt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Build | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
build-and-cache: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.9.12 # Patch version must be specified to avoid any cache confusion, since the cache key depends on the full Python version. Any difference in patches between jobs will lead to a cache not found error. | ||
|
||
- name: Cache build | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ env.pythonLocation }} | ||
key: build-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }} # Cache the entire build Python environment | ||
restore-keys: | | ||
build-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }} | ||
build-${{ env.pythonLocation }}- | ||
|
||
- name: Build package | ||
run: make build | ||
|
||
- name: Cache release | ||
uses: actions/cache@v4 | ||
with: | ||
path: dist | ||
key: release-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Deploy | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
jobs: | ||
validate: | ||
uses: "./.github/workflows/validate.yml" | ||
|
||
# GitHub Actions does not have a halt job option to stop from deploying if no functional changes were found. | ||
# We thus execute a separate deployment job depending on the output of this job. | ||
check-for-functional-changes: | ||
runs-on: ubuntu-22.04 | ||
outputs: | ||
status: ${{ steps.stop-early.outputs.status }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Fetch all the tags | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.9.12 | ||
- id: stop-early | ||
run: if "${GITHUB_WORKSPACE}/.github/has-functional-changes.sh" ; then echo "::set-output name=status::success" ; fi | ||
|
||
deploy: | ||
runs-on: ubuntu-22.04 | ||
needs: [ validate, check-for-functional-changes ] | ||
if: needs.check-for-functional-changes.outputs.status == 'success' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.9.12 | ||
- name: Restore build | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ env.pythonLocation }} | ||
key: build-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }} | ||
- name: Restore built package | ||
uses: actions/cache@v4 | ||
with: | ||
path: dist | ||
key: release-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }} | ||
- name: Upload a Python package to PyPi | ||
run: twine upload dist/* --username __token__ --password ${{ secrets.PYPI_TOKEN_OPENFISCA_BOT }} | ||
- name: Publish a git tag | ||
run: "${GITHUB_WORKSPACE}/.github/publish-git-tag.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: First time setup | ||
|
||
on: | ||
create: | ||
workflow_dispatch: | ||
|
||
permissions: | ||
actions: write | ||
checks: write | ||
contents: write | ||
|
||
jobs: | ||
first-time-setup: | ||
# Ensure this job does not run on the template repository or when the repository is forked | ||
if: ${{ !github.event.repository.is_template && !github.event.repository.fork }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
Ndpnt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- name: Infer jurisdiction name from repository name | ||
run: | | ||
echo "TITLE_CASE_JURISDICTION_NAME=$(echo ${{ github.event.repository.name }} | sed 's/openfisca-//' | sed 's/[-|_]/ /g' | awk '{for (i=1; i<=NF; i++) $i=toupper(substr($i,1,1)) substr($i,2)} 1')" >> $GITHUB_ENV | ||
|
||
- name: Execute the first-time-setup script | ||
run: CI=true JURISDICTION_NAME="$TITLE_CASE_JURISDICTION_NAME" REPOSITORY_URL="${{ github.repositoryUrl }}" ./first-time-setup.sh | ||
|
||
- name: Commit changes | ||
uses: stefanzweifel/git-auto-commit-action@v5 | ||
with: | ||
commit_message: "Customise country-template through CI" | ||
tagging_message: "0.0.1" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
name: Validate | ||
|
||
on: | ||
pull_request: | ||
types: [ assigned, opened, reopened, synchronize, ready_for_review ] | ||
workflow_call: | ||
|
||
jobs: | ||
build: | ||
uses: "./.github/workflows/build.yml" | ||
|
||
lint-files: | ||
runs-on: ubuntu-22.04 | ||
needs: [ build ] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Fetch all the tags | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.9.12 | ||
|
||
- name: Restore build | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ env.pythonLocation }} | ||
key: build-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }} | ||
|
||
- 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-22.04 | ||
needs: [ build ] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.9.12 | ||
|
||
- name: Restore build | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ env.pythonLocation }} | ||
key: build-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }} | ||
|
||
- run: make test | ||
|
||
test-api: | ||
runs-on: ubuntu-22.04 | ||
needs: [ build ] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.9.12 | ||
|
||
- name: Restore build | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ env.pythonLocation }} | ||
key: build-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }} | ||
|
||
- name: Test the Web API | ||
run: "${GITHUB_WORKSPACE}/.github/test-api.sh" | ||
|
||
check-version-and-changelog: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Fetch all the tags | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.9.12 | ||
|
||
- name: Check version number has been properly updated | ||
run: "${GITHUB_WORKSPACE}/.github/is-version-number-acceptable.sh" |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.