Skip to content

Commit 5da36a7

Browse files
committed
Add CodeQL & test coverage on PRs
1 parent 649bbe7 commit 5da36a7

File tree

4 files changed

+84
-1
lines changed

4 files changed

+84
-1
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
name: Test-Build
1919

20+
permissions:
21+
contents: read
22+
2023
on: [push, pull_request]
2124

2225
concurrency:
@@ -38,3 +41,8 @@ jobs:
3841
- name: Run Script
3942
run: make test
4043

44+
- name: Upload coverage to Codecov
45+
uses: codecov/codecov-action@v5
46+
with:
47+
token: ${{ secrets.CODECOV_TOKEN }}
48+
files: coverage.txt
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
name: CodeQL Analysis
19+
on:
20+
push:
21+
branches: [main]
22+
pull_request:
23+
branches: [main]
24+
permissions:
25+
actions: read
26+
contents: read
27+
security-events: write
28+
jobs:
29+
codeql:
30+
name: CodeQL
31+
runs-on: ubuntu-latest
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
language: ["actions", "go"]
36+
steps:
37+
- name: Checkout repository
38+
uses: actions/checkout@v6
39+
- name: Initialize CodeQL
40+
uses: github/codeql-action/init@v4
41+
with:
42+
languages: ${{ matrix.language }}
43+
- name: Autobuild
44+
uses: github/codeql-action/autobuild@v4
45+
- name: Perform CodeQL Analysis
46+
uses: github/codeql-action/analyze@v4

.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,31 @@
11
/cloudstack-ccm
22

3+
# Binaries for programs and plugins
4+
*.exe
5+
*.exe~
6+
*.dll
7+
*.so
8+
*.dylib
9+
10+
# Test binary, built with `go test -c`
11+
*.test
12+
13+
# Code coverage profiles and other test artifacts
14+
*.out
15+
coverage.*
16+
*.coverprofile
17+
profile.cov
18+
19+
# Dependency directories (remove the comment below to include it)
20+
# vendor/
21+
22+
# Go workspace file
23+
go.work
24+
go.work.sum
25+
26+
# env file
27+
.env
28+
29+
# Editor/IDE
30+
.idea/
31+
.vscode/

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ cloudstack-ccm: ${CMD_SRC}
4343
go build -ldflags ${LDFLAGS} -o $@ $^
4444

4545
test: gofmt
46-
go test -v
46+
go test -v -coverprofile=coverage.txt -covermode=atomic
4747
go vet
4848

4949
docker: gofmt

0 commit comments

Comments
 (0)