Skip to content

Commit 6df29fc

Browse files
committed
workflow: Add code format specification check and unit test check.
1 parent 4f8f52a commit 6df29fc

File tree

5 files changed

+113
-20
lines changed

5 files changed

+113
-20
lines changed

.github/workflows/auto_build_operator.yml

+8-11
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ on:
66
paths:
77
- cmd/manager/*
88
- api/*
9-
- mysqlcluster/*
10-
- mysqlcluster/container/*
11-
- mysqlcluster/syncer/*
9+
- mysqlcluster/**
1210
- controllers/*
1311
- internal/*
1412
- utils/*
@@ -20,20 +18,19 @@ jobs:
2018
build:
2119
runs-on: ubuntu-latest
2220
steps:
23-
-
24-
name: Set up QEMU
21+
- name: Set up QEMU
2522
uses: docker/setup-qemu-action@v1
26-
-
27-
name: Set up Docker Buildx
23+
24+
- name: Set up Docker Buildx
2825
uses: docker/setup-buildx-action@v1
29-
-
30-
name: Login to DockerHub
26+
27+
- name: Login to DockerHub
3128
uses: docker/login-action@v1
3229
with:
3330
username: ${{ secrets.DOCKERHUB_USERNAME }}
3431
password: ${{ secrets.DOCKERHUB_TOKEN }}
35-
-
36-
name: Build and push
32+
33+
- name: Build and push
3734
id: docker_build
3835
uses: docker/build-push-action@v2
3936
with:

.github/workflows/auto_build_sidecar.yml

+7-8
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,19 @@ jobs:
1313
build:
1414
runs-on: ubuntu-latest
1515
steps:
16-
-
17-
name: Set up QEMU
16+
- name: Set up QEMU
1817
uses: docker/setup-qemu-action@v1
19-
-
20-
name: Set up Docker Buildx
18+
19+
- name: Set up Docker Buildx
2120
uses: docker/setup-buildx-action@v1
22-
-
23-
name: Login to DockerHub
21+
22+
- name: Login to DockerHub
2423
uses: docker/login-action@v1
2524
with:
2625
username: ${{ secrets.DOCKERHUB_USERNAME }}
2726
password: ${{ secrets.DOCKERHUB_TOKEN }}
28-
-
29-
name: Build and push
27+
28+
- name: Build and push
3029
id: docker_build
3130
uses: docker/build-push-action@v2
3231
with:

.github/workflows/code_check.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: code check
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
7+
gofmt:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Set up Go
11+
uses: actions/setup-go@v2
12+
with:
13+
go-version: 1.16
14+
15+
- name: Check out source code
16+
uses: actions/checkout@v1
17+
18+
- name: run go fmt
19+
run: d="$(gofmt -d ../../)" && if [ -n "$d" ]; then echo "Format error:" ; echo "$d"; exit 1; fi
20+
21+
22+
check-crd:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Set up Go
26+
uses: actions/setup-go@v2
27+
with:
28+
go-version: 1.16
29+
30+
- name: Check out source code
31+
uses: actions/checkout@v1
32+
33+
- name: recreate crd
34+
run: make manifests
35+
36+
- name: check crd
37+
run: diff charts/mysql-operator/crds config/crd/bases
38+
39+
staticcheck:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Set up Go
43+
uses: actions/setup-go@v2
44+
with:
45+
go-version: 1.16
46+
47+
- name: Check out source code
48+
uses: actions/checkout@v1
49+
50+
- name: install staticcheck
51+
run: go install honnef.co/go/tools/cmd/staticcheck@latest
52+
53+
- name: run staticcheck
54+
run: staticcheck -f stylish ./...

.github/workflows/greetings.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Greetings
1+
name: greetings
22

33
on: issues
44

.github/workflows/unit_tests.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: unit tests
2+
3+
on:
4+
push:
5+
branches: [ main, fmt_ci]
6+
paths:
7+
- mysqlcluster/**
8+
- utils/*
9+
pull_request:
10+
branches: [ main, fmt_ci ]
11+
paths:
12+
- mysqlcluster/**
13+
- utils/*
14+
15+
jobs:
16+
17+
test-cluster:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Set up Go
21+
uses: actions/setup-go@v2
22+
with:
23+
go-version: 1.16
24+
25+
- name: Check out source code
26+
uses: actions/checkout@v1
27+
28+
- name: run test
29+
run: go test ./mysqlcluster/container/ ./mysqlcluster/ -v -cover
30+
31+
test-utils:
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Set up Go
35+
uses: actions/setup-go@v2
36+
with:
37+
go-version: 1.16
38+
39+
- name: Check out source code
40+
uses: actions/checkout@v1
41+
42+
- name: run test
43+
run: go test ./utils/ -v -cover

0 commit comments

Comments
 (0)