diff --git a/templates/jobs/fmt.yml b/templates/jobs/fmt.yml new file mode 100644 index 0000000000000000000000000000000000000000..730f1a836328fdbad19784facc68e21f856a6ea6 --- /dev/null +++ b/templates/jobs/fmt.yml @@ -0,0 +1,70 @@ +spec: + inputs: + # Job and Stage name + as: + default: 'fmt' + description: 'Defines the name of this job.' + stage: + default: 'validate' + description: 'Defines the stage that this job will belong to.' + + # Versions + # This version is only required, because we cannot access the context of the component, + # see https://gitlab.com/gitlab-org/gitlab/-/issues/438275 + version: + default: 'latest' + description: 'Version of this component. Has to be the same as the one in the component include entry.' + + opentofu_version: + default: '1.6.1' + options: + - '$OPENTOFU_VERSION' + - '1.6.1' + - '1.6.0' + - '1.6.0-rc1' + description: 'OpenTofu version that should be used.' + + # Images + image_registry_base: + default: '$CI_REGISTRY/components/opentofu' + # FIXME: not yet possible because of https://gitlab.com/gitlab-org/gitlab/-/issues/438722 + # gitlab_opentofu_image: + # # FIXME: This should reference the component tag that is used. + # # Currently, blocked by https://gitlab.com/gitlab-org/gitlab/-/issues/438275 + # # default: '$CI_REGISTRY/components/opentofu/gitlab-opentofu:$[[ inputs.opentofu_version ]]' + # default: '$CI_REGISTRY/components/opentofu/gitlab-opentofu:$[[ inputs.version ]]-opentofu$[[ inputs.opentofu_version ]]' + # description: 'Tag of the gitlab-opentofu image.' + + # Configuration + root_dir: + default: ${CI_PROJECT_DIR} + description: 'Root directory for the OpenTofu project.' + + # FIXME: wait for https://gitlab.com/gitlab-org/gitlab/-/merge_requests/142009 + # allow_failure: + # default: true + # type: boolean + # description: 'If the job is allowed to fail or not.' + +--- + +'$[[ inputs.as ]]': + stage: $[[ inputs.stage ]] + needs: [] + rules: + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + - if: $CI_OPEN_MERGE_REQUESTS # Don't add it to a *branch* pipeline if it's already in a merge request pipeline. + when: never + - if: $CI_COMMIT_BRANCH # If there's no open merge request, add it to a *branch* pipeline instead. + #allow_failure: $[[ inputs.allow_failure ]] + allow_failure: true + cache: + key: "$[[ inputs.root_dir ]]" + paths: + - $[[ inputs.root_dir ]]/.terraform/ + variables: + TF_ROOT: $[[ inputs.root_dir ]] + image: + name: '$[[ inputs.image_registry_base ]]/gitlab-opentofu:$[[ inputs.version ]]-opentofu$[[ inputs.opentofu_version ]]' + script: + - gitlab-tofu fmt