Skip to content

Commit 7c4725c

Browse files
committed
Add CodeQL & test coverage on PRs
1 parent 649bbe7 commit 7c4725c

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
# under the License.
1717

1818
name: Test-Build
19+
permissions:
20+
contents: read
1921

2022
on: [push, pull_request]
2123

@@ -38,3 +40,8 @@ jobs:
3840
- name: Run Script
3941
run: make test
4042

43+
- name: Upload coverage to Codecov
44+
uses: codecov/codecov-action@v5
45+
with:
46+
token: ${{ secrets.CODECOV_TOKEN }}
47+
file: 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

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)