From 45cfb948dd1f14b1a68f361a8fed456ab798690c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Respaut?= Date: Thu, 18 Apr 2024 16:48:46 +0200 Subject: [PATCH] ci(AZ-1391): enable semantic-release [skip ci] --- .commitlintrc.yml | 4 + .gitlab-ci.yml | 1 - .gitlab/merge_request_templates/default.md | 1 + .pre-commit-config.yaml | 58 +++++--- .releaserc | 164 +++++++++++++++++++++ .tool-versions | 5 + 6 files changed, 214 insertions(+), 19 deletions(-) create mode 100644 .commitlintrc.yml create mode 100644 .gitlab/merge_request_templates/default.md create mode 100644 .releaserc create mode 100644 .tool-versions diff --git a/.commitlintrc.yml b/.commitlintrc.yml new file mode 100644 index 0000000..f587e73 --- /dev/null +++ b/.commitlintrc.yml @@ -0,0 +1,4 @@ +extends: + - '@commitlint/config-conventional' +rules: + header-max-length: [0, "always", 120] diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f492d4e..c47389b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,6 @@ variables: AZURERM_PROVIDER_MIN_VERSION: "3.18" include: - - template: 'Workflows/Branch-Pipelines.gitlab-ci.yml' - project: 'claranet/projects/cloud/azure/terraform/ci' ref: master file: '/pipeline.yml' diff --git a/.gitlab/merge_request_templates/default.md b/.gitlab/merge_request_templates/default.md new file mode 100644 index 0000000..1d244c7 --- /dev/null +++ b/.gitlab/merge_request_templates/default.md @@ -0,0 +1 @@ +@ldap-sync/FR-Git-Cellule-Cloud-Azure diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ecd361c..3b72de1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,30 +1,52 @@ +default_install_hook_types: [commit-msg, pre-commit] repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + - 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-json + stages: [pre-commit] - id: check-yaml + stages: [pre-commit] args: - --unsafe - id: check-symlinks + stages: [pre-commit] - id: check-added-large-files + stages: [pre-commit] + args: + - --maxkb=15000 - id: detect-private-key + stages: [pre-commit] + + - repo: https://github.com/antonbabenko/pre-commit-terraform.git + rev: v1.88.4 + hooks: + - id: terraform_fmt + stages: [pre-commit] + - id: terraform_docs + stages: [pre-commit] + args: + - --args=--config=.config/terraform-docs.yml + exclude: "^modules|^example|^tools" + - id: terraform_validate + stages: [pre-commit] + exclude: ^examples + - id: terraform_tflint + stages: [pre-commit] + exclude: ^examples + args: + - --args=--config=__GIT_WORKING_DIR__/.config/tflint.hcl + - --env-vars=TFLINT_LOG="info" + - id: terraform_tfsec + stages: [pre-commit] -- repo: https://github.com/antonbabenko/pre-commit-terraform.git - rev: v1.77.1 - hooks: - - id: terraform_fmt - - id: terraform_docs - args: - - --args=--config=.config/terraform-docs.yml - exclude: '^modules|^example|^tools' - - id: terraform_validate - exclude: ^examples - - id: terraform_tflint - exclude: ^examples - args: - - --args=--config=__GIT_WORKING_DIR__/.config/tflint.hcl - - --env-vars=TFLINT_LOG="info" - - id: terraform_tfsec + - repo: https://github.com/compilerla/conventional-pre-commit + rev: v3.2.0 + hooks: + - id: conventional-pre-commit + stages: [commit-msg] + args: [] # optional: list of Conventional Commits types to allow e.g. [feat, fix, ci, chore, test] diff --git a/.releaserc b/.releaserc new file mode 100644 index 0000000..1984e4f --- /dev/null +++ b/.releaserc @@ -0,0 +1,164 @@ +{ + "branches": [ + "master", + "main" + ], + "tagFormat": "v${version}", + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "type": "docs", + "release": "patch" + }, + { + "type": "refactor", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "style", + "release": "patch" + }, + { + "type": "revert", + "release": "patch" + } + ], + "parserOpts": { + "noteKeywords": [ + "BREAKING CHANGE", + "BREAKING CHANGES", + "BREAKING" + ] + } + } + ], + [ + "@semantic-release/release-notes-generator", + { + "linkReferences": false, + "linkCompare": false, + "preset": "conventionalcommits", + "parserOpts": { + "noteKeywords": [ + "BREAKING CHANGE", + "BREAKING CHANGES", + "BREAKING" + ] + }, + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features", + "hidden": false + }, + { + "type": "fix", + "section": "Bug Fixes", + "hidden": false + }, + { + "type": "docs", + "section": "Documentation", + "hidden": false + }, + { + "type": "style", + "section": "Styles", + "hidden": false + }, + { + "type": "refactor", + "section": "Code Refactoring", + "hidden": false + }, + { + "type": "perf", + "section": "Performance Improvements", + "hidden": false + }, + { + "type": "test", + "section": "Tests", + "hidden": false + }, + { + "type": "ci", + "section": "Continuous Integration", + "hidden": false + }, + { + "type": "chore", + "section": "Miscellaneous Chores", + "hidden": false + }, + { + "type": "revert", + "section": "Revert", + "hidden": false + } + ] + } + } + ], + [ + "@semantic-release/changelog", + { + "changelogFile": "CHANGELOG.md" + } + ], + [ + "@semantic-release/git", + { + "assets": [ + "CHANGELOG.md" + ] + } + ], + [ + "@semantic-release/gitlab", + { + "gitlabUrl": "https://git.fr.clara.net", + "assets": [ + "CHANGELOG.md" + ] + } + ], + [ + "semantic-release-slack-bot", + { + "packageName": "Azure TF module", + "notifyOnSuccess": true, + "notifyOnFail": true, + "markdownReleaseNotes": true, + "onSuccessTemplate": { + "text": "New Azure TF module release", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": ":dancing-tofu: New :azure3: module ($repo_path) version out! *$npm_package_version* :dancing-tofu:" + } + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "$release_notes" + } + } + ] + } + } + ] + ] +} diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..7dc3bf9 --- /dev/null +++ b/.tool-versions @@ -0,0 +1,5 @@ +pre-commit 3.7.0 +opentofu 1.6.2 +terraform-docs 0.17.0 +tflint 0.50.3 +trivy 0.50.1