Skip to content

Commit 83e751f

Browse files
committed
chore(CI): enable GitHub Action
Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent ecf382b commit 83e751f

File tree

3 files changed

+161
-0
lines changed

3 files changed

+161
-0
lines changed

.github/workflows/codeql.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
name: "CodeQL"
7+
8+
on:
9+
push:
10+
branches: [ main ]
11+
pull_request:
12+
# The branches below must be a subset of the branches above
13+
branches: [ main ]
14+
schedule:
15+
- cron: '30 1 * * 0'
16+
17+
jobs:
18+
analyze:
19+
name: Analyze
20+
runs-on: ubuntu-latest
21+
22+
permissions:
23+
# required for all workflows
24+
security-events: write
25+
26+
# only required for workflows in private repositories
27+
actions: read
28+
contents: read
29+
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
# Override automatic language detection by changing the below list
34+
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
35+
# TODO: Enable for javascript later
36+
language: [ 'go']
37+
38+
steps:
39+
- name: Checkout repository
40+
uses: actions/checkout@v2
41+
42+
# Initializes the CodeQL tools for scanning.
43+
- name: Initialize CodeQL
44+
uses: github/codeql-action/init@v1
45+
with:
46+
languages: ${{ matrix.language }}
47+
# If you wish to specify custom queries, you can do so here or in a config file.
48+
# By default, queries listed here will override any specified in a config file.
49+
# Prefix the list here with "+" to use these queries and those in the config file.
50+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
51+
52+
- name: Perform CodeQL Analysis
53+
uses: github/codeql-action/analyze@v1

.github/workflows/go.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Run Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
lint:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Setup go
16+
uses: actions/setup-go@v2
17+
with:
18+
go-version: '^1'
19+
- name: Checkout repository
20+
uses: actions/checkout@v2
21+
- name: Setup golangci-lint
22+
uses: golangci/golangci-lint-action@v2
23+
with:
24+
version: v1.44.2
25+
args: --verbose
26+
test:
27+
strategy:
28+
matrix:
29+
os: [ubuntu-latest]
30+
go: [1.13, 1.14, 1.15, 1.16, 1.17]
31+
include:
32+
- os: ubuntu-latest
33+
go-build: ~/.cache/go-build
34+
name: ${{ matrix.os }} @ Go ${{ matrix.go }}
35+
runs-on: ${{ matrix.os }}
36+
env:
37+
GO111MODULE: on
38+
GOPROXY: https://proxy.golang.org
39+
steps:
40+
- name: Set up Go ${{ matrix.go }}
41+
uses: actions/setup-go@v2
42+
with:
43+
go-version: ${{ matrix.go }}
44+
45+
- name: Checkout Code
46+
uses: actions/checkout@v2
47+
with:
48+
ref: ${{ github.ref }}
49+
50+
- uses: actions/cache@v2
51+
with:
52+
path: |
53+
${{ matrix.go-build }}
54+
~/go/pkg/mod
55+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
56+
restore-keys: |
57+
${{ runner.os }}-go-
58+
- name: Run Tests
59+
run: |
60+
go test -v -covermode=atomic -coverprofile=coverage.out
61+
62+
- name: Upload coverage to Codecov
63+
uses: codecov/codecov-action@v2
64+
with:
65+
flags: ${{ matrix.os }},go-${{ matrix.go }}

.golangci.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
linters:
2+
enable-all: false
3+
disable-all: true
4+
fast: false
5+
enable:
6+
- bodyclose
7+
- deadcode
8+
- depguard
9+
- dogsled
10+
- dupl
11+
- errcheck
12+
- exportloopref
13+
- exhaustive
14+
- gochecknoinits
15+
- goconst
16+
- gocritic
17+
- gocyclo
18+
- gofmt
19+
- goimports
20+
- goprintffuncname
21+
- gosec
22+
- gosimple
23+
- govet
24+
- ineffassign
25+
- lll
26+
- misspell
27+
- nakedret
28+
- noctx
29+
- nolintlint
30+
- rowserrcheck
31+
- staticcheck
32+
- structcheck
33+
- stylecheck
34+
- typecheck
35+
- unconvert
36+
- unparam
37+
- unused
38+
- varcheck
39+
- whitespace
40+
- gofumpt
41+
42+
run:
43+
timeout: 3m

0 commit comments

Comments
 (0)