Skip to content
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
83 changes: 59 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,78 @@
name: go-lambda-template-ci
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]
push:
branches: [main]
workflow_dispatch:

jobs:
code-quality:
name: Code Quality
test:
name: Test on Go ${{ matrix.go-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go-version: ["1.23.x", "1.24.x"]

steps:
- uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version: ${{ matrix.go-version }}
cache: true

- name: Lint Go code
run: |
go install golang.org/x/lint/golint@latest
golint ./src/...
- name: Download dependencies
run: go mod download

- name: Format Go code
run: gofmt -l -s -w ./src
- name: Verify dependencies
run: go mod verify

- name: Set up Terraform
uses: hashicorp/setup-terraform@v3
- name: Build
run: go build -v -o bootstrap -ldflags="-s -w" ./src/main.go

- name: Check Terraform formatting
run: terraform fmt terraform/ -check
- name: Run tests
run: go test -v -race -coverprofile=coverage.out ./...

- name: Install yamllint and mdformat
run: pip install yamllint mdformat
- name: Check test coverage
run: |
go tool cover -func=coverage.out
coverage=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//')
echo "Total coverage: ${coverage}%"

- name: Lint YAML files
run: yamllint .
build-artifact:
name: Build Lambda Artifact
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Format Markdown files (check only)
run: mdformat --check .
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23"
cache: true

- name: Build for AWS Lambda
env:
GOOS: linux
GOARCH: amd64
CGO_ENABLED: 0
run: |
go build -tags lambda.norpc -ldflags="-s -w" -o bootstrap ./src/main.go

- name: Package Lambda function
run: |
zip lambda-function.zip bootstrap

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: lambda-function
path: lambda-function.zip
retention-days: 7
74 changes: 74 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Code Quality

on:
pull_request:
branches: [main]
push:
branches: [main]
workflow_dispatch:

jobs:
code-quality:
name: Code Quality Checks
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.24"
cache: true

- name: Format check
run: |
gofmt -l -s .
if [ -n "$(gofmt -l -s .)" ]; then
echo "Go files must be formatted with gofmt. Please run: gofmt -l -s -w ."
exit 1
fi

- name: Install golangci-lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh |
sh -s -- -b $(go env GOPATH)/bin latest
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH

- name: Run golangci-lint
run: golangci-lint run --timeout=5m ./...

- name: Run tests with coverage
run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./...

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
files: ./coverage.out
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
continue-on-error: true

- name: Set up Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: "1.10.3"

- name: Check Terraform formatting
run: terraform fmt -check -recursive terraform/

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install YAML and Markdown linters
run: |
pip install yamllint mdformat mdformat-gfm

- name: Lint YAML files
run: yamllint .

- name: Check Markdown formatting
run: mdformat --check .
78 changes: 78 additions & 0 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Security

on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
# Run security scans weekly on Mondays at 10:00 AM UTC
- cron: "0 10 * * 1"
workflow_dispatch:

jobs:
govulncheck:
name: Go Vulnerability Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.24"
cache: true

- name: Install govulncheck
run: go install golang.org/x/vuln/cmd/govulncheck@latest

- name: Run govulncheck
run: govulncheck ./...

gosec:
name: Security Scan with gosec
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.24"
cache: true

- name: Run gosec
uses: securego/gosec@master
with:
args: "-no-fail -fmt sarif -out results.sarif ./..."

- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarif
continue-on-error: true

codeql:
name: CodeQL Analysis
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: go

- name: Autobuild
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
33 changes: 33 additions & 0 deletions .github/workflows/validate-pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Validate PR Title

on:
pull_request:
types: [opened, edited, synchronize, reopened]

jobs:
validate-title:
name: Validate PR Title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
types: |
feat
fix
docs
style
refactor
perf
test
build
ci
chore
revert
requireScope: false
subjectPattern: ^[A-Z].+$
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.
45 changes: 35 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
bootstrap

# Test binary, built with `go test -c`
*.test
Expand All @@ -17,16 +15,43 @@ coverage.*
*.coverprofile
profile.cov

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work
go.work.sum

# env file
# Lambda deployment artifacts
*.zip
lambda-function.zip
function.zip

# Terraform state files
*.tfstate
*.tfstate.*
*.tfvars
.terraform/
.terraform.lock.hcl

# Environment files
.env
.env.local
.env.*.local

# Editor/IDE files
.idea/
.vscode/
*.swp
*.swo
*~
.DS_Store

# Build output
dist/
build/
bin/

# Logs
*.log

# OS files
Thumbs.db

# Editor/IDE
# .idea/
# .vscode/
Loading
Loading