Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into VAS-834-feat-add-noti…
Browse files Browse the repository at this point in the history
…ce-generation

# Conflicts:
#	.github/workflows/code_review.yml
#	.github/workflows/deploy_with_github_runner.yml
  • Loading branch information
alessio-cialini committed May 10, 2024
2 parents 6985e08 + e20eb36 commit f067a74
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 150 deletions.
6 changes: 6 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ changelog:
- title: Breaking Changes 🛠
labels:
- breaking-change
- major
- title: Exciting New Features 🎉
labels:
- enhancement
- minor
- title: Bug Fixing 🔥
labels:
- bug
- patch
- title: Other Changes
labels:
- "*"
71 changes: 34 additions & 37 deletions .github/workflows/check_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,26 @@ jobs:
with:
configuration-path: '.github/auto_assign.yml'

check_format:
name: Check Format
check_labels:
name: Check Required Labels
# The type of runner that the job will run on
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Formatting
id: format
continue-on-error: true
uses: findologic/intellij-format-action@main
with:
path: .
fail-on-changes: false

- uses: actions/[email protected]
if: steps.format.outcome != 'success'
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Verify PR Labels
if: ${{ !contains(github.event.pull_request.labels.*.name, 'major') && !contains(github.event.pull_request.labels.*.name, 'minor') && !contains(github.event.pull_request.labels.*.name, 'patch') && !contains(github.event.pull_request.labels.*.name, 'patch') && !contains(github.event.pull_request.labels.*.name, 'skip') }}
uses: actions/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
console.log(context);
var comments = await github.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo
});
for (const comment of comments.data) {
console.log(comment);
if (comment.body.includes('Comment this PR with')){
if (comment.body.includes('This pull request does not contain a valid label')){
github.rest.issues.deleteComment({
issue_number: context.issue.number,
owner: context.repo.owner,
Expand All @@ -66,12 +57,12 @@ jobs:
}
}
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Comment this PR with *update_code* to update `openapi.json` and format the code. Consider to use pre-commit to format the code.'
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'This pull request does not contain a valid label. Please add one of the following labels: `[major, minor, patch, patch, skip]`'
})
core.setFailed('Format your code.')
core.setFailed('Missing required labels')
check_size:
runs-on: ubuntu-latest
Expand All @@ -84,7 +75,8 @@ jobs:
- name: Check Size
uses: actions/[email protected]
env:
IGNORED_FILES: openapi.json, openapi-node.json
IGNORED_FILES: openapi.json
BRANCH_NAME: ${{ github.head_ref}}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
Expand All @@ -93,15 +85,15 @@ jobs:
var changes = additions + deletions
console.log('additions: '+additions+' + deletions: '+deletions+ ' = total changes: ' + changes);
const { IGNORED_FILES } = process.env
const { IGNORED_FILES, BRANCH_NAME } = process.env
const ignored_files = IGNORED_FILES.trim().split(',').filter(word => word.length > 0);
if (ignored_files.length > 0){
var ignored = 0
const execSync = require('child_process').execSync;
for (const file of IGNORED_FILES.trim().split(',')) {
const ignored_additions_str = execSync('git --no-pager diff --numstat origin/main..origin/${{ github.head_ref}} | grep ' + file + ' | cut -f 1', { encoding: 'utf-8' })
const ignored_deletions_str = execSync('git --no-pager diff --numstat origin/main..origin/${{ github.head_ref}} | grep ' + file + ' | cut -f 2', { encoding: 'utf-8' })
const ignored_additions_str = execSync('git --no-pager diff --numstat origin/main..origin/'+BRANCH_NAME+' | grep ' + file + ' | cut -f 1', { encoding: 'utf-8' })
const ignored_deletions_str = execSync('git --no-pager diff --numstat origin/main..origin/'+BRANCH_NAME+' | grep ' + file + ' | cut -f 2', { encoding: 'utf-8' })
const ignored_additions = ignored_additions_str.split('\n').map(elem=> parseInt(elem || 0)).reduce(
(accumulator, currentValue) => accumulator + currentValue,
Expand All @@ -122,21 +114,26 @@ jobs:
repo: context.repo.repo
});
if (labels.data.find(label => label.name == 'size/large')){
github.rest.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: 'size/large'
})
}
if (labels.data.find(label => label.name == 'size/small')){
if (changes <= 400){
if (labels.data.find(label => label.name == 'size/large')){
github.rest.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: 'size/small'
name: 'size/large'
})
}
}
if (changes >= 200){
if (labels.data.find(label => label.name == 'size/small')){
github.rest.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: 'size/small'
})
}
}
var comments = await github.rest.issues.listComments({
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/code_review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
sonar_token: ${{ secrets.SONAR_TOKEN }}
project_key: ${{env.PROJECT_KEY}}
coverage_exclusions: "**/config/*,**/*Mock*,**/model/**,**/entity/*,**/exception/*"
cpd_exclusions: "**/model/**,**/entity/*"
cpd_exclusions: "**/models/**,**/entity/*"
java_version: 17


Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/deploy_with_github_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
type: string

env:
APP_NAME: pagopa-print-payment-notice-generator
APP_NAME: print-payment-notice-generator


permissions:
Expand All @@ -36,6 +36,7 @@ jobs:
container_app_environment_name: ${{ vars.CONTAINER_APP_ENVIRONMENT_NAME }}
resource_group_name: ${{ vars.CONTAINER_APP_ENVIRONMENT_RESOURCE_GROUP_NAME }} # RG of the runner
pat_token: ${{ secrets.BOT_TOKEN_GITHUB }}
self_hosted_runner_image_tag: "v3.0.0"

deploy:
needs: [ create_runner ]
Expand Down
19 changes: 15 additions & 4 deletions .github/workflows/release_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Release And Deploy

# Controls when the workflow will run
on:
merge_group:
branches: [ main ]
pull_request:
types: [ closed ]

Expand All @@ -21,7 +23,7 @@ on:
type: choice
description: Select the version
options:
- ''
- patch
- skip_or_promote
- new_release
- breaking_change
Expand Down Expand Up @@ -59,7 +61,16 @@ jobs:
# Set Semvar
- run: echo "SEMVER=patch" >> $GITHUB_ENV

- if: ${{ (github.event.pull_request.merged && contains(github.event.pull_request.labels.*.name, 'breaking-change')) }}
- if: ${{ (github.event.pull_request.merged && contains(github.event.pull_request.labels.*.name, 'skip')) }}
run: echo "SEMVER=skip" >> $GITHUB_ENV

- if: ${{ (github.event.pull_request.merged && contains(github.event.pull_request.labels.*.name, 'patch')) }}
run: echo "SEMVER=patch" >> $GITHUB_ENV

- if: ${{ (github.event.pull_request.merged && contains(github.event.pull_request.labels.*.name, 'minor')) }}
run: echo "SEMVER=minor" >> $GITHUB_ENV

- if: ${{ (github.event.pull_request.merged && contains(github.event.pull_request.labels.*.name, 'major')) }}
run: echo "SEMVER=major" >> $GITHUB_ENV

# force semver if dev, !=main or skip release
Expand Down Expand Up @@ -99,11 +110,12 @@ jobs:
steps:
- name: Make Release
id: release
uses: pagopa/github-actions-template/maven-release@v1.6.8
uses: pagopa/github-actions-template/maven-release@v1.12.0
with:
semver: ${{ needs.setup.outputs.semver }}
github_token: ${{ secrets.BOT_TOKEN_GITHUB }}
beta: ${{ inputs.beta }}
prerelease: ${{ inputs.environment != 'prod' }}
skip_ci: false

image:
Expand All @@ -128,7 +140,6 @@ jobs:
environment: ${{ needs.setup.outputs.environment }}
secrets: inherit


notify:
needs: [ setup, release, deploy_aks ]
runs-on: ubuntu-latest
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/update_gha.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import requests
import json

import requests

url = 'https://github.com/pagopa/template-java-spring-microservice/tree/main/.github/workflows'
url = 'https://api.github.com/repos/pagopa/template-java-spring-microservice/contents/.github/workflows'
url_raw = 'https://raw.githubusercontent.com/pagopa/template-java-spring-microservice/main/'

response = requests.get(url)

for item in json.loads(response.text)["payload"]["tree"]["items"]:
for item in json.loads(response.text):
path = item["path"]
name = item["name"]
print(name)
response = requests.get(url_raw+path)
response = requests.get(url_raw + path)
fo = open(name, "w")
fo.write(response.text)
fo.close()


11 changes: 8 additions & 3 deletions .identity/00_data.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
data "azurerm_storage_account" "tf_storage_account"{
data "azurerm_storage_account" "tf_storage_account" {
name = "pagopainfraterraform${var.env}"
resource_group_name = "io-infra-rg"
}
Expand All @@ -17,14 +17,19 @@ data "github_organization_teams" "all" {
summary_only = true
}

data "azurerm_user_assigned_identity" "identity_cd_01" {
name = "${local.prefix}-${var.env_short}-${local.domain}-01-github-cd-identity"
resource_group_name = "${local.prefix}-${var.env_short}-identity-rg"
}

data "azurerm_key_vault" "key_vault" {
name = "pagopa-${var.env_short}-kv"
resource_group_name = "pagopa-${var.env_short}-sec-rg"
}

data "azurerm_key_vault" "domain_key_vault" {
name = "pagopa-${var.env_short}-${local.domain}-kv"
resource_group_name = "pagopa-${var.env_short}-${local.domain}-sec-rg"
name = "pagopa-${var.env_short}-itn-${local.domain}-kv"
resource_group_name = "pagopa-${var.env_short}-itn-${local.domain}-sec-rg"
}

data "azurerm_resource_group" "apim_resource_group" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ resource "github_repository_environment" "github_repository_environment" {

locals {
env_secrets = {
"CLIENT_ID" : module.github_runner_app.application_id,
"CLIENT_ID" : data.azurerm_user_assigned_identity.identity_cd_01.client_id,
"TENANT_ID" : data.azurerm_client_config.current.tenant_id,
"SUBSCRIPTION_ID" : data.azurerm_subscription.current.subscription_id,
"SUBKEY" : data.azurerm_key_vault_secret.key_vault_integration_test_subkey.value,
Expand Down
96 changes: 0 additions & 96 deletions .identity/02_application_action.tf

This file was deleted.

2 changes: 1 addition & 1 deletion .identity/99_variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ variable "prefix" {
default = "pagopa"
validation {
condition = (
length(var.prefix) <= 6
length(var.prefix) <= 6
)
error_message = "Max length is 6 chars."
}
Expand Down

0 comments on commit f067a74

Please sign in to comment.