Skip to content

Commit

Permalink
Merge pull request #238 from smlx/update-ci
Browse files Browse the repository at this point in the history
Update CI workflows
  • Loading branch information
smlx authored Jun 28, 2024
2 parents de8c9be + c5225e8 commit fd50737
Show file tree
Hide file tree
Showing 23 changed files with 339 additions and 246 deletions.
29 changes: 29 additions & 0 deletions .github/commitlint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* Taken from: https://github.com/wagoid/commitlint-github-action/blob/7f0a61df502599e1f1f50880aaa7ec1e2c0592f2/commitlint.config.mjs */
/* eslint-disable import/no-extraneous-dependencies */
import { maxLineLength } from '@commitlint/ensure'

const bodyMaxLineLength = 100

const validateBodyMaxLengthIgnoringDeps = (parsedCommit) => {
const { type, scope, body } = parsedCommit
const isDepsCommit =
type === 'chore' && (scope === 'deps' || scope === 'deps-dev')

return [
isDepsCommit || !body || maxLineLength(body, bodyMaxLineLength),
`body's lines must not be longer than ${bodyMaxLineLength}`,
]
}

export default {
extends: ['@commitlint/config-conventional'],
plugins: ['commitlint-plugin-function-rules'],
rules: {
'body-max-line-length': [0],
'function-rules/body-max-line-length': [
2,
'always',
validateBodyMaxLengthIgnoringDeps,
],
},
}
44 changes: 44 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
version: 2
updates:
- package-ecosystem: github-actions
commit-message:
prefix: chore
include: scope
directory: /
schedule:
interval: monthly
groups:
github-actions:
patterns:
- "*"
update-types:
- "minor"
- "patch"
- package-ecosystem: docker
commit-message:
prefix: chore
include: scope
directory: /
schedule:
interval: monthly
groups:
docker:
patterns:
- "*"
update-types:
- "minor"
- "patch"
- package-ecosystem: gomod
commit-message:
prefix: chore
include: scope
directory: /
schedule:
interval: monthly
groups:
gomod:
patterns:
- "*"
update-types:
- "minor"
- "patch"
14 changes: 0 additions & 14 deletions .github/dependabot.yml

This file was deleted.

20 changes: 20 additions & 0 deletions .github/dependency-review-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# https://github.com/cncf/foundation/blob/main/allowed-third-party-license-policy.md
allow-licenses:
- 'Apache-2.0'
- 'BSD-2-Clause'
- 'BSD-2-Clause-FreeBSD'
- 'BSD-3-Clause'
- 'ISC'
- 'MIT'
- 'PostgreSQL'
- 'Python-2.0'
- 'X11'
- 'Zlib'

allow-dependencies-licenses:
# this action is GPL-3 but it is only used in CI
# https://github.com/actions/dependency-review-action/issues/530#issuecomment-1638291806
- pkg:githubactions/vladopajic/go-test-coverage@bcd064e5ceef1ccec5441519eb054263b6a44787
# this package is MPL-2.0 and has a CNCF exception
# https://github.com/cncf/foundation/blob/9b8c9173c2101c1b4aedad3caf2c0128715133f6/license-exceptions/cncf-exceptions-2022-04-12.json#L43C17-L43C47
- pkg:golang/github.com/go-sql-driver/mysql
46 changes: 34 additions & 12 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,49 @@
name: Build
on: pull_request
name: build
on:
pull_request:
branches:
- main
permissions: {}
jobs:
build:
build-snapshot:
permissions:
contents: read
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version: stable
- name: Install Dependencies (ubuntu)
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get update && sudo apt-get -u install libpcsclite-dev
- name: Set up environment
run: echo "GOVERSION=$(go version)" >> $GITHUB_ENV
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
- uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6.0.0
id: goreleaser
with:
version: latest
args: build --snapshot --rm-dist --config .goreleaser.${{ matrix.os }}.yml
args: build --clean --verbose --snapshot --config .goreleaser.${{ matrix.os }}.yaml
check-tag:
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
fetch-depth: 0
- id: ccv
uses: smlx/ccv@d3de774e9b607b079940a7a86952f44643743336 # v0.9.0
with:
write-tag: false
- run: |
echo "new-tag=$NEW_TAG"
echo "new-tag-version=$NEW_TAG_VERSION"
env:
NEW_TAG: ${{steps.ccv.outputs.new-tag}}
NEW_TAG_VERSION: ${{steps.ccv.outputs.new-tag-version}}
33 changes: 0 additions & 33 deletions .github/workflows/codeql-analysis.yaml

