Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve tooling to prep for rearchitecting the project #84

Merged
merged 20 commits into from
Feb 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ on:
branches:
- main
paths:
- "pkg/**"
- "pkg/**/*"
- "scripts/**/*"
- "main.go"
- "go.mod"

jobs:
project:
name: Project
uses: ./.github/workflows/project.yml
validate:
name: Validate
uses: ./.github/workflows/validate.yml

release:
name: Release
needs: project
needs: validate
runs-on: ubuntu-24.04
permissions:
contents: write
Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/project.yml → .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ on:
push:
branches:
- main
paths:
- "!pkg/**"
paths: # This workflow is called by main.yml if these files have changed
- "!pkg/**/*"
- "!scripts/**/*"
- "!main.go"
- "!go.mod"
pull_request:
workflow_call:

# also update lefthook.yml
jobs:
validate:
name: Validate
vmatch:
runs-on: ubuntu-24.04
steps:
- name: Checkout
Expand All @@ -33,10 +33,18 @@ jobs:
name: Actions
uses: anttiharju/actions/lint-actions@v0

- if: always()
name: ShellCheck
uses: anttiharju/actions/check-shellcheck@v0

- if: always()
name: Docs
uses: anttiharju/actions/lint-docs@v0

- if: always()
name: Prettier
uses: anttiharju/actions/check-prettier@v0

- if: always()
name: EditorConfig
uses: anttiharju/actions/check-editorconfig@v0
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ vmatch

# mkdocs build output
site

# generated by action-validator install
.tool-versions
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["golang.go", "EditorConfig.EditorConfig"]
}
File renamed without changes.
13 changes: 9 additions & 4 deletions lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ output:
- success
- failure

# also update validate.yml
# Match to validate.yml
pre-commit:
parallel: true
jobs:
- name: Build
run: go build
glob: "{pkg/*,main.go,go.mod}"
stage_fixed: true

- name: Lint
run: golangci-lint run --fix
Expand All @@ -26,12 +25,18 @@ pre-commit:
action-validator --verbose {} +
- run: actionlint
glob: ".github/*"
stage_fixed: true

- name: ShellCheck
run: >
git ls-files -z | xargs -0 file |
grep "script text executable" |
cut -d: -f1 | xargs
shellcheck --color=always -x
glob: "{*.sh,scripts/*}"

- name: Docs
run: mkdocs build --strict
glob: "{docs/*,mkdocs.yml}"
stage_fixed: true

- name: Prettier
run: npx prettier --write .
Expand Down
16 changes: 10 additions & 6 deletions pkg/picker/picker.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,24 @@ import (
"github.com/anttiharju/vmatch/pkg/wrapper/linter"
)

func firstArgIsGo(args []string) bool {
return len(args) > 0 && args[0] == "go"
func firstArgIs(arg string, args []string) bool {
return len(args) > 0 && args[0] == arg
}

func SelectWrapper(args []string) int {
if firstArgIsGo(args) {
if firstArgIs("go", args) {
wrappedLanguage := language.Wrap("go")
exitCode := wrappedLanguage.Run(args[1:])

return exitCode
}

wrappedLinter := linter.Wrap("golangci-lint")
exitCode := wrappedLinter.Run(args)
if firstArgIs("golangci-lint", args) {
wrappedLinter := linter.Wrap("golangci-lint")
exitCode := wrappedLinter.Run(args)

return exitCode
return exitCode
}

return 1
}
3 changes: 3 additions & 0 deletions scripts/go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

vmatch go "$@"
3 changes: 3 additions & 0 deletions scripts/golangci-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

vmatch golangci-lint "$@"
11 changes: 11 additions & 0 deletions scripts/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
set -eu

goversion="$1"
goos="$2"
goarch="$3"
path="$4"
mkdir -p "$path"

url="https://go.dev/dl/go${goversion}.${goos}-${goarch}.tar.gz"
curl -sL "$url" | tar -C "$path" --strip-components=1 -xz