Skip to content

Commit

Permalink
feat: add ci
Browse files Browse the repository at this point in the history
thinkgos committed Apr 22, 2024
1 parent 934347b commit f188e6c
Showing 9 changed files with 234 additions and 1 deletion.
17 changes: 17 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
commit-message:
prefix: "chore"
include: "scope"

- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
commit-message:
prefix: "chore"
include: "scope"
68 changes: 68 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Tests

on:
push:
paths-ignore:
- "**.md"
pull_request:
paths-ignore:
- "**.md"

env:
GO111MODULE: on
GOPROXY: "https://proxy.golang.org"

jobs:
build:
name: Test on ${{ matrix.os }} @Go${{ matrix.go-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: ["1.21.x", "1.22.x"]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
cache: false

- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Print Go environment
id: vars
run: |
printf "Using go at: $(which go)\n"
printf "Go version: $(go version)\n"
printf "\n\nGo environment:\n\n"
go env
printf "\n\nSystem environment:\n\n"
env
# Calculate the short SHA1 hash of the git commit
echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "go_cache=$(go env GOCACHE)" >> $GITHUB_OUTPUT
- name: Cache go modules
uses: actions/cache@v4
with:
path: |
${{ steps.vars.outputs.GO_CACHE }}
~/go/pkg/mod
key: ${{ runner.os }}-${{ matrix.go-version }}-go-ci-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ matrix.go-version }}-go-ci-
- name: Unit test
run: |
go test -v -race -coverprofile=coverage -covermode=atomic ./...
- name: Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v4
with:
files: ./coverage
flags: unittests
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
51 changes: 51 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: CodeQL

on:
push:
paths-ignore:
- "**.md"
pull_request:
paths-ignore:
- "**.md"
schedule:
- cron: "0 5 * * 6"

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
18 changes: 18 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Lint

on:
push:
paths-ignore:
- "**.md"

jobs:
golang-ci:
name: GolangCi-Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v4
with: # BUG: typecheck error when enable all
args: --disable-all -E goimports,misspell,whitespace
version: latest
26 changes: 26 additions & 0 deletions .github/workflows/pr_review_dog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Reviewdog

on:
pull_request:
paths-ignore:
- "**.md"

jobs:
golangci-lint:
name: runner / golangci-lint
runs-on: ubuntu-latest
steps:
# optionally use a specific version of Go rather than the default one
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22.x"

- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: golangci-lint
uses: reviewdog/action-golangci-lint@v2
with: # BUG: typecheck error when enable all
args: --disable-all -E goimports,misspell,whitespace
version: latest
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: goreleaser

on:
push:
# run only against tags
tags:
- "*"

permissions:
contents: write
# packages: write
# issues: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- run: git fetch --force --tags
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ">=1.22.0"
cache: true
# More assembly might be required: Docker logins, GPG, etc. It all depends
# on your needs.
- name: Release binary
uses: goreleaser/goreleaser-action@v5
with:
# either 'goreleaser' (default) or 'goreleaser-pro':
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro'
# distribution:
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# proc

`proc` annotation syntax:
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/thinkgos/proc

go 1.22.2

require github.com/alecthomas/participle/v2 v2.1.1
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
github.com/alecthomas/assert/v2 v2.3.0 h1:mAsH2wmvjsuvyBvAmCtm7zFsBlb8mIHx5ySLVdDZXL0=
github.com/alecthomas/assert/v2 v2.3.0/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ=
github.com/alecthomas/participle/v2 v2.1.1 h1:hrjKESvSqGHzRb4yW1ciisFJ4p3MGYih6icjJvbsmV8=
github.com/alecthomas/participle/v2 v2.1.1/go.mod h1:Y1+hAs8DHPmc3YUFzqllV+eSQ9ljPTk0ZkPMtEdAx2c=
github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk=
github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=

0 comments on commit f188e6c

Please sign in to comment.