Skip to content

Commit

Permalink
Improve repo structure (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
anttiharju authored Feb 9, 2025
1 parent a61f1bc commit fba7098
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 60 deletions.
23 changes: 0 additions & 23 deletions .editorconfig

This file was deleted.

13 changes: 13 additions & 0 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Build
description: Build a binary with go

runs:
using: "composite"
steps:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
cache: false # To suppress warning about 'missing' go sum
- shell: sh
run: go build
14 changes: 14 additions & 0 deletions .github/actions/lint/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Lint
description: Run golangci-lint

runs:
using: "composite"
steps:
- name: Get golangci-lint version
id: get-version
shell: sh
run: echo "golangci-lint=v$(cat .golangci-version)" >> "$GITHUB_OUTPUT"
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: ${{ steps.get-version.outputs.golangci-lint }}
8 changes: 4 additions & 4 deletions .github/workflows/homebrew_tap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ permissions:
contents: write

jobs:
update-vmatch-formulas:
name: Update vMatch formulas
update-vmatch-formula:
name: Update vmatch formula
runs-on: ubuntu-24.04
steps:
- name: Generate commit token
Expand All @@ -42,7 +42,7 @@ jobs:
uses: anttiharju/actions/render-formula@v0
with:
template: Go
app-name: vmatch-golangci-lint
app-name: ${{ github.event.repository.name }}
description: Wrapper that automatically calls the golangci-lint version matching your project
homepage: ${{ inputs.homepage }}
url: ${{ inputs.url }}
Expand All @@ -56,6 +56,6 @@ jobs:
uses: anttiharju/actions/commit-changes@v0
with:
message: |
Update vMatch formulas to ${{ steps.extract-version.outputs.version }}
Update vmatch formula to ${{ steps.extract-version.outputs.version }}
https://github.com/anttiharju/vmatch/blob/${{ github.sha }}/.github/workflows/homebrew_tap.yml
3 changes: 3 additions & 0 deletions .github/workflows/main_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ jobs:
needs: validate
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Release
uses: anttiharju/actions/release@v0

- name: Setup Go
uses: actions/setup-go@v5
with:
Expand Down
32 changes: 7 additions & 25 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,15 @@ on:
workflow_call:

jobs:
golangci-lint:
validate:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
cache: false # To suppress warning about 'missing' go sum
- name: Get golangci-lint version
id: get-version
run: echo "golangci-lint=v$(cat .golangci-version)" >> "$GITHUB_OUTPUT"
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: ${{ steps.get-version.outputs.golangci-lint }}

build:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
cache: false # To suppress warning about 'missing' go sum
- name: Build binary
run: make build
- name: golangci-lint
uses: ./.github/actions/lint

- if: always()
name: go build
uses: ./.github/actions/build
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ go.work.sum
# env file
.env

# make build output
vmatch-golangci-lint
# built binary
vmatch
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ linters:
# https://peter.bourgon.org/blog/2017/06/09/theory-of-modern-go.html
- gochecknoglobals
- gochecknoinits
# use make lint-fix
# run with --fix
- gofmt
- gofumpt
- goimports
Expand Down
4 changes: 0 additions & 4 deletions Makefile

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ I saw mismatching linter versions causing confusion in a team so I thought to au

A solution to this could be to implement another wrapper for Go, `vmatch-go`. But this bring up another issue:

### vMatch does not want to cause visible changes in repositories that use it
### vmatch does not want to cause visible changes in repositories that use it

Currently, integrating `vmatch-golangci-lint` into for example VS Code should not end up in version control. But should `vmatch-go` be implemented, it would definitely be visible in tracked files with the current wrapping approach.

Expand Down
17 changes: 17 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
output:
- success
- failure

pre-push:
jobs:
- run: go build
- name: golangci-lint
glob: "*.go"
run: golangci-lint run

pre-commit:
jobs:
- name: golangci-lint --fast --fix
glob: "*.go"
run: golangci-lint run --fast --fix {staged_files}
stage_fixed: true
File renamed without changes.

0 comments on commit fba7098

Please sign in to comment.