From da9f218e8cc1a17559de20a44f5b7f8053f0f262 Mon Sep 17 00:00:00 2001 From: Aleksander Zaruczewski Date: Wed, 28 Feb 2024 18:15:30 +0200 Subject: [PATCH] ci: improve trunk flow --- .github/workflows/codeql.yml | 5 ++ .github/workflows/lint.yml | 13 +--- .github/workflows/trunk_upgrade.yaml | 28 ++++++++ .markdownlint.json | 8 --- .trunk/.gitignore | 2 + .../configs/.golangci.yaml | 0 .trunk/configs/.markdownlint.yaml | 5 ++ .trunk/trunk.yaml | 68 +++++++++++++------ internal/pkg/eventhandler/fnkeyhandler.go | 1 + 9 files changed, 90 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/trunk_upgrade.yaml delete mode 100644 .markdownlint.json rename .golangci.yaml => .trunk/configs/.golangci.yaml (100%) create mode 100644 .trunk/configs/.markdownlint.yaml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 8f00da9..9c686c2 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -27,6 +27,11 @@ jobs: github.event_name == 'push' steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod - uses: github/codeql-action/init@v3 with: languages: go diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 996d11e..6c10443 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -30,20 +30,11 @@ jobs: (github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'skip workflows')) || github.event_name == 'push' runs-on: ubuntu-latest + permissions: + checks: write steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: go-version-file: go.mod - uses: trunk-io/trunk-action@v1 - golangci-lint: - if: > - (github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'skip workflows')) || - github.event_name == 'push' - runs-on: macos-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - - uses: golangci/golangci-lint-action@v4 diff --git a/.github/workflows/trunk_upgrade.yaml b/.github/workflows/trunk_upgrade.yaml new file mode 100644 index 0000000..d93af56 --- /dev/null +++ b/.github/workflows/trunk_upgrade.yaml @@ -0,0 +1,28 @@ +name: Upgrade Trunk + +on: + schedule: + - cron: 0 8 * * 1-5 + workflow_dispatch: {} + +permissions: read-all + +jobs: + trunk-upgrade: + runs-on: ubuntu-latest + + permissions: + contents: write + pull-requests: write + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + - uses: trunk-io/trunk-action/upgrade@v1 + with: + prefix: "ci(deps): " + lowercase-title: true diff --git a/.markdownlint.json b/.markdownlint.json deleted file mode 100644 index 59499ed..0000000 --- a/.markdownlint.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "default": true, - "MD013": { - "line_length": 120, - "code_blocks": false, - "tables": false - } -} diff --git a/.trunk/.gitignore b/.trunk/.gitignore index cf2f254..15966d0 100644 --- a/.trunk/.gitignore +++ b/.trunk/.gitignore @@ -2,6 +2,8 @@ *logs *actions *notifications +*tools plugins user_trunk.yaml user.yaml +tmp diff --git a/.golangci.yaml b/.trunk/configs/.golangci.yaml similarity index 100% rename from .golangci.yaml rename to .trunk/configs/.golangci.yaml diff --git a/.trunk/configs/.markdownlint.yaml b/.trunk/configs/.markdownlint.yaml new file mode 100644 index 0000000..4e7f940 --- /dev/null +++ b/.trunk/configs/.markdownlint.yaml @@ -0,0 +1,5 @@ +default: true +MD013: + line_length: 120 + code_blocks: false + tables: false diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index c1a1441..f2b4e90 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -1,33 +1,59 @@ +# This file controls the behavior of Trunk: https://docs.trunk.io/cli +# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml version: 0.1 cli: - version: 1.7.0 + version: 1.20.1 +# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins) +plugins: + sources: + - id: trunk + ref: v1.4.3 + uri: https://github.com/trunk-io/plugins +# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes) +runtimes: + enabled: + - go@1.21.0 + - node@18.12.1 + - python@3.10.8 +# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration) lint: - disabled: - - golangci-lint # This currently fails to lint files that use cgo. + definitions: + # We only add CGO_ENABLED=1, everything else is inherited from the default linter configuration. + - name: golangci-lint + environment: + - name: GOLANGCI_LINT_CACHE + value: ${cachedir} + - name: PATH + list: + - ${env.PATH} + - name: GO111MODULE + value: auto + - name: SSH_AUTH_SOCK + optional: true + value: ${env.SSH_AUTH_SOCK} + - name: CGO_ENABLED + value: "1" enabled: - - actionlint@1.6.24 - - markdownlint@0.33.0 - - yamllint@1.30.0 - - git-diff-check@SYSTEM - - gitleaks@8.16.2 - - gofmt@1.19.3 - - prettier@2.8.7 + - actionlint@1.6.27 + - checkov@3.2.26 + - git-diff-check + - gofmt@1.20.4 + - golangci-lint@1.56.2 + - markdownlint@0.39.0 + - osv-scanner@1.6.2 + - prettier@3.2.5 + - trivy@0.49.1 + - trufflehog@3.68.2 + - yamllint@1.35.1 ignore: - linters: - markdownlint paths: - - LICENSE.md - CHANGELOG.md + - LICENSE.md actions: enabled: + - trunk-announce + - trunk-check-pre-push + - trunk-fmt-pre-commit - trunk-upgrade-available -plugins: - sources: - - id: trunk - ref: v0.0.14 - uri: https://github.com/trunk-io/plugins -runtimes: - enabled: - - python@3.10.8 - - go@1.19.5 - - node@18.12.1 diff --git a/internal/pkg/eventhandler/fnkeyhandler.go b/internal/pkg/eventhandler/fnkeyhandler.go index 37eb648..140a5e8 100644 --- a/internal/pkg/eventhandler/fnkeyhandler.go +++ b/internal/pkg/eventhandler/fnkeyhandler.go @@ -1,3 +1,4 @@ +// Package eventhandler encapsulates logic to handle keyboard events. package eventhandler import (