Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
pasqualespica committed Oct 29, 2024
2 parents c9ef711 + 6a23a05 commit d6cc375
Show file tree
Hide file tree
Showing 140 changed files with 2,549 additions and 1,349 deletions.
2 changes: 1 addition & 1 deletion .devops/aca-code-review-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ resources:
- repository: terraform
type: github
name: pagopa/azure-pipeline-templates
ref: refs/heads/iac-fix
ref: refs/tags/v6.11.0
endpoint: "io-azure-devops-github-ro"

stages:
Expand Down
2 changes: 1 addition & 1 deletion .devops/apiconfig-code-review-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ resources:
- repository: terraform
type: github
name: pagopa/azure-pipeline-templates
ref: refs/heads/iac-fix
ref: refs/tags/v6.11.0
endpoint: "io-azure-devops-github-ro"

stages:
Expand Down
2 changes: 1 addition & 1 deletion .devops/canoneunico-code-review-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ resources:
- repository: terraform
type: github
name: pagopa/azure-pipeline-templates
ref: refs/heads/iac-fix
ref: refs/tags/v6.11.0
endpoint: "io-azure-devops-github-ro"

stages:
Expand Down
2 changes: 1 addition & 1 deletion .devops/mock-code-review-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ resources:
- repository: terraform
type: github
name: pagopa/azure-pipeline-templates
ref: refs/heads/iac-fix
ref: refs/tags/v6.11.0
endpoint: "io-azure-devops-github-ro"

