-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Experiment] Replace a small shell script with go (#185)
* Replace a simple bash script with golang * Add simple go CI * Replace `makers` with `cargo-make make` * Replace cargo-make installer action with asdf * Add trigger for make file
- Loading branch information
Showing
10 changed files
with
109 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: CI - Go | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- '.github/workflows/ci-go.yml' | ||
- '**.go' | ||
- 'go.*' | ||
- 'testdata/**' | ||
- 'Makefile.toml' | ||
pull_request: | ||
paths: | ||
- '.github/workflows/ci-go.yml' | ||
- '**.go' | ||
- 'go.*' | ||
- 'testdata/**' | ||
- 'Makefile.toml' | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: 'go.mod' | ||
cache-dependency-path: 'go.sum' | ||
# https://github.com/davidB/rust-cargo-make/pull/178 is the blocker, even if this action is recommended in cargo-make official docs | ||
- uses: asdf-vm/actions/install@v2 | ||
with: | ||
# Keep same version as used in *.nix | ||
tool_versions: | | ||
cargo-make 0.36.10 | ||
# - run: go test | ||
- run: makers test-race | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: 'go.mod' | ||
cache-dependency-path: 'go.sum' | ||
- name: check format | ||
run: go fmt ./... && git add --intent-to-add . && git diff --exit-code | ||
- run: go vet ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,5 +44,5 @@ jobs: | |
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
# Keep same version as *.nix | ||
# Keep same version as used in *.nix | ||
- uses: crate-ci/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ | |
# Managed by home-manager | ||
.config/fish/conf.d/ | ||
.config/fish/config.fish | ||
|
||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
"os/exec" | ||
"strings" | ||
) | ||
|
||
func main() { | ||
cmds := []struct { | ||
path string | ||
args []string | ||
}{ | ||
{"go", []string{"version"}}, | ||
{"makers", []string{"--version"}}, | ||
{"nix", []string{"--version"}}, | ||
{"dprint", []string{"--version"}}, | ||
{"shellcheck", []string{"--version"}}, | ||
{"shfmt", []string{"--version"}}, | ||
{"fd", []string{"--version"}}, | ||
{"typos", []string{"--version"}}, | ||
{"gitleaks", []string{"version"}}, | ||
} | ||
|
||
for _, cmd := range cmds { | ||
output, err := exec.Command(cmd.path, cmd.args...).Output() | ||
log.Printf("%s %s\n%s\n", cmd.path, strings.Join(cmd.args, " "), output) | ||
if err != nil { | ||
log.Fatalln(err) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,5 +16,6 @@ pkgs.mkShell { | |
pkgs.coreutils | ||
pkgs.fd | ||
pkgs.typos | ||
pkgs.go_1_20 | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module print-deps | ||
|
||
go 1.20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.