Skip to content

Commit e779000

Browse files
committed
ci(github): migrate CI/CD from Drone to GitHub Actions
- Remove `.drone.yml` file - Add Dependabot configuration for GitHub Actions and Go modules with a weekly update schedule - Add CodeQL analysis workflow for Go language - Add GitHub Actions workflow to run tests on push and pull requests for the `master` branch - Add GitHub Actions workflow for GoReleaser to run on tag push Signed-off-by: appleboy <[email protected]>
1 parent 0d8912d commit e779000

File tree

5 files changed

+167
-69
lines changed

5 files changed

+167
-69
lines changed

.drone.yml

Lines changed: 0 additions & 69 deletions
This file was deleted.

.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.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [master]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [master]
20+
schedule:
21+
- cron: "41 23 * * 6"
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
permissions:
28+
actions: read
29+
contents: read
30+
security-events: write
31+
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
language: ["go"]
36+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37+
# Learn more about CodeQL language support at https://git.io/codeql-language-support
38+
39+
steps:
40+
- name: Checkout repository
41+
uses: actions/checkout@v4
42+
43+
# Initializes the CodeQL tools for scanning.
44+
- name: Initialize CodeQL
45+
uses: github/codeql-action/init@v3
46+
with:
47+
languages: ${{ matrix.language }}
48+
# If you wish to specify custom queries, you can do so here or in a config file.
49+
# By default, queries listed here will override any specified in a config file.
50+
# Prefix the list here with "+" to use these queries and those in the config file.
51+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
52+
53+
- name: Perform CodeQL Analysis
54+
uses: github/codeql-action/analyze@v3

.github/workflows/go.yml

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

.github/workflows/goreleaser.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Setup go
21+
uses: actions/setup-go@v5
22+
with:
23+
go-version-file: go.mod
24+
check-latest: true
25+
- name: Run GoReleaser
26+
uses: goreleaser/goreleaser-action@v6
27+
with:
28+
# either 'goreleaser' (default) or 'goreleaser-pro'
29+
distribution: goreleaser
30+
version: latest
31+
args: release --clean
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)