stages:
Expand Down
26 changes: 24 additions & 2 deletions .devops/nodo-db-schema-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,28 @@ stages:
--querytext "
do \$\$
BEGIN
CREATE SEQUENCE IF NOT EXISTS $(PARTITION_SCHEMA).seq_log
INCREMENT 1
START 1
MINVALUE 1
MAXVALUE 9223372036854775807
CACHE 1
;
CREATE TABLE IF NOT EXISTS $(PARTITION_SCHEMA).PG_LOG
(
ID_TRACE NUMERIC DEFAULT nextval('seq_log'::regclass) NOT NULL ,
UTENTE character varying,
PROCESSO character varying,
DATA_INIZIO timestamp without time zone,
DATA_FINE timestamp without time zone,
DELTA_TIME INTERVAL,
ESITO character varying,
MESSAGGIO character varying,
NOTE character varying
);
CREATE TABLE IF NOT EXISTS $(PARTITION_SCHEMA).tab_part
(
tabella character varying(100) COLLATE pg_catalog."default",
Expand Down Expand Up @@ -364,8 +386,8 @@ stages:
inlineScript: |
az config set extension.use_dynamic_install=yes_without_prompt
az postgres flexible-server execute --name $(DB_HOST) --admin-user $(PARTITION_USERNAME) \
--admin-password '$(db-partition-password)' --database-name "postgres" \
az postgres flexible-server execute --name $(DB_HOST) --admin-user $(ADMIN_USERNAME) \
--admin-password '$(db-administrator-login-password)' --database-name "postgres" \
--querytext "
do \$\$
BEGIN
Expand Down
8 changes: 4 additions & 4 deletions .devops/observability-code-review-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ resources:
- repository: terraform
type: github
name: pagopa/azure-pipeline-templates
ref: refs/heads/iac-fix
ref: refs/tags/v6.11.0
endpoint: "io-azure-devops-github-ro"

stages:
Expand All @@ -91,7 +91,7 @@ stages:
# 2. Run terraform plan core
- template: templates/terraform-plan/template.yaml@terraform
parameters:
TF_ENVIRONMENT_FOLDER: "weu-dev"
TF_ENVIRONMENT_FOLDER: "dev"
WORKINGDIR: ${{ variables.WORKING_DIR_COMMON }}
AZURE_SERVICE_CONNECTION_NAME: "${{variables.azureServiceConnectionPlanNameDev}}"
TF_SUMMARIZE: true
Expand Down Expand Up @@ -134,7 +134,7 @@ stages:
# 2. Run terraform plan core
- template: templates/terraform-plan/template.yaml@terraform
parameters:
TF_ENVIRONMENT_FOLDER: "weu-uat"
TF_ENVIRONMENT_FOLDER: "uat"
WORKINGDIR: ${{ variables.WORKING_DIR_COMMON }}
AZURE_SERVICE_CONNECTION_NAME: "${{variables.azureServiceConnectionPlanNameUat}}"
TF_SUMMARIZE: true
Expand Down Expand Up @@ -177,7 +177,7 @@ stages:
# 2. Run terraform plan core
- template: templates/terraform-plan/template.yaml@terraform
parameters:
TF_ENVIRONMENT_FOLDER: "weu-prod"
TF_ENVIRONMENT_FOLDER: "prod"
WORKINGDIR: ${{ variables.WORKING_DIR_COMMON }}
AZURE_SERVICE_CONNECTION_NAME: "${{variables.azureServiceConnectionPlanNameProd}}"
TF_SUMMARIZE: true
Expand Down
2 changes: 1 addition & 1 deletion .devops/qi-code-review-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ resources:
- repository: terraform
type: github
name: pagopa/azure-pipeline-templates
ref: refs/heads/iac-fix
ref: refs/tags/v6.11.0
endpoint: "io-azure-devops-github-ro"

stages:
Expand Down
2 changes: 1 addition & 1 deletion .devops/qi-deploy-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ resources:
- repository: terraform
type: github
name: pagopa/azure-pipeline-templates
ref: refs/heads/iac-fix
ref: refs/tags/v6.11.0
endpoint: "io-azure-devops-github-ro"

stages:
Expand Down
2 changes: 1 addition & 1 deletion .devops/receipts-code-review-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ resources:
- repository: terraform
type: github
name: pagopa/azure-pipeline-templates
ref: refs/heads/iac-fix
ref: refs/tags/v6.11.0
endpoint: "io-azure-devops-github-ro"

stages:
Expand Down
2 changes: 1 addition & 1 deletion .devops/receipts-deploy-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ resources:
- repository: terraform
type: github
name: pagopa/azure-pipeline-templates
ref: refs/heads/iac-fix
ref: refs/tags/v6.11.0
endpoint: "io-azure-devops-github-ro"

stages:
Expand Down
144 changes: 7 additions & 137 deletions .github/workflows/static_analysis_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,154 +13,24 @@ jobs:
- run: |
rm -rf *
- name: ⏬ Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install necessary packages
run: python -m pip install --upgrade pip

- name: 🔨 Get Modified Paths
id: get-paths
run: |
import os
import subprocess
IGNORED_PATHS = ["domains", "scripts", "github", ".devops"]
def get_current_branch():
result = subprocess.run(["git", "rev-parse", "--abbrev-ref", "HEAD"], capture_output=True, text=True)
return result.stdout.strip()
def get_git_diff(current_branch):
subprocess.run(["git", "fetch", "origin"])
result = subprocess.run(["git", "diff", "--name-only", current_branch, "origin/main"], capture_output=True, text=True)
with open('/tmp/diff.txt', 'w') as f:
f.write(result.stdout)
def get_required_path(path):
# Split the path into its components
parts = path.split(os.sep)
# Find the index of "src" and "domains"
try:
start_index = parts.index("src") # Find "src"
# Check if "domains" is present and get up one higher level
if "domains" in parts[start_index:]:
domains_index = parts.index("domains", start_index)
if len(parts) > domains_index + 2: # Ensure there is a level after "domains"
end_index = 3 # Exclude the last part
# Include the parent of "domains" and all up to the second last part
return os.sep.join(parts[start_index:end_index])
else:
return ""
else: # Handle paths not containing 'domains'
if len(parts) > start_index + 2: # Ensure there is enough depth
end_index = 2 # Exclude the last part
return os.sep.join(parts[start_index:end_index])
else:
return ""
except (ValueError, IndexError) as e:
return ""
def get_modified_paths(pattern, exclude_ignored=True):
with open('/tmp/diff.txt') as f:
lines = f.readlines()
if exclude_ignored:
paths = [
line.strip()
for line in lines
if not any(ignored in line for ignored in IGNORED_PATHS)
]
else:
paths = [line.strip() for line in lines if pattern in line]
# Removing duplicates and sorting
unique_paths = sorted(set([
get_required_path(path)
for path in paths if path
]))
return unique_paths
def write_to_file(content, filepath):
with open(filepath, 'w') as f:
f.write(content)
def main():
current_branch = get_current_branch()
print(f"Current branch: {current_branch}")
get_git_diff(current_branch)
modified_paths_source = get_modified_paths('src/', exclude_ignored=True)
print(f"Modified paths in source: {modified_paths_source}")
modified_paths_domains = get_modified_paths('domains', exclude_ignored=False)
print(f"Modified paths in domains: {modified_paths_domains}")
modified_paths = "\n".join(modified_paths_source + modified_paths_domains)
print(f"📌 Modified paths: {modified_paths}")
write_to_file(modified_paths, "/tmp/paths.txt")
if any("src/" in path for path in modified_paths.split()):
print("src folder modified.")
with open(os.getenv('GITHUB_ENV'), 'a') as f:
f.write('run_static_analysis=true\n')
else:
print("src folder not modified.")
with open(os.getenv('GITHUB_ENV'), 'a') as f:
f.write('run_static_analysis=false\n')
if __name__ == "__main__":
main()
shell: python

- name: Read modified paths
if: env.run_static_analysis == 'true'
id: read_paths
run: |
modified_paths=$(cat /tmp/paths.txt)
echo "Modified paths: $modified_paths"
echo "::set-output name=modified_paths::$modified_paths"
- name: ⏬ Download Modified Folders Only
if: env.run_static_analysis == 'true'
id: download_changed_folders
shell: bash
run: |
# Read all paths and download only the modified folders
MODIFIED_FOLDERS=($(cat /tmp/paths.txt))
# Include 'scripts' in the list of directories to checkout
MODIFIED_FOLDERS+=("scripts")
# Initialize git sparse-checkout
git sparse-checkout init --cone
# Set each path in MODIFIED_FOLDERS for sparse-checkout
git sparse-checkout set "${MODIFIED_FOLDERS[@]}"
# Checkout the latest changes
git checkout
uses: pagopa/eng-github-actions-iac-template/global/[email protected]
with:
start_folder: "src"
default_end_folder_depth: 3
include_patterns: "src,domains"

- name: 👀 See folders downloaded
if: env.run_static_analysis == 'true'
if: env.dir_changes_detected == 'true'
id: see
shell: bash
run: |
ls -la
du -h -d 3 .
- name: Static Analysis
if: env.run_static_analysis == 'true'
if: env.dir_changes_detected == 'true'
uses: pagopa/eng-github-actions-iac-template/azure/[email protected]
with:
precommit_version: 'v1.89.1@sha256:1ea921bc4fe87651d41677218e537afdcdb8202e757e554b9866668eaba144c5'
Loading

0 comments on commit d6cc375

Please sign in to comment.