Skip to content

Commit

Permalink
Merge pull request #1 from yufeiminds/main
Browse files Browse the repository at this point in the history
feat(module): Add base template of tfmod
  • Loading branch information
lonegunmanb authored Sep 24, 2022
2 parents 9c4a440 + 28c5378 commit 97a7076
Show file tree
Hide file tree
Showing 23 changed files with 1,393 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"image": "mcr.microsoft.com/azterraform:latest",

"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined",
"--init",
"--network=host" // host networking
],

// Enable docker-in-docker
"mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],
"customizations": {
"vscode": {
"extensions": [
"hashicorp.terraform"
]
}
}
}
30 changes: 30 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# EditorConfig is awesome: http://EditorConfig.org
# Uses editorconfig to maintain consistent coding styles

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 80
trim_trailing_whitespace = true

[*.{tf,tfvars}]
indent_size = 2
indent_style = space

[*.md]
max_line_length = 0
trim_trailing_whitespace = false

[Makefile]
tab_width = 2
indent_style = tab

[COMMIT_EDITMSG]
max_line_length = 0
61 changes: 61 additions & 0 deletions .github/workflows/pr-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Pre Pull Request Check
on:
pull_request:
types: ['opened', 'synchronize']
paths:
- '.github/**'
- '**.go'
- '**.tf'
- '.github/workflows/**'
- '**.md'

jobs:
prepr-check:
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/azterraform:latest
env:
SKIP_CHECKOV: "true"
steps:
- name: checkout
uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '>=1.17.0'
- uses: actions/setup-node@v3
with:
node-version: 14
- name: make tools
run: |
make tools
- name: gofmtcheck
run: |
make gofmtcheck
- name: gencheck
run: |
make gencheck
- name: tfvalidatecheck
run: |
make tfvalidatecheck
- name: tffmtcheck
run: |
make tffmtcheck
- name: terrafmtcheck
run: |
make terrafmtcheck
- name: golint
run: |
make golint
- name: tflint
run: |
make tflint
- name: Run Checkov action
id: checkov
if: ${{env.SKIP_CHECKOV == ''}}
uses: bridgecrewio/checkov-action@master
with:
directory: ./
framework: terraform
quiet: true
output_format: sarif
download_external_modules: true
52 changes: 52 additions & 0 deletions .github/workflows/pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: 'Validate PR title'

on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
# Please look up the latest version from
# https://github.com/amannn/action-semantic-pull-request/releases
- uses: amannn/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# Configure which types are allowed.
# Default: https://github.com/commitizen/conventional-commit-types
types: |
fix
feat
docs
ci
chore
# Configure that a scope must always be provided.
requireScope: false
# Configure additional validation for the subject based on a regex.
# This example ensures the subject starts with an uppercase character.
subjectPattern: ^[A-Z].+$
# If `subjectPattern` is configured, you can use this property to override
# the default error message that is shown when the pattern doesn't match.
# The variables `subject` and `title` can be used within the message.
subjectPatternError: |
The subject "{subject}" found in the pull request title "{title}"
didn't match the configured pattern. Please ensure that the subject
starts with an uppercase character.
# For work-in-progress PRs you can typically use draft pull requests
# from Github. However, private repositories on the free plan don't have
# this option and therefore this action allows you to opt-in to using the
# special "[WIP]" prefix to indicate this state. This will avoid the
# validation of the PR title and the pull request checks remain pending.
# Note that a second check will be reported if this is enabled.
wip: true
# When using "Squash and merge" on a PR with only one commit, GitHub
# will suggest using that commit message instead of the PR title for the
# merge commit, and it's easy to commit this by mistake. Enable this option
# to also validate the commit message for one commit PRs.
validateSingleCommit: false
35 changes: 35 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Release

on:
workflow_dispatch:
push:
branches:
- main
- master
paths:
- '**/*.tf'
- '.github/workflows/release.yml'

