From da3bcdfcd44c52adef2cfac2b336d271fa5311c0 Mon Sep 17 00:00:00 2001 From: Tero Virtanen <105207219+terovirtanen@users.noreply.github.com> Date: Tue, 12 Mar 2024 11:09:34 +0200 Subject: [PATCH] build: pipeline upgrade (#473) * fix: set allowed data fields, moved from pipeline definition to application OH-57 * fix: proposal on pr review --- docker-compose.env.yaml.example | 1 + docker-entrypoint.sh | 5 ++ .../configuration/allowed_data_fields.json | 54 ++++++++++++++++++ pipelines/helsinki-profile-api-dev.yml | 52 +++++++++++++++++ pipelines/helsinki-profile-api-release.yml | 49 ++++++++++++++++ pipelines/helsinki-profile-api-review.yml | 57 +++++++++++++++++++ 6 files changed, 218 insertions(+) create mode 100644 open_city_profile/configuration/allowed_data_fields.json create mode 100644 pipelines/helsinki-profile-api-dev.yml create mode 100644 pipelines/helsinki-profile-api-release.yml create mode 100644 pipelines/helsinki-profile-api-review.yml diff --git a/docker-compose.env.yaml.example b/docker-compose.env.yaml.example index ce2582c5..300529eb 100644 --- a/docker-compose.env.yaml.example +++ b/docker-compose.env.yaml.example @@ -3,6 +3,7 @@ DEBUG=1 APPLY_MIGRATIONS=1 CREATE_SUPERUSER=1 SEED_DEVELOPMENT_DATA=0 +SET_ALLOWED_DATA_FIELDS=0 OIDC_CLIENT_ID= OIDC_CLIENT_SECRET= diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 234d28ee..ceb040e1 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -23,6 +23,11 @@ if [[ "$APPLY_MIGRATIONS" = "1" ]] && [[ "$SEED_DEVELOPMENT_DATA" = "1" ]]; then ./manage.py seed_development_data fi +if [[ "$SET_ALLOWED_DATA_FIELDS" = "1" ]]; then + echo "Set allowed data fields..." + ./manage.py set_allowed_data_fields < open_city_profile/configuration/allowed_data_fields.json +fi + # Create superuser if [[ "$CREATE_SUPERUSER" = "1" ]]; then ./manage.py add_admin_user -u admin -p admin -e admin@example.com diff --git a/open_city_profile/configuration/allowed_data_fields.json b/open_city_profile/configuration/allowed_data_fields.json new file mode 100644 index 00000000..cdf3f012 --- /dev/null +++ b/open_city_profile/configuration/allowed_data_fields.json @@ -0,0 +1,54 @@ +[ + { + "field_name": "name", + "translations": [ + {"code": "en", "label": "Name"}, + {"code": "fi", "label": "Nimi"}, + {"code": "sv", "label": "Namn"} + ] + }, + { + "field_name": "personalidentitycode", + "translations": [ + {"code": "en", "label": "Personal identity code"}, + {"code": "fi", "label": "Henkilötunnus"}, + {"code": "sv", "label": "Personbeteckning"} + ], + "aliases": ["Personal_identity_code", "ssn"] + }, + { + "field_name": "address", + "translations": [ + {"code": "en", "label": "Addresses"}, + {"code": "fi", "label": "Osoitteet"}, + {"code": "sv", "label": "Adresser"} + ], + "aliases": ["addresses"] + }, + { + "field_name": "municipalityofresidence", + "translations": [ + {"code": "en", "label": "Municipality of residence"}, + {"code": "fi", "label": "Kotikunta"}, + {"code": "sv", "label": "Hemkommun"} + ], + "aliases": ["homemunicipality", "Municipality_of_residence"] + }, + { + "field_name": "phone", + "translations": [ + {"code": "en", "label": "Phone numbers"}, + {"code": "fi", "label": "Puhelinnumerot"}, + {"code": "sv", "label": "Telefonnummer"} + ], + "aliases": ["phones"] + }, + { + "field_name": "email", + "translations": [ + {"code": "en", "label": "Emails"}, + {"code": "fi", "label": "Sähköpostiosoitteet"}, + {"code": "sv", "label": "E-postadresser"} + ] + } +] diff --git a/pipelines/helsinki-profile-api-dev.yml b/pipelines/helsinki-profile-api-dev.yml new file mode 100644 index 00000000..0229a471 --- /dev/null +++ b/pipelines/helsinki-profile-api-dev.yml @@ -0,0 +1,52 @@ +# Continuous integration (CI) triggers cause a pipeline to run whenever you push +# an update to the specified branches or you push specified tags. +trigger: + batch: true + branches: + include: + - main + paths: + exclude: + - '*release-please*' + - '*.md' + - '.github/' + - 'pipelines/helsinki-profile-api-release.yml' + - 'pipelines/helsinki-profile-api-review.yml' + - 'docker-compose*' + +# Pull request (PR) triggers cause a pipeline to run whenever a pull request is +# opened with one of the specified target branches, or when updates are made to +# such a pull request. +# +# GitHub creates a new ref when a pull request is created. The ref points to a +# merge commit, which is the merged code between the source and target branches +# of the pull request. +# +# Opt out of pull request validation +pr: none + +# By default, use self-hosted agents +pool: Default + +resources: + repositories: + # Azure DevOps repository + - repository: helsinki-profile-api + type: git + # Azure DevOps project/repository + name: helsinki-profile-api-ops/helsinki-profile-api + +extends: + # Filename in Azure DevOps Repository + template: azure-pipelines-helsinki-profile-api-dev.yml@helsinki-profile-api + # parameters: + # Application build arguments and config map values as key value pairs. + # Does not contain all buildArguments or configMap values, the rest located in helsinki-profile-api + # Default value to pythonVersion is set on template. + # The values here will override the values defined in the helsinki-profile-api repository + # buildArgs: + # DEBUG: 1 + # configMap: # pod environment variables + # DEBUG: 1 + ## Used tool version + # pythonVersion: 3.11 diff --git a/pipelines/helsinki-profile-api-release.yml b/pipelines/helsinki-profile-api-release.yml new file mode 100644 index 00000000..896db945 --- /dev/null +++ b/pipelines/helsinki-profile-api-release.yml @@ -0,0 +1,49 @@ +# Continuous integration (CI) triggers cause a pipeline to run whenever you push +# an update to the specified branches or you push specified tags. +trigger: + batch: true + tags: + include: + - open-city-profile-v* + +# Pull request (PR) triggers cause a pipeline to run whenever a pull request is +# opened with one of the specified target branches, or when updates are made to +# such a pull request. +# +# GitHub creates a new ref when a pull request is created. The ref points to a +# merge commit, which is the merged code between the source and target branches +# of the pull request. +# +# Opt out of pull request validation +pr: none + +# By default, use self-hosted agents +pool: Default + +resources: + repositories: + # Azure DevOps repository + - repository: helsinki-profile-api + type: git + # Azure DevOps project/repository + name: helsinki-profile-api-ops/helsinki-profile-api + +extends: + # Filename in Azure DevOps Repository + template: azure-pipelines-helsinki-profile-api-release.yml@helsinki-profile-api + # parameters: + # Application build arguments and config map values as key value pairs. + # Does not contain all buildArguments or configMap values, the rest located in helsinki-profile-api + # Default value to pythonVersion is set on template. + # The values here will override the values defined in the helsinki-profile-api repository + ## Staging definitions + # buildArgsStage: + # DEBUG: 1 + # configMapStage: # pod environment variables + # DEBUG: 1 + ## Production definitions + ## Production is using staging image + # configMap: # pod environment variables + # DEBUG: 1 + ## Used tool version + # pythonVersion: 3.11 diff --git a/pipelines/helsinki-profile-api-review.yml b/pipelines/helsinki-profile-api-review.yml new file mode 100644 index 00000000..d9ce345f --- /dev/null +++ b/pipelines/helsinki-profile-api-review.yml @@ -0,0 +1,57 @@ +# +# Review pipeline. Run build and deploy for Platta dev environments. +# Pipeline runs different tests e.g. unittest and browser tests. +# +# Continuous integration (CI) triggers cause a pipeline to run whenever you push +# an update to the specified branches or you push specified tags. +# only PR trigger pipeline +trigger: none + +# Pull request (PR) triggers cause a pipeline to run whenever a pull request is +# opened with one of the specified target branches, or when updates are made to +# such a pull request. +# +# GitHub creates a new ref when a pull request is created. The ref points to a +# merge commit, which is the merged code between the source and target branches +# of the pull request. +# +# Opt out of pull request validation +pr: + # PR target branch + branches: + include: + - main + paths: + exclude: + - '*release-please*' + - '*.md' + - '.github/' + - 'pipelines/helsinki-profile-api-release.yml' + - 'pipelines/helsinki-profile-api-dev.yml' + - 'docker-compose*' + +# By default, use self-hosted agents +pool: Default + +resources: + repositories: + # Azure DevOps repository + - repository: helsinki-profile-api + type: git + # Azure DevOps project/repository + name: helsinki-profile-api-ops/helsinki-profile-api + +extends: + # Filename in Azure DevOps Repository + template: azure-pipelines-helsinki-profile-api-review.yml@helsinki-profile-api + # parameters: + # Application build arguments and config map values as key value pairs. + # Does not contain all buildArguments or configMap values, the rest located in helsinki-profile-api + # Default value to pythonVersion is set on template. + # The values here will override the values defined in the helsinki-profile-api repository + # buildArgs: + # DEBUG: 1 + # configMap: # pod environment variables + # DEBUG: 1 + ## Used tool version + # pythonVersion: 3.11