Skip to content

Commit fd50737

Browse files
authored
Merge pull request #238 from smlx/update-ci
Update CI workflows
2 parents de8c9be + c5225e8 commit fd50737

23 files changed

+339
-246
lines changed

.github/commitlint.config.mjs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* Taken from: https://github.com/wagoid/commitlint-github-action/blob/7f0a61df502599e1f1f50880aaa7ec1e2c0592f2/commitlint.config.mjs */
2+
/* eslint-disable import/no-extraneous-dependencies */
3+
import { maxLineLength } from '@commitlint/ensure'
4+
5+
const bodyMaxLineLength = 100
6+
7+
const validateBodyMaxLengthIgnoringDeps = (parsedCommit) => {
8+
const { type, scope, body } = parsedCommit
9+
const isDepsCommit =
10+
type === 'chore' && (scope === 'deps' || scope === 'deps-dev')
11+
12+
return [
13+
isDepsCommit || !body || maxLineLength(body, bodyMaxLineLength),
14+
`body's lines must not be longer than ${bodyMaxLineLength}`,
15+
]
16+
}
17+
18+
export default {
19+
extends: ['@commitlint/config-conventional'],
20+
plugins: ['commitlint-plugin-function-rules'],
21+
rules: {
22+
'body-max-line-length': [0],
23+
'function-rules/body-max-line-length': [
24+
2,
25+
'always',
26+
validateBodyMaxLengthIgnoringDeps,
27+
],
28+
},
29+
}

.github/dependabot.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
commit-message:
5+
prefix: chore
6+
include: scope
7+
directory: /
8+
schedule:
9+
interval: monthly
10+
groups:
11+
github-actions:
12+
patterns:
13+
- "*"
14+
update-types:
15+
- "minor"
16+
- "patch"
17+
- package-ecosystem: docker
18+
commit-message:
19+
prefix: chore
20+
include: scope
21+
directory: /
22+
schedule:
23+
interval: monthly
24+
groups:
25+
docker:
26+
patterns:
27+
- "*"
28+
update-types:
29+
- "minor"
30+
- "patch"
31+
- package-ecosystem: gomod
32+
commit-message:
33+
prefix: chore
34+
include: scope
35+
directory: /
36+
schedule:
37+
interval: monthly
38+
groups:
39+
gomod:
40+
patterns:
41+
- "*"
42+
update-types:
43+
- "minor"
44+
- "patch"

.github/dependabot.yml

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

.github/dependency-review-config.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# https://github.com/cncf/foundation/blob/main/allowed-third-party-license-policy.md
2+
allow-licenses:
3+
- 'Apache-2.0'
4+
- 'BSD-2-Clause'
5+
- 'BSD-2-Clause-FreeBSD'
6+
- 'BSD-3-Clause'
7+
- 'ISC'
8+
- 'MIT'
9+
- 'PostgreSQL'
10+
- 'Python-2.0'
11+
- 'X11'
12+
- 'Zlib'
13+
14+
allow-dependencies-licenses:
15+
# this action is GPL-3 but it is only used in CI
16+
# https://github.com/actions/dependency-review-action/issues/530#issuecomment-1638291806
17+
- pkg:githubactions/vladopajic/go-test-coverage@bcd064e5ceef1ccec5441519eb054263b6a44787
18+
# this package is MPL-2.0 and has a CNCF exception
19+
# https://github.com/cncf/foundation/blob/9b8c9173c2101c1b4aedad3caf2c0128715133f6/license-exceptions/cncf-exceptions-2022-04-12.json#L43C17-L43C47
20+
- pkg:golang/github.com/go-sql-driver/mysql

.github/workflows/build.yaml

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,49 @@
1-
name: Build
2-
on: pull_request
1+
name: build
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
permissions: {}
37
jobs:
4-
build:
8+
build-snapshot:
9+
permissions:
10+
contents: read
511
strategy:
612
matrix:
713
os:
814
- ubuntu-latest
915
- macos-latest
1016
runs-on: ${{ matrix.os }}
1117
steps:
12-
- name: Checkout
13-
uses: actions/checkout@v4
14-
- name: Install Go
15-
uses: actions/setup-go@v5
18+
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
19+
with:
20+
ref: ${{ github.event.pull_request.head.sha }}
21+
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
1622
with:
1723
go-version: stable
1824
- name: Install Dependencies (ubuntu)
1925
if: matrix.os == 'ubuntu-latest'
2026
run: sudo apt-get update && sudo apt-get -u install libpcsclite-dev
21-
- name: Set up environment
22-
run: echo "GOVERSION=$(go version)" >> $GITHUB_ENV
23-
- name: Run GoReleaser
24-
uses: goreleaser/goreleaser-action@v5
27+
- uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6.0.0
28+
id: goreleaser
2529
with:
2630
version: latest
27-
args: build --snapshot --rm-dist --config .goreleaser.${{ matrix.os }}.yml
31+
args: build --clean --verbose --snapshot --config .goreleaser.${{ matrix.os }}.yaml
32+
check-tag:
33+
permissions:
34+
contents: read
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
38+
with:
39+
fetch-depth: 0
40+
- id: ccv
41+
uses: smlx/ccv@d3de774e9b607b079940a7a86952f44643743336 # v0.9.0
42+
with:
43+
write-tag: false
44+
- run: |
45+
echo "new-tag=$NEW_TAG"
46+
echo "new-tag-version=$NEW_TAG_VERSION"
47+
env:
48+
NEW_TAG: ${{steps.ccv.outputs.new-tag}}
49+
NEW_TAG_VERSION: ${{steps.ccv.outputs.new-tag-version}}