jobs:
release:
name: Release
runs-on: ubuntu-latest
# Skip running release workflow on forks
if: github.repository_owner == 'yufeiminds'
steps:
- name: Checkout
uses: actions/checkout@v2
with:
persist-credentials: false
fetch-depth: 0

- name: Release
uses: cycjimmy/semantic-release-action@v2
with:
semantic_version: 18.0.0
extra_plugins: |
@semantic-release/[email protected]
@semantic-release/[email protected]
[email protected]
env:
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
32 changes: 32 additions & 0 deletions .github/workflows/stale-actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: 'Mark or close stale issues and PRs'
on:
schedule:
- cron: '0 0 * * *'

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v4
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
# Staling issues and PR's
days-before-stale: 30
stale-issue-label: stale
stale-pr-label: stale
stale-issue-message: |
This issue has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this issue will be closed in 10 days
stale-pr-message: |
This PR has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this PR will be closed in 10 days
# Not stale if have this labels or part of milestone
exempt-issue-labels: bug,wip,on-hold
exempt-pr-labels: bug,wip,on-hold
exempt-all-milestones: true
# Close issue operations
# Label will be automatically removed if the issues are no longer closed nor locked.
days-before-close: 10
delete-branch: true
close-issue-message: This issue was automatically closed because of stale in 10 days
close-pr-message: This PR was automatically closed because of stale in 10 days
65 changes: 65 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Variable files
terraform.tfvars

### https://raw.github.com/github/gitignore/abad92dac5a4306f72242dae3bca6e277bce3615/Terraform.gitignore

# Compiled files
*.tfstate
*.tfstate.backup
*.tfvars

**/.terraform.lock.hcl

# Terraform directory
.terraform/
terraform.tfstate.d/
logs/

# Go vendor directory
vendor/

# Files generated by terratest
.test-data/

# Terraform log file
terraform.log

### https://raw.github.com/github/gitignore/abad92dac5a4306f72242dae3bca6e277bce3615/Global/Vim.gitignore

# swap
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
# session
Session.vim
# temporary
.netrwhist
*~
# auto-generated tag files
tags

# IDE configs
.idea

# Ruby download package lock file.
Gemfile.lock

# Mac folder attribute file
.DS_Store

.terraform.tfstate.lock.info

# SSH Key
private_ssh_key

# generated readme by the pr-check job

README-generated.md

**/override.tf

.tflint.hcl
.tflint_example.hcl

tfmod-scaffold/
scripts

45 changes: 45 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"branches": [
"main",
"master"
],
"ci": false,
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits"
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits"
}
],
[
"@semantic-release/github",
{
"successComment": "This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:",
"labels": false,
"releasedLabels": false
}
],
[
"@semantic-release/changelog",
{
"changelogFile": "CHANGELOG.md",
"changelogTitle": "# Changelog\n\nAll notable changes to this project will be documented in this file."
}
],
[
"@semantic-release/git",
{
"assets": [
"CHANGELOG.md"
],
"message": "chore(release): version ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
]
]
}
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Changelog

All notable changes to this project will be documented in this file.

## 1.0.0 (2022-09-24)


### Features

* add basic module structure ([6bda6f8](https://github.com/yufeiminds/terraform-verified-module/commit/6bda6f87e9e1073e80c7f0a79cc3d49d6c23f93b))
* **ci:** Add base template of tfmod ([#1](https://github.com/yufeiminds/terraform-verified-module/issues/1)) ([1259cdc](https://github.com/yufeiminds/terraform-verified-module/commit/1259cdc3d0d1f8e86f9dfb4aa9a8046908df2dac))
9 changes: 9 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
SHELL := /bin/bash

-include $(shell curl -sSL "https://raw.githubusercontent.com/Azure/tfmod-scaffold/main/scripts/install.sh" | bash -s > /dev/null ; echo tfmod-scaffold/GNUmakefile)

init:
@sh "$(CURDIR)/scripts/init.sh"

cleanup:
@sh "$(CURDIR)/scripts/cleanup.sh"
Loading

0 comments on commit 97a7076

Please sign in to comment.