This file was deleted.

33 changes: 16 additions & 17 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
name: Coverage
name: coverage
on:
push:
branches:
- main

permissions: {}
jobs:
coverage:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Configure git
run: |
git config --global user.name "$GITHUB_ACTOR"
git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Set up go
uses: actions/setup-go@v5
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version: stable
- name: Install Dependencies
run: sudo apt-get update && sudo apt-get -u install libpcsclite-dev
- name: Calculate coverage
run: |
go test -v -covermode=count -coverprofile=coverage.out.raw -coverpkg=./... ./...
grep -v mock_ coverage.out.raw > coverage.out
- name: Convert coverage to lcov
uses: jandelgado/gcov2lcov-action@v1.0.9
- name: Coveralls
uses: coverallsapp/github-action@v2.2.3
go test -v -covermode=atomic -coverprofile=cover.out.raw -coverpkg=./... ./...
# remove generated code from coverage calculation
grep -Ev 'internal/mock|_enumer.go' cover.out.raw > cover.out
- name: Generage coverage badge
uses: vladopajic/go-test-coverage@1079cd4e58dda229c04ffdb6324fc3756b8542ff # v2.10.1
with:
github-token: ${{ secrets.github_token }}
profile: cover.out
local-prefix: github.com/${{ github.repository }}
git-token: ${{ secrets.GITHUB_TOKEN }}
# orphan branch for storing badges
git-branch: badges
27 changes: 17 additions & 10 deletions .github/workflows/dependabot-automerge.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#enable-auto-merge-on-a-pull-request
name: Dependabot auto-merge
on: pull_request

permissions:
contents: write
pull-requests: write

name: dependabot auto-merge
on:
pull_request:
branches:
- main
permissions: {}
jobs:
dependabot:
dependabot-automerge:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
if: github.actor == 'dependabot[bot]'
steps:
- name: Enable auto-merge for Dependabot PRs
- name: Fetch dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@5e5f99653a5b510e8555840e80cbf1514ad4af38 # v2.1.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Enable auto-merge for Dependabot PRs # these still need approval before merge
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/dependency-review.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: dependency review
on:
pull_request:
branches:
- main
permissions: {}
jobs:
dependency-review:
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: actions/dependency-review-action@72eb03d02c7872a771aacd928f3123ac62ad6d3a # v4.3.3
with:
config-file: .github/dependency-review-config.yaml
50 changes: 32 additions & 18 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,42 @@
name: Lint
on: pull_request
name: lint
on:
pull_request:
branches:
- main
permissions: {}
jobs:
golangci-lint:
name: lint
lint-go:
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Dependencies
run: sudo apt-get update && sudo apt-get -u install libpcsclite-dev
- name: Install Go
uses: actions/setup-go@v5
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version: stable
- name: golangci-lint
uses: golangci/golangci-lint-action@v5
- name: Install Dependencies
run: sudo apt-get update && sudo apt-get -u install libpcsclite-dev
- uses: golangci/golangci-lint-action@a4f60bb28d35aeee14e6880718e0c85ff1882e64 # v6.0.1
with:
version: latest
commitlint:
args: --timeout=180s --enable gocritic
lint-commits:
permissions:
contents: read
pull-requests: read
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
fetch-depth: 0
- name: Lint commit messages
uses: wagoid/commitlint-github-action@v5.4.5
- uses: wagoid/commitlint-github-action@7f0a61df502599e1f1f50880aaa7ec1e2c0592f2 # v6.0.1
with:
configFile: .github/commitlint.config.mjs
lint-actions:
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: docker://rhysd/actionlint:1.7.0@sha256:601d6faeefa07683a4a79f756f430a1850b34d575d734b1d1324692202bf312e # v1.7.0
with:
args: -color
Loading

0 comments on commit fd50737

Please sign in to comment.