Skip to content

Commit e4d548f

Browse files
author
Michael Gasch
committed
chore: Add Github Actions and Dependabot automation
Closes: #6 Signed-off-by: Michael Gasch <[email protected]>
1 parent b943b84 commit e4d548f

File tree

5 files changed

+203
-0
lines changed

5 files changed

+203
-0
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: gomod
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
open-pull-requests-limit: 10
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "daily"
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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: [ main ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ main ]
20+
schedule:
21+
- cron: '34 21 * * 5'
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' ]
37+
# Learn more:
38+
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
39+
40+
steps:
41+
- name: Checkout repository
42+
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
43+
44+
# Initializes the CodeQL tools for scanning.
45+
- name: Initialize CodeQL
46+
uses: github/codeql-action/init@1fae5bf71b0ecdc7d0a2ef0d0c28409d99693966
47+
with:
48+
languages: ${{ matrix.language }}
49+
# If you wish to specify custom queries, you can do so here or in a config file.
50+
# By default, queries listed here will override any specified in a config file.
51+
# Prefix the list here with "+" to use these queries and those in the config file.
52+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
53+
54+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
55+
# If this step fails, then you should remove it and run the build manually (see below)
56+
- name: Autobuild
57+
uses: github/codeql-action/autobuild@1fae5bf71b0ecdc7d0a2ef0d0c28409d99693966
58+
59+
# ℹ️ Command-line programs to run using the OS shell.
60+
# 📚 https://git.io/JvXDl
61+
62+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
63+
# and modify them (or add more) to build your code if your project
64+
# uses a compiled language
65+
66+
#- run: |
67+
# make bootstrap
68+
# make release
69+
70+
- name: Perform CodeQL Analysis
71+
uses: github/codeql-action/analyze@1fae5bf71b0ecdc7d0a2ef0d0c28409d99693966

.github/workflows/dep-review.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Dependency Review
2+
3+
on:
4+
pull_request:
5+
branches: ["main"]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
dependency-review:
12+
strategy:
13+
matrix:
14+
go-version: ["1.18"]
15+
platform: ["ubuntu-latest"]
16+
runs-on: ${{ matrix.platform }}
17+
timeout-minutes: 5
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
21+
22+
- name: Dependency Review
23+
uses: actions/dependency-review-action@a9c83d3af6b9031e20feba03b904645bb23d1dab

.github/workflows/go-lint.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Code Linting
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
7+
pull_request:
8+
branches: ["main"]
9+
10+
jobs:
11+
lint:
12+
name: Code Linting
13+
strategy:
14+
matrix:
15+
go-version: ["1.18"]
16+
platform: ["ubuntu-latest"]
17+
runs-on: ${{ matrix.platform }}
18+
timeout-minutes: 5
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
22+
with:
23+
fetch-depth: 1
24+
25+
- name: Run golangci-lint
26+
uses: golangci/golangci-lint-action@537aa1903e5d359d0b27dbc19ddd22c5087f3fbc
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Unit Tests
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
7+
pull_request:
8+
branches: ["main"]
9+
10+
jobs:
11+
test:
12+
name: Unit Tests
13+
strategy:
14+
matrix:
15+
go-version: ["1.18"]
16+
platform: ["ubuntu-latest"]
17+
18+
runs-on: ${{ matrix.platform }}
19+
timeout-minutes: 5
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
24+
25+
- name: Install tparse
26+
run: go install github.com/mfridman/tparse@latest
27+
28+
- name: Set up Go ${{ matrix.go-version }}
29+
uses: actions/setup-go@fcdc43634adb5f7ae75a9d7a9b9361790f7293e2
30+
with:
31+
go-version: ${{ matrix.go-version }}
32+
id: go
33+
34+
- name: Restore Go cache
35+
uses: actions/cache@48af2dc4a9e8278b89d7fa154b955c30c6aaab09
36+
with:
37+
path: |
38+
~/.cache/go-build
39+
~/go/pkg/mod
40+
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
41+
restore-keys: |
42+
${{ runner.os }}-go-${{ matrix.go-version }}-
43+
44+
- name: Check for .codecov.yaml
45+
id: codecov-enabled
46+
uses: andstor/file-existence-action@f02338908d150e00a4b8bebc2dad18bd9e5229b0
47+
with:
48+
files: .codecov.yaml
49+
50+
- if: steps.codecov-enabled.outputs.files_exists == 'true'
51+
name: Enable Go Coverage
52+
run: echo 'COVER_OPTS=-coverprofile=coverage.txt -covermode=atomic' >> $GITHUB_ENV
53+
54+
- name: Test
55+
env:
56+
GOFLAGS: "-v -race -count=1 -json"
57+
run: go test $COVER_OPTS ./... | tparse -all
58+
59+
- name: Verify git clean
60+
shell: bash
61+
run: |
62+
if [[ -z "$(git status --porcelain)" ]]; then
63+
echo "${{ github.repository }} up to date."
64+
else
65+
echo "${{ github.repository }} is dirty."
66+
echo "::error:: $(git status)"
67+
exit 1
68+
fi
69+
70+
- if: steps.codecov-enabled.outputs.files_exists == 'true'
71+
name: Produce Codecov Report
72+
uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378

0 commit comments

Comments
 (0)