Skip to content

Commit

Permalink
Update templates to use the new shared workflows (#342)
Browse files Browse the repository at this point in the history
* Migrate to the new shared workflows

* upd make

* unify naming

* Terraform PR target

* update templates

* dedup

* upd make

* fix docker

* fix docker

* fix docker

* fix build

* fix docker

* fix docker

* fix build

* fix build

* fix build

* update docs

* fix lint

* disable md lint

* rename

* rename

* rename

* rename
  • Loading branch information
max-lobur authored May 12, 2023
1 parent a2b111d commit 0f7b77a
Show file tree
Hide file tree
Showing 18 changed files with 126 additions and 331 deletions.
2 changes: 1 addition & 1 deletion .github/linters/.markdown-lint.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Default state for all rules
default: true
default: false

# Ignore MD041/first-line-heading/first-line-h1
# Error: First line in a file should be a top-level heading [Context: "## what"]
Expand Down
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ RUN apk --update --no-cache add \
ca-certificates \
coreutils \
curl \
unzip \
git \
gettext \
go \
Expand Down Expand Up @@ -77,6 +78,17 @@ RUN update-alternatives --set terraform /usr/share/terraform/$DEFAULT_TERRAFORM_
mkdir -p /build-harness/vendor && \
cp -p /usr/share/terraform/$DEFAULT_TERRAFORM_VERSION/bin/terraform /build-harness/vendor/terraform

# Install tflint
RUN curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash
COPY <<EOF .tflint.hcl
plugin "aws" {
enabled = true
version = "0.23.0"
source = "github.com/terraform-linters/tflint-ruleset-aws"
}
EOF
RUN tflint --init

# Patch for old Makefiles that expect a directory like x.x from the 0.x days.
# Fortunately, they only look for the current version, so we only need links
# for the current major version.
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,15 @@ Available targets:
template/build Create $OUT file by building it from $IN template file
template/deps Install dependencies
terraform/bump-tf-12-min-version Rewrite versions.tf to bump modules with minimum core version of '0.12.x' to '>= 0.12.26'
terraform/fmt Format terraform
terraform/get-modules (Obsolete) Ensure all modules can be fetched
terraform/get-plugins (Obsolete) Ensure all plugins can be fetched
terraform/install Install terraform
terraform/lint Lint check Terraform
terraform/lint Format check terraform
terraform/loosen-constraints and convert "~>" constraints to ">=".
terraform/precommit Terraform pull-request routine check/update
terraform/rewrite-required-providers Rewrite versions.tf to update existing configuration to add an explicit source attribute for each provider
terraform/tflint Lint terraform (with tflint)
terraform/upgrade-modules This target has not been upgraded to handle registry format
terraform/validate Basic terraform sanity check
travis/docker-login Login into docker hub
Expand Down
5 changes: 4 additions & 1 deletion docs/targets.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,15 @@ Available targets:
template/build Create $OUT file by building it from $IN template file
template/deps Install dependencies
terraform/bump-tf-12-min-version Rewrite versions.tf to bump modules with minimum core version of '0.12.x' to '>= 0.12.26'
terraform/fmt Format terraform
terraform/get-modules (Obsolete) Ensure all modules can be fetched
terraform/get-plugins (Obsolete) Ensure all plugins can be fetched
terraform/install Install terraform
terraform/lint Lint check Terraform
terraform/lint Format check terraform
terraform/loosen-constraints and convert "~>" constraints to ">=".
terraform/precommit Terraform pull-request routine check/update
terraform/rewrite-required-providers Rewrite versions.tf to update existing configuration to add an explicit source attribute for each provider
terraform/tflint Lint terraform (with tflint)
terraform/upgrade-modules This target has not been upgraded to handle registry format
terraform/validate Basic terraform sanity check
travis/docker-login Login into docker hub
Expand Down
15 changes: 7 additions & 8 deletions modules/github/Makefile.init
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ GITHUB_TEMPLATES = \
.github/ISSUE_TEMPLATE/feature_request.yml \
.github/ISSUE_TEMPLATE/bug_report.yml \
.github/ISSUE_TEMPLATE/question.md \
.github/auto-release.yml \
.github/workflows/auto-release.yml \
.github/workflows/validate-codeowners.yml

# Install extra configuration for terraform projects
GITHUB_TERRAFORM_TEMPLATES = .github/workflows/chatops.yml \
.github/workflows/auto-context.yml \
.github/workflows/auto-format.yml \
.github/workflows/auto-readme.yml \
GITHUB_TERRAFORM_TEMPLATES = .github/workflows/feature-branch.yml \
.github/workflows/feature-branch-chatops.yml \
.github/workflows/release-branch.yml \
.github/workflows/release-published.yml \
.github/workflows/scheduled.yml \
.github/mergify.yml \
.github/renovate.json
.github/renovate.json \
.github/auto-release.yml

GTIHUB_CODEOWNERS_FILE = .github/CODEOWNERS

Expand Down
10 changes: 9 additions & 1 deletion modules/terraform/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ terraform/get-modules:
terraform/validate:
@$(TERRAFORM) validate

## Lint check Terraform
## Lint terraform (with tflint)
terraform/tflint:
tflint --enable-plugin=aws

## Format check terraform
terraform/lint:
ifeq ($(OS), darwin)
@FAIL=`$(TERRAFORM) fmt -write=false | xargs -n 1 printf '\t- %s\n'`; \
Expand All @@ -36,6 +40,7 @@ else
[ -z "$$FAIL" ] || (echo "Terraform configuration needs linting. Run '$(TERRAFORM) fmt'"; echo $$FAIL; exit 1)
endif

## Format terraform
terraform/fmt:
ifeq ($(wildcard *.tf),)
@echo "* $@: No terraform files detected"
Expand Down Expand Up @@ -114,3 +119,6 @@ terraform/rewrite-required-providers: terraform/loosen-constraints
terraform/v14-rewrite: TERRAFORM = terraform-0.13
terraform/v14-rewrite: terraform/loosen-constraints terraform/bump-tf-12-min-version terraform/rewrite-required-providers terraform/rewrite-module-source terraform/rewrite-readme-source
@{ [[ "$(TERRAFORM_FORCE_README)" != "true" ]] && git diff --no-patch --exit-code README.yaml; } || $(MAKE) readme

## Terraform pull-request routine check/update
terraform/precommit: terraform/fmt terraform/tflint readme/build
26 changes: 0 additions & 26 deletions templates/.github/workflows/auto-release.yml

This file was deleted.

30 changes: 0 additions & 30 deletions templates/.github/workflows/validate-codeowners.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ version-resolver:
- 'bug'
- 'hotfix'
default: 'minor'
filter-by-commitish: true

categories:
- title: '🚀 Enhancements'
Expand Down
67 changes: 0 additions & 67 deletions templates/terraform/.github/workflows/auto-context.yml

This file was deleted.

88 changes: 0 additions & 88 deletions templates/terraform/.github/workflows/auto-format.yml

This file was deleted.

Loading

0 comments on commit 0f7b77a

Please sign in to comment.