Skip to content

Commit

Permalink
Merge pull request #138 from smlx/overhaul-ci
Browse files Browse the repository at this point in the history
overhaul ci
  • Loading branch information
smlx authored May 23, 2024
2 parents 630f3a4 + 03cd661 commit d9a4eb3
Show file tree
Hide file tree
Showing 21 changed files with 372 additions and 183 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,
],
},
}
30 changes: 30 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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: gomod
commit-message:
prefix: chore
include: scope
directory: /
schedule:
interval: monthly
groups:
gomod:
patterns:
- "*"
update-types:
- "minor"
- "patch"
10 changes: 0 additions & 10 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
29 changes: 29 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: build
on:
pull_request:
branches:
- main
permissions: {}
jobs:
build-snapshot:
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
strategy:
matrix:
binary:
- go-cli-github
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: stable
- run: echo "GOVERSION=$(go version)" >> "$GITHUB_ENV"
- uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0
id: goreleaser
with:
version: latest
args: build --clean --debug --single-target --snapshot
37 changes: 0 additions & 37 deletions .github/workflows/codeql-analysis.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions .github/workflows/commitlint.yaml

This file was deleted.

33 changes: 17 additions & 16 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
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 "[email protected]"
- name: Set up go
uses: actions/setup-go@v5
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: stable
- name: Calculate coverage
run: go test -v -covermode=count -coverprofile=coverage.out
- name: Convert coverage to lcov
uses: jandelgado/[email protected]
- name: Coveralls
uses: coverallsapp/github-action@v2
run: |
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@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- uses: actions/dependency-review-action@0c155c5e8556a497adf53f2c18edabf945ed8e70 # v4.3.2
with:
config-file: .github/dependency-review-config.yaml
14 changes: 0 additions & 14 deletions .github/workflows/golangci-lint.yaml

This file was deleted.

40 changes: 40 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: lint
on:
pull_request:
branches:
- main
permissions: {}
jobs:
lint-go:
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: stable
- uses: golangci/golangci-lint-action@9d1e0624a798bb64f6c3cea93db47765312263dc # v5.1.0
with:
args: --timeout=180s --enable gocritic
lint-commits:
permissions:
contents: read
pull-requests: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
fetch-depth: 0
- 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@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- uses: docker://rhysd/actionlint:1.7.0@sha256:601d6faeefa07683a4a79f756f430a1850b34d575d734b1d1324692202bf312e # v1.7.0
with:
args: -color
Loading

0 comments on commit d9a4eb3

Please sign in to comment.