Skip to content

Commit 8555c28

Browse files
authored
ci: Refactor GitHub Actions
- simplify GitHub Actions - remove old build/lint/release workflows - add a reusable setup-go composite action - add new ci workflow to run build, MegaLinter, tests, Sonar, and CodeQL - add new release workflow with semantic‑release dry run and manual release
1 parent abb1a77 commit 8555c28

23 files changed

Lines changed: 300 additions & 451 deletions
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Setup Go
2+
description: |
3+
This action sets up the Go environment for your project, downloading the necessary modules
4+
and preparing the environment for building or testing Go applications.
5+
inputs:
6+
go-version-file:
7+
description: Path to go.mod file
8+
default: 'go.mod'
9+
go-version:
10+
description: Explicit Go version
11+
required: false
12+
default: '1.24'
13+
14+
runs:
15+
using: composite
16+
steps:
17+
- name: Setup Go environment
18+
uses: actions/setup-go@v5.5.0
19+
with:
20+
go-version-file: ${{ inputs.go-version-file }}
21+
go-version: ${{ inputs.go-version }}
22+
cache: true
23+
- name: Download Go modules
24+
run: go mod download
25+
shell: bash

.github/workflows/build.yml

Lines changed: 0 additions & 177 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
name: Continuous Integration
2+
3+
on:
4+
push:
5+
branches: [main, dev]
6+
pull_request:
7+
branches: [main, dev]
8+
schedule:
9+
- cron: '0 0 * * 0'
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
security-events: write
15+
16+
jobs:
17+
build:
18+
name: Go Build
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Git Checkout
22+
uses: actions/checkout@v4
23+
- name: Setup Go
24+
uses: ./.github/actions/setup-go
25+
- name: Go Build
26+
run: go build -v ./...
27+
28+
lint:
29+
name: Linters
30+
runs-on: ubuntu-latest
31+
needs: build
32+
permissions:
33+
issues: write
34+
pull-requests: write
35+
steps:
36+
- name: Git Checkout
37+
uses: actions/checkout@v4
38+
- name: Setup Go
39+
uses: ./.github/actions/setup-go
40+
- name: GolangCI Lint
41+
uses: golangci/golangci-lint-action@v8
42+
with:
43+
version: v2.1
44+
args: --config=.linters/.golangci.yml
45+
- name: MegaLinter
46+
uses: oxsecurity/megalinter/flavors/go@v8
47+
id: ml
48+
env:
49+
VALIDATE_ALL_CODEBASE: true
50+
DEFAULT_WORKSPACE: ${{ github.workspace }}
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
- name: Archive reports
53+
uses: actions/upload-artifact@v4
54+
if: ${{ success() || failure() }}
55+
with:
56+
name: MegaLinter reports
57+
path: |
58+
.ml-reports/
59+
mega-linter.log
60+
61+
tests:
62+
name: Go All Tests
63+
runs-on: ubuntu-latest
64+
needs: build
65+
strategy:
66+
matrix:
67+
tf-version: ['1.11.*', '1.12.*']
68+
steps:
69+
- name: Git Checkout
70+
uses: actions/checkout@v4
71+
- name: Setup Go
72+
uses: ./.github/actions/setup-go
73+
- name: Setup Terraform
74+
uses: hashicorp/setup-terraform@v3
75+
with:
76+
terraform_version: ${{ matrix.tf-version }}
77+
terraform_wrapper: false
78+
- name: Run Tests
79+
run: go test ./internal/provider -v -coverprofile=tests-report.lcov -json > tests-report.log
80+
env:
81+
TF_ACC: '1'
82+
- name: Codecov Upload Coverage
83+
uses: codecov/codecov-action@v4
84+
with:
85+
token: ${{ secrets.CODECOV_TOKEN }}
86+
verbose: true
87+
files: tests-report.lcov
88+
- name: Codecov Upload Test Results
89+
if: ${{ !cancelled() }}
90+
uses: codecov/test-results-action@v1
91+
with:
92+
token: ${{ secrets.CODECOV_TOKEN }}
93+
- name: Upload Test Artifacts
94+
uses: actions/upload-artifact@v4
95+
with:
96+
name: tests-report-${{ github.sha }}
97+
path: |
98+
tests-report.lcov
99+
tests-report.log
100+
retention-days: 7
101+
overwrite: true
102+
103+
sonar:
104+
name: SonarCloud Scan
105+
if: github.event_name == 'push'
106+
runs-on: ubuntu-latest
107+
needs: [tests]
108+
steps:
109+
- name: Git Checkout
110+
uses: actions/checkout@v4
111+
with:
112+
fetch-depth: 0
113+
- name: Download Artifacts
114+
uses: actions/download-artifact@v4
115+
with:
116+
name: tests-report-${{ github.sha }}
117+
- name: Sonarqube Scan
118+
uses: SonarSource/sonarqube-scan-action@v5
119+
env:
120+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
121+
122+
codeql:
123+
name: CodeQL Scan
124+
runs-on: ubuntu-latest
125+
if: github.event_name != 'pull_request'
126+
needs: build
127+
steps:
128+
- name: Git Checkout
129+
uses: actions/checkout@v4
130+
- name: CodeQL Analysis
131+
uses: github/codeql-action/init@v3
132+
with:
133+
languages: go
134+
- name: CodeQL Analysis
135+
uses: github/codeql-action/analyze@v3
136+
with:
137+
category: '/language:go'

.github/workflows/codeql.yml

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)