Skip to content

Commit

Permalink
feat: init
Browse files Browse the repository at this point in the history
  • Loading branch information
FabrizioCafolla committed Mar 5, 2024
0 parents commit 72533ef
Show file tree
Hide file tree
Showing 46 changed files with 2,114 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .activate
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
if [ "${BASH_SOURCE-}" = "$0" ]; then
echo "You must source this script: \$ source $0" >&2
exit 33
fi

source .venv/bin/activate

if [[ -f .env ]]; then
source .env
fi

if [[ "$(command -v minikube)" != "" ]] ; then
eval $(minikube -p minikube docker-env)
fi
62 changes: 62 additions & 0 deletions .github/ISSUE_TEMPLATE/BUG_REPORT.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: "🐛 Bug Report"
description: Create a new ticket for a bug.
title: "🐛 [BUG] - <title>"
labels: [
"bug"
]
body:
- type: textarea
id: description
attributes:
label: "Description"
description: Please enter an explicit description of your issue
placeholder: Short and explicit description of your incident...
validations:
required: true
- type: textarea
id: reprod
attributes:
label: "Reproduction steps"
description: Please enter an explicit description of your issue
value: |
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
render: bash
validations:
required: true
- type: textarea
id: logs
attributes:
label: "Logs"
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
render: bash
validations:
required: false
- type: dropdown
id: browsers
attributes:
label: "Browsers"
description: What browsers are you seeing the problem on ?
multiple: true
options:
- Firefox
- Chrome
- Safari
- Microsoft Edge
- Opera
validations:
required: false
- type: dropdown
id: os
attributes:
label: "OS"
description: What is the impacted environment ?
multiple: true
options:
- Windows
- Linux
- Mac
validations:
required: false
47 changes: 47 additions & 0 deletions .github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: "💡 Feature Request"
description: Create a new ticket for a new feature request
title: "💡 [REQUEST] - <title>"
labels: [
"feat: request"
]
body:
- type: textarea
id: summary
attributes:
label: "Summary"
description: Provide a brief explanation of the feature
placeholder: Describe in a few lines your feature request
validations:
required: true
- type: textarea
id: implementation_pr
attributes:
label: "Implementation PR"
description: Pull request used
placeholder: "#Pull Request ID"
validations:
required: false
- type: textarea
id: reference_issues
attributes:
label: "Reference Issues"
description: Common issues
placeholder: "#Issues IDs"
validations:
required: false
- type: textarea
id: basic_example
attributes:
label: "Basic Example"
description: Indicate here some basic examples of your feature.
placeholder: A few specific words about your feature request.
validations:
required: false
- type: textarea
id: drawbacks
attributes:
label: "Drawbacks"
description: What are the drawbacks/impacts of your feature request ?
placeholder: Identify the drawbacks and impacts while being neutral on your feature request
validations:
required: false
31 changes: 31 additions & 0 deletions .github/ISSUE_TEMPLATE/QUESTION.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "❓ Question"
description: Create a new ticket for a question
title: "❓ [QUESTION] - <title>"
labels: [
"question"
]
body:
- type: textarea
id: summary
attributes:
label: "Summary"
description: Provide a brief explanation of the qustion
placeholder: Describe in a few lines your question
validations:
required: true
- type: textarea
id: reference_issues
attributes:
label: "Reference Issues"
description: Common issues
placeholder: "#Issues IDs"
validations:
required: false
- type: textarea
id: basic_example
attributes:
label: "Basic Example"
description: Indicate here some basic examples of your question.
placeholder: Describe specific case or example
validations:
required: false
29 changes: 29 additions & 0 deletions .github/boring-cyborg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
labelPRBasedOnFilePath:
ci:
- .github/*
- .github/**/*

dependencies:
- requirements.txt
- .pre-commit-config.yaml

infrastructure:
- infrastructure/*
- infrastructure/**/*
- app/**/infrastructure/*
- app/**/infrastructure/**/*

api:
- app/api/*
- app/api/**/*

firstPRWelcomeComment: >
Thanks for opening this pull request! Please check out our contributing guidelines.
verifyTitles:
titleRegexp: ^(feat|feat!|fix|fix!|docs|refactor|refactor!|test|chore|build|ci)\((ci|docs|deps|deps-dev|api|infrastructure)\):.*
alwaysUsePrTitle: true
validateEitherPrOrSingleCommitTitle: true
statusTitle: "Title Validator"
successMessage: "Validation successful!"
failureMessage: "Wrong ${type} title: ${title}"
7 changes: 7 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## PR Checklist

