Skip to content

Commit f1b107c

Browse files
committed
chore(CI/CD): Enabled GitHub Actions
Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent 0d76a12 commit f1b107c

File tree

4 files changed

+165
-0
lines changed

4 files changed

+165
-0
lines changed

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: weekly
7+
- package-ecosystem: gomod
8+
directory: /
9+
schedule:
10+
interval: weekly

.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@v3
41+
42+
# Initializes the CodeQL tools for scanning.
43+
- name: Initialize CodeQL
44+
uses: github/codeql-action/init@v2
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@v2

.github/workflows/go.yml

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

.github/workflows/goreleaser.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Goreleaser
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
goreleaser:
13+
runs-on: ubuntu-latest
14+
steps:
15+
-
16+
name: Checkout
17+
uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0
20+
-
21+
name: Set up Go
22+
uses: actions/setup-go@v2
23+
with:
24+
go-version: 1.17
25+
-
26+
name: Run GoReleaser
27+
uses: goreleaser/goreleaser-action@v3
28+
with:
29+
# either 'goreleaser' (default) or 'goreleaser-pro'
30+
distribution: goreleaser
31+
version: latest
32+
args: release --rm-dist
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)