Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: pagopa/pagopa-taxonomy
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.0.3
Choose a base ref
...
head repository: pagopa/pagopa-taxonomy
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
  • 16 commits
  • 20 files changed
  • 3 contributors

Commits on Oct 19, 2023

  1. fix

    aomegax committed Oct 19, 2023
    Copy the full SHA
    8ab724b View commit details
  2. Merge pull request #24 from pagopa/fix-runner-cd

    fix runner
    aomegax authored Oct 19, 2023
    Copy the full SHA
    ec37087 View commit details
  3. Copy the full SHA
    143c331 View commit details
  4. fix

    aomegax committed Oct 19, 2023
    Copy the full SHA
    7262739 View commit details
  5. Copy the full SHA
    4379b91 View commit details
  6. Merge pull request #25 from pagopa/fix-cd-pipe

    fix cd
    aomegax authored Oct 19, 2023
    Copy the full SHA
    bd8a1f8 View commit details
  7. Copy the full SHA
    d495a6b View commit details

Commits on Oct 20, 2023

  1. Changed CSV headers and tests. Added openapi.json and new response me…

    …ssage for the /info endpoint
    andrea-barchi committed Oct 20, 2023
    Copy the full SHA
    24ba3d7 View commit details
  2. Fixed smell

    andrea-barchi committed Oct 20, 2023
    Copy the full SHA
    bc4b233 View commit details
  3. Fixed smell

    andrea-barchi committed Oct 20, 2023
    Copy the full SHA
    528b45f View commit details
  4. Merge pull request #26 from pagopa/NOD-554-tassonomia-modifica-acquis…

    …izione-tracciato-csv
    
    fix: [NOD-554] Changed CSV headers and tests. Added openapi.json and new response me…
    aomegax authored Oct 20, 2023
    Copy the full SHA
    9fe357f View commit details
  5. Copy the full SHA
    566405f View commit details

Commits on Oct 24, 2023

  1. Copy the full SHA
    243c397 View commit details

Commits on Oct 25, 2023

  1. Fixed smells

    andrea-barchi committed Oct 25, 2023
    Copy the full SHA
    608f6b7 View commit details

Commits on Nov 27, 2023

  1. Merge pull request #27 from pagopa/optimization

    Optimized taxonomy retrieval
    aomegax authored Nov 27, 2023
    Copy the full SHA
    c05ba84 View commit details
  2. Bump to version 1.1.2 [skip ci]

    pagopa-github-bot committed Nov 27, 2023
    Copy the full SHA
    6b29e74 View commit details
132 changes: 48 additions & 84 deletions .github/workflows/04_release_deploy.yml
Original file line number Diff line number Diff line change
@@ -62,20 +62,34 @@ jobs:
runs-on: ubuntu-latest
outputs:
semver: ${{ steps.semver_setup.outputs.semver }}
environment: ${{ steps.output.outputs.environment }}
environment: ${{ steps.semver_setup.outputs.environment }}
resource_group: ${{ steps.get_rg.outputs.resource_group }}
app_name: ${{ steps.get_appname.outputs.app_name }}
steps:
- name: Semver setup
id: semver_setup
uses: pagopa/github-actions-template/nodo5-semver-setup@ce252c8501c9242bd6045f7cdd650736b2f38777
with:
semver: ${{ inputs.semver }}

# Set deploy variables
- run: echo "ENV_SHORT=$(echo ${{steps.semver_setup.outputs.environment}} | cut -c1-1)" >> $GITHUB_ENV

- id: get_rg
name: Set Resource Group
run: echo "resource_group=pagopa-${{env.ENV_SHORT}}-weu-shared-txnm-rg" >> $GITHUB_OUTPUT

- id: get_appname
name: Set App Name
run: echo "app_name=pagopa-${{env.ENV_SHORT}}-weu-shared-txnm-fn" >> $GITHUB_OUTPUT

