Skip to content

Commit

Permalink
chore(ci): setup (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
powerman authored Jun 21, 2023
1 parent f800747 commit 94eda5c
Show file tree
Hide file tree
Showing 14 changed files with 2,376 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# /name - apply (* doesn't match /) to file "name" beginning in project root
# na/me - apply (* doesn't match /) to file "na/me" anywhere
# name - apply (* do match /) to file "name" anywhere
# name/** - apply … to dir …
# **/name - apply (* doesn't match /) to file "name" in any dir including project root
# na/**/me - apply (* doesn't match /) to file "na/me", "na/*/me", "na/*/*/me", …
go.sum binary
*.*.go binary
3 changes: 3 additions & 0 deletions .github/commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
};
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 2
updates:
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: 'daily'
commit-message:
prefix: 'chore(ci):'
- package-ecosystem: 'gomod'
directory: '/'
schedule:
interval: 'daily'
commit-message:
prefix: 'chore(deps):'
open-pull-requests-limit: 10
62 changes: 62 additions & 0 deletions .github/workflows/CI&CD.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: CI/CD

on:
push:
branches: master
tags: v*
pull_request:
branches: master
schedule:
- cron: '0 12 * * 6'

jobs:

test:
runs-on: 'ubuntu-latest'
timeout-minutes: 30
strategy:
matrix:
go:
- '^1.20' # Also used for goveralls.
- 'tip'

steps:
- uses: actions/setup-go@v3
if: matrix.go != 'tip'
with:
go-version: ${{ matrix.go }}

- name: Install Go tip
if: matrix.go == 'tip'
run: |
mkdir "$HOME/gotip"
curl -sL https://storage.googleapis.com/go-build-snap/go/linux-amd64/$(git ls-remote https://github.com/golang/go.git HEAD | awk '{print $1}').tar.gz -o - | tar -C "$HOME/gotip" -xzf -
echo "GOROOT=$HOME/gotip" >> $GITHUB_ENV
echo "$HOME/gotip/bin" >> $GITHUB_PATH
- run: go version

- uses: actions/checkout@v3

- uses: actions/cache@v3
with:
path: |
~/go/bin
~/go/pkg
~/go/src
~/.cache/go-build
~/.cache/golangci-lint
.buildcache
key: v4-test-${{ runner.os }}-${{ hashFiles('go.mod') }}-${{ hashFiles('tools.go') }}
restore-keys: |
v4-test-${{ runner.os }}-
- run: go generate
- run: .buildcache/bin/golangci-lint run
- run: go test -race ./...

- name: Report code coverage
env:
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
if: env.COVERALLS_TOKEN && matrix.go == '^1.20'
run: .buildcache/bin/goveralls -service=GitHub
31 changes: 31 additions & 0 deletions .github/workflows/Create-GitHub-Release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Create GitHub Release

on:
push:
tags: v*

jobs:

create-release:
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Generate changelog
id: changelog
uses: metcalfc/changelog-generator@v3.0.0
with:
myToken: ${{ secrets.GITHUB_TOKEN }}

- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: ${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: false
21 changes: 21 additions & 0 deletions .github/workflows/Lint-PR-name.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Lint PR name

on:
pull_request:
branches: master
types: [ opened, edited, synchronize, reopened ]

jobs:

lint-PR-name:
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- uses: actions/checkout@v3

- name: Install Dependencies
run: npm install @commitlint/config-conventional

- uses: JulienKode/pull-request-name-linter-action@v0.5.0
with:
configuration-path: '.github/commitlint.config.js'
14 changes: 14 additions & 0 deletions .github/workflows/Update-Go-doc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Update Go module doc

on:
push:
tags: v*

jobs:

update-doc:
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- name: Pull new module version
uses: andrewslotin/go-proxy-pull-action@master
62 changes: 62 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: "CodeQL"

on:
push:
branches: [master]
#pull_request:
# The branches below must be a subset of the branches above
#branches: [master]
schedule:
- cron: '0 12 * * 5'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
# Override automatic language detection by changing the below list
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
language: ['go']
# Learn more...
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection

steps:
- name: Checkout repository
uses: actions/checkout@v3
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

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}

# 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@v2

# ℹ️ 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@v2
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# /name - exclude path (* doesn't match /) to file/dir "name" beginning in project root
# na/me - exclude path (* doesn't match /) to file/dir "na/me" anywhere
# name - exclude path (* do match /) to file/dir "name" anywhere
# name/ - exclude path … to dir …
# **/name - exclude path (* doesn't match /) to file/dir "name" in any dir including project root
# na/**/me - exclude path (* doesn't match /) to file/dir "na/me", "na/*/me", "na/*/*/me", …
# !name - include previously excluded path …
/.buildcache/
/cover.out
Loading

0 comments on commit 94eda5c

Please sign in to comment.