.github/workflows/codeql-analysis.yaml

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

.github/workflows/coverage.yaml

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
1-
name: Coverage
1+
name: coverage
22
on:
33
push:
44
branches:
55
- main
6-
6+
permissions: {}
77
jobs:
88
coverage:
9+
permissions:
10+
contents: write
911
runs-on: ubuntu-latest
1012
steps:
11-
- name: Checkout repository
12-
uses: actions/checkout@v4
13-
- name: Configure git
14-
run: |
15-
git config --global user.name "$GITHUB_ACTOR"
16-
git config --global user.email "[email protected]"
17-
- name: Set up go
18-
uses: actions/setup-go@v5
13+
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
14+
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
1915
with:
2016
go-version: stable
2117
- name: Install Dependencies
2218
run: sudo apt-get update && sudo apt-get -u install libpcsclite-dev
2319
- name: Calculate coverage
2420
run: |
25-
go test -v -covermode=count -coverprofile=coverage.out.raw -coverpkg=./... ./...
26-
grep -v mock_ coverage.out.raw > coverage.out
27-
- name: Convert coverage to lcov
28-
uses: jandelgado/[email protected]
29-
- name: Coveralls
30-
uses: coverallsapp/[email protected]
21+
go test -v -covermode=atomic -coverprofile=cover.out.raw -coverpkg=./... ./...
22+
# remove generated code from coverage calculation
23+
grep -Ev 'internal/mock|_enumer.go' cover.out.raw > cover.out
24+
- name: Generage coverage badge
25+
uses: vladopajic/go-test-coverage@1079cd4e58dda229c04ffdb6324fc3756b8542ff # v2.10.1
3126
with:
32-
github-token: ${{ secrets.github_token }}
27+
profile: cover.out
28+
local-prefix: github.com/${{ github.repository }}
29+
git-token: ${{ secrets.GITHUB_TOKEN }}
30+
# orphan branch for storing badges
31+
git-branch: badges

.github/workflows/dependabot-automerge.yaml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#enable-auto-merge-on-a-pull-request
2-
name: Dependabot auto-merge
3-
on: pull_request
4-
5-
permissions:
6-
contents: write
7-
pull-requests: write
8-
2+
name: dependabot auto-merge
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
permissions: {}
98
jobs:
10-
dependabot:
9+
dependabot-automerge:
10+
permissions:
11+
contents: write
12+
pull-requests: write
1113
runs-on: ubuntu-latest
12-
if: ${{ github.actor == 'dependabot[bot]' }}
14+
if: github.actor == 'dependabot[bot]'
1315
steps:
14-
- name: Enable auto-merge for Dependabot PRs
16+
- name: Fetch dependabot metadata
17+
id: metadata
18+
uses: dependabot/fetch-metadata@5e5f99653a5b510e8555840e80cbf1514ad4af38 # v2.1.0
19+
with:
20+
github-token: "${{ secrets.GITHUB_TOKEN }}"
21+
- name: Enable auto-merge for Dependabot PRs # these still need approval before merge
1522
run: gh pr merge --auto --merge "$PR_URL"
1623
env:
1724
PR_URL: ${{github.event.pull_request.html_url}}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: dependency review
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
permissions: {}
7+
jobs:
8+
dependency-review:
9+
permissions:
10+
contents: read
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
14+
- uses: actions/dependency-review-action@72eb03d02c7872a771aacd928f3123ac62ad6d3a # v4.3.3
15+
with:
16+
config-file: .github/dependency-review-config.yaml

.github/workflows/lint.yaml

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,42 @@
1-
name: Lint
2-
on: pull_request
1+
name: lint
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
permissions: {}
37
jobs:
4-
golangci-lint:
5-
name: lint
8+
lint-go:
9+
permissions:
10+
contents: read
611
runs-on: ubuntu-latest
712
steps:
8-
- name: Checkout
9-
uses: actions/checkout@v4
10-
- name: Install Dependencies
11-
run: sudo apt-get update && sudo apt-get -u install libpcsclite-dev
12-
- name: Install Go
13-
uses: actions/setup-go@v5
13+
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
14+
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
1415
with:
1516
go-version: stable
16-
- name: golangci-lint
17-
uses: golangci/golangci-lint-action@v5
17+
- name: Install Dependencies
18+
run: sudo apt-get update && sudo apt-get -u install libpcsclite-dev
19+
- uses: golangci/golangci-lint-action@a4f60bb28d35aeee14e6880718e0c85ff1882e64 # v6.0.1
1820
with:
19-
version: latest
20-
commitlint:
21+
args: --timeout=180s --enable gocritic
22+
lint-commits:
23+
permissions:
24+
contents: read
25+
pull-requests: read
2126
runs-on: ubuntu-latest
2227
steps:
23-
- name: Checkout
24-
uses: actions/checkout@v4
28+
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
2529
with:
2630
fetch-depth: 0
27-
- name: Lint commit messages
28-
uses: wagoid/[email protected]
31+
- uses: wagoid/commitlint-github-action@7f0a61df502599e1f1f50880aaa7ec1e2c0592f2 # v6.0.1
32+
with:
33+
configFile: .github/commitlint.config.mjs
34+
lint-actions:
35+
permissions:
36+
contents: read
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
40+
- uses: docker://rhysd/actionlint:1.7.0@sha256:601d6faeefa07683a4a79f756f430a1850b34d575d734b1d1324692202bf312e # v1.7.0
41+
with:
42+
args: -color

0 commit comments

Comments
 (0)