- [ ] I have read the [Code of conduct](https://github.com/italia-opensource/awesome-italia-opensource/blob/main/CODE_OF_CONDUCT.md).

**If this is related to an issue/PR**

- [ ] I documented and tested the code (issue #)
61 changes: 61 additions & 0 deletions .github/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash
# Description: build.sh è lo script che consente di gestire il build delle immagini in modo univoco e standard per tutti i microservizi
# cosentendo di gestire i vari ambienti locale, staging e production allo stesso modo.
# Crea in output il file .dockerimage che può essere utilizzato dallo script terraform per recuperare l'immagine appena buildata

set -eE -o functrace

failure() {
local lineno=$1
local msg=$2
echo "Failed at $lineno: $msg"
}
trap 'failure ${LINENO} "$BASH_COMMAND"' ERR

set -o pipefail

WORKDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/../../microservices"

main(){
local _arg_microservice_name=${1}
local _arg_microservice_version=${2}
local _arg_load_minikube_docker_env=${3:-"false"}
local _arg_docker_filedir=${4:-""}

if [ "$_arg_microservice_name" == "" ]; then
echo "microservice_name is not set"
exit 1
fi

if [ "$_arg_microservice_version" == "" ]; then
echo "microservice_version is not set"
exit 1
fi

if [ "$_arg_docker_filedir" == "" ]; then
_arg_docker_filedir="${WORKDIR}/${_arg_microservice_name}"
fi

cd ${_arg_docker_filedir}

if [[ "$_arg_load_minikube_docker_env" == "true" ]]; then
eval $(minikube -p minikube docker-env) # Load minikube docker env in local infrastructure
fi

local _image_name="${_arg_microservice_name}:${_arg_microservice_version}"

echo "Building the image ${_image_name}"

docker build -t ${_image_name} .

if [[ "$_arg_load_minikube_docker_env" == "true" ]]; then
_image_sha="$(docker images --quiet ${_image_name})"
docker tag ${_image_name} ${_arg_microservice_name}:${_image_sha} # TODO: create tag with sha256 because minikube cannot retrieve the image via sha256.
printf "${_image_sha}" > .dockerimage
exit 0
fi

printf "${_arg_microservice_version}" > .dockerimage
}

main $@
42 changes: 42 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Code Quality

on:
push:
branches:
- main
pull_request:
branches:
- main
paths:
- '.github/workflows/test.yml'
- '.pre-commit-config.yaml'
- 'app/**/infrstructure/**'
- 'app/**/Dockerfile'
- 'infrastructure/**'
types: [opened, synchronize]

permissions:
contents: read

jobs:
code-quality:
name: Code Quality
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.9

- name: Setup and run pre-commit
run: |
chmod +x localstack/setup.sh
./localstack/setup.sh
source .venv/bin/activate
pre-commit run --all-files
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log
crash.*.log

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Include override files you do wish to add to version control using negated pattern
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

# Ignore CLI configuration files
.terraformrc
terraform.rc

.venv

localstack/localstack.txt

microservices/**/.dockerimage
26 changes: 26 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.18.2
hooks:
- id: gitleaks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
stages: [pre-commit]
- id: end-of-file-fixer
stages: [pre-commit]
- id: check-yaml
stages: [pre-commit]
- id: requirements-txt-fixer
stages: [pre-commit]
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.88.0
hooks:
- id: terraform_tflint
- id: terraform_fmt
- id: terraform_checkov
args:
- --args=--quiet
- --args=--skip-check CKV_K8S_43
- --args=--skip-check CKV_K8S_15
26 changes: 26 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Code of conduct

**Be patient and courteous**.

**Be inclusive**. We welcome and support people of all backgrounds and identities. This includes, but is not limited to members of any sexual orientation, gender identity and expression, race, ethnicity, culture, national origin, social and economic class, educational level, color, immigration status, sex, age, size, family status, political belief, religion, and mental and physical ability.

**Be considerate**. We all depend on each other to produce the best work we can as a company. Your decisions will affect clients and colleagues, and you should take those consequences into account when making decisions.

**Be respectful**. We won't all agree all the time, but disagreement is no excuse for disrespectful behavior. We will all experience frustration from time to time, but we cannot allow that frustration to become personal attacks. An environment where people feel uncomfortable or threatened is not a productive or creative one.

**Choose your words carefully**. Always conduct yourself professionally. Be kind to others. Do not insult or put down others. Harassment and exclusionary behavior aren't acceptable. This includes, but is not limited to: - Threats of violence. - Discriminatory jokes and language. - Sharing sexually explicit or violent material via electronic devices or other means. - Personal insults, especially those using racist or sexist terms. - Unwelcome sexual attention. - Advocating for, or encouraging, any of the above behavior.

**Do not harass others**. In general, if someone asks you to stop something, then stop. When we disagree, try to understand why. Differences of opinion and disagreements are mostly unavoidable. What is important is that we resolve disagreements and differing views constructively.

**Our differences can be our strengths**. We can find strength in diversity. Different people have different perspectives on issues, and that can be valuable for solving problems or generating new ideas. Being unable to understand why someone holds a viewpoint doesn’t mean that they’re wrong. Don’t forget that we all make mistakes, and blaming each other doesn’t get us anywhere.

**The accuracy of the data**. The data you wish to enter, modify or delete must be subjected to PR and that the actions taken to the data be consistent and truthful. In no way is the improper use of the data entered or deleted accepted to offend, disparage or other illegal actions. The responsible persons for the information entered/modified/deleted must be its owners or at least act in good faith without causing damage to third parties.

Instead, focus on resolving issues and learning from mistakes.

### Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

*Credits: https://www.betterteam.com/professional-code-of-conduct*
Loading

0 comments on commit 72533ef

Please sign in to comment.