Skip to content

Commit

Permalink
ci: add CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
greenkiwi committed May 17, 2023
1 parent b84d45a commit 7c0d275
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 1 deletion.
31 changes: 31 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on:
pull_request:
branches: [main]
workflow_dispatch:

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: mfinelli/setup-shfmt@v2
- name: Install actionlint
uses: open-turo/action-install-release@v1
with:
repository: rhysd/actionlint
- name: Pre-commit
uses: open-turo/action-pre-commit@v1

test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- run: script/test
4 changes: 3 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ jobs:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
needs:
- build
- test
steps:
- name: Deploy to GitHub Pages
id: deployment
Expand Down
59 changes: 59 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,62 @@ We use the following standards as a baseline for all Terraform code at Turo:
formatting and linting standards.
- Scripts to rule them all -- we use [scripts to rule them all](https://github.com/github/scripts-to-rule-them-all) to
provide consistent usage and functionality across all repositories.

## `pre-commit` configuration

We expect that all tf repos will have the following pre-commit configuration:

```yaml
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0 # Use the ref you want to point at
hooks:
- id: check-json
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/open-turo/standards-terraform
rev: add-pre-commit-hooks
hooks:
- id: vars-in-variables-files
- id: outputs-in-outputs-files
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.77.1
hooks:
- id: terraform_fmt
stages: [commit]
- id: terraform_validate
stages: [commit]
- id: terraform_docs
stages: [commit]
- id: terraform_providers_lock
stages: [commit]
args:
- --args=-platform=darwin_amd64
- --args=-platform=linux_amd64
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
hooks:
- id: prettier
stages: [commit]
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.4.0
hooks:
- id: commitlint
stages: [commit-msg]
additional_dependencies: ["@open-turo/commitlint-config-conventional"]
- repo: https://github.com/turo/pre-commit-hooks
rev: v3.4.1
hooks:
- id: go-fmt
- id: golangci-lint
- repo: https://github.com/rhysd/actionlint
rev: v1.6.23
hooks:
- id: actionlint
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 3.0.0 # or specific git tag
hooks:
- id: shellcheck
- id: shfmt
```

0 comments on commit 7c0d275

Please sign in to comment.