Skip to content

Commit 8c3a8fb

Browse files
author
houyuxi
committed
ci: add test jobs
Signed-off-by: houyuxi <yuxi.hou@transwarp.io>
1 parent f14c9d2 commit 8c3a8fb

2 files changed

Lines changed: 51 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,52 @@ env:
1717
GO_VERSION: "1.22.5"
1818

1919
jobs:
20+
lint:
21+
name: lint
22+
runs-on: ubuntu-22.04
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
with:
27+
submodules: recursive
28+
- name: Install Go
29+
uses: actions/setup-go@v5
30+
with:
31+
go-version: ${{ env.GO_VERSION }}
32+
- name: Go tidy
33+
run: make tidy
34+
- name: golangci-lint
35+
uses: golangci/golangci-lint-action@v6
36+
with:
37+
version: v1.61.0
38+
39+
test:
40+
name: Unit test
41+
needs: [ lint ]
42+
runs-on: ubuntu-22.04
43+
steps:
44+
- name: Checkout code
45+
uses: actions/checkout@v4
46+
with:
47+
submodules: recursive
48+
- name: Install Go
49+
uses: actions/setup-go@v5
50+
with:
51+
go-version: ${{ env.GO_VERSION }}
52+
- name: Go tidy
53+
run: make tidy
54+
- name: Run tests
55+
run: make test
56+
- name: Upload coverage to Codecov
57+
if: ${{ github.repository == 'Project-HAMi/ascend-device-plugin' }}
58+
uses: codecov/codecov-action@v4
59+
with:
60+
token: ${{ secrets.CODECOV_TOKEN }}
61+
files: ./_output/coverage/coverage.out
62+
flags: unittests
63+
fail_ci_if_error: false
64+
verbose: true
65+
2066
build-vnpu:
2167
runs-on: ubuntu-22.04-arm
2268
container:
@@ -49,7 +95,7 @@ jobs:
4995
env:
5096
IMAGE_NAME: ${{ secrets.IMAGE_NAME || 'projecthami/ascend-device-plugin' }}
5197
runs-on: ubuntu-latest
52-
needs: ["build-vnpu"]
98+
needs: ["build-vnpu", "test"]
5399
steps:
54100
- uses: actions/checkout@v4
55101
with:

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ all: ascend-device-plugin
88
tidy:
99
$(GO) mod tidy
1010

11+
test:
12+
$(GO) test -v -coverprofile=_output/coverage/coverage.out ./...
13+
1114
docker:
1215
docker build \
1316
--build-arg BASE_IMAGE=ubuntu:20.04 \
@@ -24,4 +27,4 @@ ascend-device-plugin:
2427
clean:
2528
rm -rf ./ascend-device-plugin
2629

27-
.PHONY: all clean
30+
.PHONY: all tidy test lint clean

0 commit comments

Comments
 (0)