release:
name: Create a New Release
runs-on: ubuntu-latest
needs: [ setup ]
outputs:
version: ${{ steps.release.outputs.version }}
registry_image: ${{ steps.get_image.outputs.registry_image }}
steps:
- name: Make Release
id: release
@@ -85,9 +99,13 @@ jobs:
github_token: ${{ secrets.BOT_TOKEN_GITHUB }}
beta: false

- name: Set image name from container registry
id: get_image
run: echo "registry_image=ghcr.io/pagopa/pagopa-taxonomy:${{steps.release.outputs.version}}" >> $GITHUB_OUTPUT

build-and-push:
needs: [ setup, release ]
name: Build and Push Docker Image
needs: [ setup, release ]
runs-on: ubuntu-latest
if: ${{ needs.setup.outputs.semver != 'skip' }}
environment: ${{ needs.setup.outputs.environment }}
@@ -102,89 +120,35 @@ jobs:

deploy_azure_fn:
name: Deploy Azure function
environment: ${{ needs.setup.outputs.environment }}
needs: [ setup, release, build-and-push ]
runs-on: ubuntu-latest
if: ${{ always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
strategy:
matrix:
environment: [ dev, uat, prod ]
secrets: inherit
uses: ./.github/workflows/04_self_hosted.yml
with:
environment: ${{ matrix.environment }}
target: ${{ needs.setup.outputs.environment }}
resource_group: ${{ needs.setup.outputs.resource_group }}
app_name: ${{ needs.setup.outputs.app_name }}
registry_image: ${{ needs.release.outputs.registry_image }}

notify:
name: Notify
needs: [ setup, release, deploy_azure_fn ]
runs-on: ubuntu-latest
if: always()
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v3

- name: 'Login via Azure CLI'
uses: azure/login@v1
with:
client-id: ${{ secrets.CLIENT_ID }}
tenant-id: ${{ secrets.TENANT_ID }}
subscription-id: ${{ secrets.SUBSCRIPTION_ID }}

- name: Set env variables
run: |
ENV_SHORT=$(echo ${{needs.setup.outputs.environment}} | cut -c1-1)
echo "RESOURCE_GROUP=pagopa-$ENV_SHORT-weu-shared-txnm-rg" >> $GITHUB_ENV
echo "APP_NAME=pagopa-$ENV_SHORT-weu-shared-txnm-fn" >> $GITHUB_ENV
echo "REGISTRY_IMAGE=ghcr.io/pagopa/pagopa-taxonomy:${{needs.release.outputs.version}}" >> $GITHUB_ENV
- name: 'Azure CLI script: start staging slot'
uses: azure/CLI@v1
if: ${{ needs.setup.outputs.environment == 'prod' }}
with:
inlineScript: |
az functionapp start --name ${{ env.APP_NAME }} --resource-group ${{ env.RESOURCE_GROUP }} --slot staging
- name: 'Run Azure Functions Container Action: staging slot'
uses: Azure/functions-container-action@v1.2.1
if: ${{ needs.setup.outputs.environment == 'prod' }}
with:
app-name: ${{ env.APP_NAME }}
image: ${{ env.REGISTRY_IMAGE }}
slot-name: staging

- name: 'Deploy Approval'
uses: trstringer/manual-approval@v1
if: ${{ needs.setup.outputs.environment == 'prod' }}
- name: Report Status
if: always()
uses: ravsamhq/notify-slack-action@v2
with:
secret: ${{ secrets.BOT_TOKEN_GITHUB }}
approvers: pagopa-team-core
minimum-approvals: 1
issue-title: "Deploying ${{ env.TAG }} to prod from staging"
issue-body: "Please approve or deny the deployment of version ${{ env.TAG }}."
exclude-workflow-initiator-as-approver: false
timeout-minutes: 360

- name: 'Run Azure Functions Container Action'
uses: Azure/functions-container-action@v1.2.1
with:
app-name: ${{ env.APP_NAME }}
image: ${{ env.REGISTRY_IMAGE }}
slot-name: production

- name: 'Azure CLI script: end staging slot'
uses: azure/CLI@v1
if: ${{ needs.setup.outputs.environment == 'prod' }}
with:
inlineScript: |
az functionapp stop --name ${{ env.APP_NAME }} --resource-group ${{ env.RESOURCE_GROUP }} --slot staging
- name: Azure logout
run: |
az logout
# notify:
# needs: [ setup, release, deploy_azure_fn ]
# runs-on: ubuntu-latest
# name: Notify
# if: always()
# steps:
# - name: Report Status
# if: always()
# uses: ravsamhq/notify-slack-action@v2
# with:
# status: ${{ needs.deploy_azure_fn.result }}
# token: ${{ secrets.GITHUB_TOKEN }}
# notification_title: 'New Release on ${{ needs.setup.outputs.environment }} ${{ needs.release.outputs.version }} has {status_message}'
# message_format: '{emoji} <{run_url}|{workflow}> {status_message} in <{repo_url}|{repo}>'
# footer: 'Linked to <{workflow_url}| workflow file>'
# icon_success: ':white_check_mark:'
# env:
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
status: ${{ needs.deploy_azure_fn.result }}
token: ${{ secrets.GITHUB_TOKEN }}
notification_title: 'New Release on ${{ needs.setup.outputs.environment }} ${{ needs.release.outputs.version }} has {status_message}'
message_format: '{emoji} <{run_url}|{workflow}> {status_message} in <{repo_url}|{repo}>'
footer: 'Linked to <{workflow_url}| workflow file>'
icon_success: ':white_check_mark:'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
106 changes: 62 additions & 44 deletions .github/workflows/04_self_hosted.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Self Hosted Runner
name: Deploy Azure function

on:
workflow_call:
@@ -11,75 +11,93 @@ on:
required: true
description: The environment target of the job
type: string

env:
NAMESPACE: nodo
APP_NAME: pagopanodoretodatastore
resource_group:
required: true
description: The resource group of the function to deploy
type: string
app_name:
required: true
description: The name of the function to deploy
type: string
registry_image:
required: true
description: The name of the image from container registry to be used
type: string

permissions:
id-token: write
contents: read

jobs:
create_runner:
name: Create Runner
show_input:
runs-on: ubuntu-latest
if: ${{ inputs.target == inputs.environment }}
steps:
- name: Get input parameters
run: |
echo environment=${{ inputs.environment }}
echo target=${{ inputs.target }}
echo resource_group=${{ inputs.resource_group }}
echo app_name=${{ inputs.app_name }}
echo registry_image=${{ inputs.registry_image }}
# Starting the Azure Function's staging slot, if deploying in PROD
start_staging_slot:
name: Create staging slots
runs-on: ubuntu-22.04
if: ${{ inputs.target == inputs.environment && inputs.target == 'prod' }}
environment:
name: ${{ inputs.environment }}
if: ${{ inputs.target == inputs.environment || inputs.environment == 'all' }}
outputs:
runner_name: ${{ steps.create_github_runner.outputs.runner_name }}
steps:
- name: Create GitHub Runner
id: create_github_runner
# from https://github.com/pagopa/github-self-hosted-runner-azure-create-action/commits/main
uses: pagopa/github-self-hosted-runner-azure-create-action@v1.1.2
- name: Create staging slots
uses: pagopa/github-actions-template/azure-function-start-staging-slot@a1b72480e9ac555364be0b7ecdcc8f5ab1c89ad9
with:
branch: ${{ github.ref_name }}
client_id: ${{ secrets.CLIENT_ID }}
tenant_id: ${{ secrets.TENANT_ID }}
subscription_id: ${{ secrets.SUBSCRIPTION_ID }}
container_app_environment_name: ${{ secrets.CONTAINER_APP_ENVIRONMENT_NAME }}
resource_group_name: ${{ secrets.RUNNER_RESOURCE_GROUP_NAME }} # RG of the runner
pat_token: ${{ secrets.BOT_TOKEN_GITHUB }}
self_hosted_runner_image_tag: "v1.4.0"
resource_group: ${{ inputs.resource_group }}
app_name: ${{ inputs.app_name }}
registry_image: ${{ inputs.registry_image }}


# Executing the deploy of the Azure function with the new image
deploy:
needs: [ create_runner ]
runs-on: [ self-hosted, "${{ needs.create_runner.outputs.runner_name }}" ]
if: ${{ inputs.target == inputs.environment || inputs.environment == 'all' }}
name: Deploy
environment: ${{ inputs.environment }}
name: Deploy Azure Function
runs-on: ubuntu-22.04
needs: [ start_staging_slot ]
if: ${{ always() && inputs.target == inputs.environment }}
environment:
name: ${{ inputs.environment }}
steps:
- name: Deploy
uses: pagopa/github-actions-template/azure-functions-deploy@az-functions # TODO set tag after PR merge
- name: Deploy Azure Function
uses: pagopa/github-actions-template/azure-functions-deploy@a1b72480e9ac555364be0b7ecdcc8f5ab1c89ad9
with:
branch: ${{ github.ref_name }}
client_id: ${{ secrets.CLIENT_ID }}
subscription_id: ${{ secrets.SUBSCRIPTION_ID }}
tenant_id: ${{ secrets.TENANT_ID }}
env: ${{ inputs.environment }}
namespace: ${{ env.NAMESPACE }}
cluster_name: ${{ secrets.CLUSTER_NAME }}
resource_group: ${{ secrets.CLUSTER_RESOURCE_GROUP_NAME }}
app_name: ${{ env.APP_NAME }}

subscription_id: ${{ secrets.SUBSCRIPTION_ID }}
app_name: ${{ inputs.app_name }}
registry_image: ${{ inputs.registry_image }}


cleanup_runner:
name: Cleanup Runner
needs: [ create_runner, deploy ]
if: ${{ success() || failure() && inputs.target == inputs.environment || inputs.environment == 'all' }}
# Stopping the Azure Function's staging slot, if deploying in PROD
stop_staging_slot:
name: Clean staging slots
needs: [ start_staging_slot, deploy ]
if: ${{ success() || failure() && (inputs.target == inputs.environment && inputs.target == 'prod') }}
runs-on: ubuntu-22.04
environment: ${{ inputs.environment }}
environment:
name: ${{ inputs.environment }}
steps:
- name: Cleanup GitHub Runner
id: cleanup_github_runner
# from https://github.com/pagopa/github-self-hosted-runner-azure-cleanup-action/commits/main
uses: pagopa/github-self-hosted-runner-azure-cleanup-action@v1.0.3
- name: Deploy Azure Function
uses: pagopa/github-actions-template/azure-function-stop-staging-slot@a1b72480e9ac555364be0b7ecdcc8f5ab1c89ad9
with:
branch: ${{ github.ref_name }}
client_id: ${{ secrets.CLIENT_ID }}
tenant_id: ${{ secrets.TENANT_ID }}
subscription_id: ${{ secrets.SUBSCRIPTION_ID }}
resource_group_name: ${{ secrets.RUNNER_RESOURCE_GROUP_NAME }}
runner_name: ${{ needs.create_runner.outputs.runner_name }}
pat_token: ${{ secrets.BOT_TOKEN_GITHUB }}
resource_group: ${{ inputs.resource_group }}
app_name: ${{ inputs.app_name }}
registry_image: ${{ inputs.registry_image }}
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# pagoPA Functions taxonomy

Java Taxonomy Azure Function.
This function has the role of converting a CSV file to JSON and retrieve it from a blob storage whenever needed.
Taxonomy Azure Function.
This function has the role of converting a CSV file to JSON and then to retrieve it from a blob storage whenever needed.

[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=pagopa_pagopa-taxonomy&metric=alert_status)](https://sonarcloud.io/project/overview?id=pagopa_pagopa-taxonomy)

---

## Api Documentation 📖

Check out the [OpenApi 3 here](https://editor.swagger.io/?url=https://raw.githubusercontent.com/pagopa/pagopa-taxonomy/main/openapi/openapi.json)

---

2 changes: 1 addition & 1 deletion integration-test/features/Taxonomy_KO.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Feature: Taxonomy
Feature: Taxonomy KO

Scenario: No CSV file in the storage when trying to generate taxonomy
Given the infrastructure is up and running
2 changes: 1 addition & 1 deletion integration-test/features/Taxonomy_OK.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Feature: Taxonomy
Feature: Taxonomy OK

Scenario: Generate Taxonomy JSON
Given the infrastructure is up and running
4 changes: 3 additions & 1 deletion integration-test/features/config/config.json
Original file line number Diff line number Diff line change
@@ -5,6 +5,8 @@
"input_container_name": "input",
"output_container_name": "output",
"csv_blob_name": "taxonomy.csv",
"json_blob_name": "taxonomy.json"
"json_blob_name": "taxonomy_standard.json",
"taxonomy_csv_example": "codice_tipo_ente_creditore;tipo_ente_creditore;progressivo_macro_area_per_ente_creditore;nome_macro_area;descrizione_macro_area;codice_tipologia_servizio;tipo_servizio;motivo_giuridico_della_riscossione;descrizione_tipo_servizio;versione_tassonomia;dati_specifici_di_incasso;data_inizio_validita;data_fine_validita;combinazione_topic_subtopic\n05;SERVIZIO SANITARIO NAZIONALE;01;SERVIZIO SANITARIO NAZIONALE;I servizi sanitari sono quelli di assistenza sanitaria a tutela della salute della popolazione e degli animali. Tali servizi vengono erogati dalle ASL e dagli Ospedali, che a loro volta si distinguono in Presidi ospedalieri e Aziende ospedaliere.;153;incassi servizi sociali;SP;pagamento servizi rivolti a Persone non autosufficienti o portatrici di particolari patologie e disabilità;36;9/0501153SP/;07/03/2023;01/01/2080;Benessere sociale + Altro",
"force_taxomy_example": false
}
}
32 changes: 27 additions & 5 deletions integration-test/features/environment.py
Original file line number Diff line number Diff line change
@@ -14,17 +14,39 @@ def before_all(context):
more_userdata = json.load(open(os.path.join(context.config.base_dir + "/config/config.json")))
context.config.update_userdata(more_userdata)

global_config = context.config.userdata.get("global_config")

container = ContainerClient.from_connection_string(global_config.get("connection_string"), global_config.get("input_container_name"))
if container.get_blob_client(global_config.get("csv_blob_name")).exists():
with open(file=csv_file_path, mode="wb") as csv_file:
download_stream = container.download_blob(blob=global_config.get("csv_blob_name"))
csv_file.write(download_stream.readall())

# before feature
def before_feature(context, feature):
container = ContainerClient.from_connection_string(context.config.userdata.get("global_config").get("connection_string"), context.config.userdata.get("global_config").get("input_container_name"))
global_config = context.config.userdata.get("global_config")
container = ContainerClient.from_connection_string(global_config.get("connection_string"), global_config.get("input_container_name"))
try:
if not container.exists():
container.create_container()
print("Container created.")
if not container.get_blob_client(context.config.userdata.get("global_config").get("csv_blob_name")).exists():
with open(file=csv_file_path, mode="rb") as data:
container.upload_blob(name=context.config.userdata.get("global_config").get("csv_blob_name"), data=data)
print("Blob Uploaded.")
if not container.get_blob_client(global_config.get("csv_blob_name")).exists() or global_config.get("force_taxomy_example"):
container.upload_blob(name=global_config.get("csv_blob_name"), data=global_config.get("taxonomy_csv_example"), overwrite=True)
print("Blob Uploaded.")
except Exception as e:
print(e)


def after_all(context):
global_config = context.config.userdata.get("global_config")
container = ContainerClient.from_connection_string(global_config.get("connection_string"), global_config.get("input_container_name"))
try:
if container.get_blob_client(global_config.get("csv_blob_name")).exists():
if os.path.exists(csv_file_path):
with open(file=csv_file_path, mode="rb") as csv_file:
container.upload_blob(name=global_config.get("csv_blob_name"), data=csv_file.read(), overwrite=True)
print("Blob Restored.")
except Exception as e:
print(e)

print("Before feature executed.")
Loading