-
-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (86 loc) · 2.6 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: CI
on:
push:
branches: ["*"]
tags: ["v*"]
pull_request:
branches: ["*"]
permissions:
contents: write
jobs:
build:
name: "Build"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23"
- name: Install dependencies
run: go get .
- name: Build
run: go build -v ./...
test:
name: "Test"
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23"
- name: Create a .env.test file
run: |
touch .env.test
echo "CS_API_KEY=\"${{ vars.CS_API_KEY }}\"" >> .env.test
echo "CS_DELIVERY_TOKEN=\"${{ vars.CS_DELIVERY_TOKEN }}\"" >> .env.test
echo "CS_MANAGEMENT_TOKEN=\"${{ vars.CS_MANAGEMENT_TOKEN }}\"" >> .env.test
echo "CS_BRANCH=\"${{ vars.CS_BRANCH }}\"" >> .env.test
echo "CS_REGION=\"${{ vars.CS_REGION }}\"" >> .env.test
echo "DB_CONN=\"file:db_test.sqlite3\"" >> .env.test
echo "DB_TYPE=\"sqlite3\"" >> .env.test
- name: Create a test results directory
run: mkdir test-results
- name: Run tests
run: |
go test "./..." -coverprofile="test-results/coverage.out" -covermode=count -json > test-results/test-report.out
- name: Delete the .env.test file after tests are completed
run: rm .env.test
- uses: actions/upload-artifact@v4
with:
name: test-results
path: test-results/
sonar-scan:
name: "SonarQube Scan"
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
- name: SonarQube Scan
uses: SonarSource/sonarqube-scan-action@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
deploy:
name: "Release"
needs: [build, test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install "syft"
run: |
/bin/bash -c "curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin"
- name: "Run GoReleaser"
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if:
startsWith(github.ref, 'refs/tags/')