Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add CI for checking Go and Terraform #2

Merged
merged 2 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Go Build and Format

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
go:
name: Go ${{ matrix.task }}
runs-on: ubuntu-latest
strategy:
matrix:
task: [fmt, build]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "^1.20"
- name: Install dependencies
run: go mod tidy
- name: Run go fmt
if: matrix.task == 'fmt'
run: |
if [ -n "$(go fmt ./...)" ]; then
echo "Go files must be formatted with gofmt. Please run 'go fmt ./...' locally."
exit 1
fi
- name: Run go build
if: matrix.task == 'build'
run: go build ./...
35 changes: 35 additions & 0 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Terraform Format and Validate

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
terraform:
name: Terraform ${{ matrix.task }}
runs-on: ubuntu-latest
strategy:
matrix:
task: [fmt, validate]
defaults:
run:
working-directory: infra
steps:
- uses: actions/checkout@v4
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: "1.5.1"
- name: Terraform Format
if: matrix.task == 'fmt'
run: terraform fmt -check
- name: Terraform Init
if: matrix.task == 'validate'
run: terraform init -backend=false
- name: Terraform Validate
if: matrix.task == 'validate'
run: terraform validate
Loading