Skip to content

Merge pull request #1 from gosuda/copilot/update-ci-workflow-for-go #7

Merge pull request #1 from gosuda/copilot/update-ci-workflow-for-go

Merge pull request #1 from gosuda/copilot/update-ci-workflow-for-go #7

Workflow file for this run

name: CI
on:
pull_request:
branches: [main]
push:
branches: ["*"]
env:
CGO_ENABLED: "0"
jobs:
check-go:
name: Check Go Project
runs-on: ubuntu-latest
outputs:
is-go-project: ${{ steps.check.outputs.exists }}
steps:
- uses: actions/checkout@v5
- id: check
run: |
if [ -f "go.mod" ]; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "✓ go.mod found - proceeding with Go CI pipeline"
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "⊘ go.mod not found - skipping Go CI pipeline"
fi
test:
name: Test
runs-on: ubuntu-latest
needs: check-go
if: needs.check-go.outputs.is-go-project == 'true'
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: "stable"
check-latest: true
- run: go mod download
- run: go vet ./...
- run: go test -v -race -coverprofile=coverage.out ./...
lint:
name: Lint
runs-on: ubuntu-latest
needs: check-go
if: needs.check-go.outputs.is-go-project == 'true'
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: "stable"
check-latest: true
- run: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
- run: golangci-lint run
security:
name: Security
runs-on: ubuntu-latest
needs: check-go
if: needs.check-go.outputs.is-go-project == 'true'
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: "stable"
check-latest: true
- run: go install golang.org/x/vuln/cmd/govulncheck@latest
- run: govulncheck ./...
build:
name: Build
runs-on: ubuntu-latest
needs: [check-go, test, lint, security]
if: needs.check-go.outputs.is-go-project == 'true'
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: "stable"
check-latest: true
- run: go mod download
- run: go build ./...