-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored OpenFisca rules as code to download tagged versions of the…
… Country Template instead of manually managing Country Template package and rules
- Loading branch information
1 parent
ece51de
commit 6f6b17b
Showing
46 changed files
with
73 additions
and
1,484 deletions.
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 |
---|---|---|
@@ -1,6 +1,39 @@ | ||
name: Deploy images | ||
|
||
on: | ||
- push | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
delploy: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker image | ||
id: meta_openfisca | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ./images/rules-as-code | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: ${{ steps.meta_openfisca.outputs.tags }} |
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,26 +1,26 @@ | ||
FROM uselagoon/python-3.9:latest as build | ||
FROM uselagoon/python-3.11:latest | ||
|
||
WORKDIR /app/ | ||
|
||
RUN apk add gcc libc-dev g++ linux-headers yaml-dev | ||
RUN pip wheel --wheel-dir=/app/wheel numpy==1.20.* numexpr==2.8.* psutil PyYAML | ||
|
||
|
||
FROM uselagoon/python-3.9:latest | ||
ENV COUNTRY_TEMPLATE_VERSION=6.0.1 | ||
ENV OPENFISCA_CORE_VERSION=41.4.1 | ||
ENV COUNTRY_NAME=rules | ||
|
||
EXPOSE 3000 | ||
WORKDIR /app | ||
|
||
ARG PROJECT_NAME=rule | ||
COPY openfisca_$PROJECT_NAME /app/openfisca_$PROJECT_NAME | ||
COPY README.md setup.cfg setup.py /app/ | ||
# Install OpenFisca-Core dependencies | ||
RUN apk add build-base linux-headers yaml-dev | ||
|
||
WORKDIR /app/ | ||
# Install OpenFisca-Core | ||
RUN pip install OpenFisca-Core[web-api]==$OPENFISCA_CORE_VERSION | ||
|
||
COPY --from=build /app/ /app/ | ||
COPY README.md /app/openfisca_$PROJECT_NAME | ||
RUN apk add gcc libc-dev g++ linux-headers yaml-dev libffi-dev | ||
RUN pip install --no-index --find-links=/app/wheel numpy numexpr psutil PyYAML | ||
RUN pip install -e /app | ||
# Install country-template | ||
ADD https://github.com/openfisca/country-template/archive/refs/tags/$COUNTRY_TEMPLATE_VERSION.tar.gz /app | ||
RUN tar -xzf /app/$COUNTRY_TEMPLATE_VERSION.tar.gz -C /app && \ | ||
rm /app/$COUNTRY_TEMPLATE_VERSION.tar.gz && \ | ||
mv /app/country-template-$COUNTRY_TEMPLATE_VERSION /app/country-template | ||
|
||
# Copy bootstrap.sh to country-template and run it | ||
COPY bootstrap.sh /app | ||
RUN . /app/bootstrap.sh | ||
|
||
ENTRYPOINT ["openfisca", "serve", "--bind", "0.0.0.0:3000"] |
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,23 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
lowercase_country_name=$(echo $COUNTRY_NAME | tr '[:upper:]' '[:lower:]') | ||
|
||
mv country-template openfisca-$lowercase_country_name | ||
cd openfisca-$lowercase_country_name | ||
all_module_files=`find openfisca_country_template -type f ! -name "*.DS_Store"` | ||
|
||
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" setup.py setup.cfg Makefile MANIFEST.in $all_module_files | ||
sed -i.template "s|Country-Template|$COUNTRY_NAME|g" setup.py $all_module_files | ||
find . -name "*.template" -type f -delete | ||
|
||
set +x | ||
|
||
mv openfisca_country_template openfisca_$lowercase_country_name | ||
|
||
# Install OpenFisca country template | ||
pip install -e . |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
images/rules-as-code/openfisca_rules/parameters/benefits/basic_income.yaml
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
images/rules-as-code/openfisca_rules/parameters/benefits/housing_allowance.yaml
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
images/rules-as-code/openfisca_rules/parameters/benefits/index.yaml
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
images/rules-as-code/openfisca_rules/parameters/benefits/parenting_allowance/amount.yaml
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
...les-as-code/openfisca_rules/parameters/benefits/parenting_allowance/income_threshold.yaml
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
images/rules-as-code/openfisca_rules/parameters/general/age_of_majority.yaml
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
images/rules-as-code/openfisca_rules/parameters/general/age_of_retirement.yaml
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
images/rules-as-code/openfisca_rules/parameters/taxes/housing_tax.yaml
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
images/rules-as-code/openfisca_rules/parameters/taxes/income_tax_rate.yaml
This file was deleted.
Oops, something went wrong.
40 changes: 0 additions & 40 deletions
40
images/rules-as-code/openfisca_rules/parameters/taxes/social_security_contribution.yaml
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.