-
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.
* docs: add README.md * feat: init cobra pj * style: add linter * ci: fix ci
- Loading branch information
1 parent
015081f
commit d164fec
Showing
11 changed files
with
380 additions
and
0 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,231 @@ | ||
name: Main CI | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- '**.go' | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
jobs: | ||
all-status-check: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
needs: | ||
- ci-req-check | ||
- yaml-lint | ||
- action-lint | ||
- golang-build-check | ||
- golang-vet-check | ||
- golang-fmt-check | ||
- golang-lint-check | ||
- golang-test-comment-check | ||
- golang-test-check | ||
- golang-generate-check | ||
steps: | ||
- name: All status check | ||
run: echo "All status check passed" | ||
|
||
ci-req-check: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Check all-status-check | ||
run: | | ||
diff \ | ||
<(yq ".jobs | del(.all-status-check) | keys.[]" .github/workflows/ci.yml) \ | ||
<(yq ".jobs.all-status-check.needs.[]" .github/workflows/ci.yml) | ||
yaml-lint: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: reviewdog/action-yamllint@v1.20.0 | ||
with: | ||
level: warning | ||
fail_level: warning | ||
yamllint_flags: "-c .yamllint ." | ||
|
||
action-lint: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: reviewdog/action-actionlint@v1.60.0 | ||
with: | ||
level: warning | ||
fail_level: warning | ||
|
||
golang-build-check: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: go.mod | ||
cache-dependency-path: go.sum | ||
- name: Run go build | ||
run: make build | ||
|
||
golang-vet-check: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: go.mod | ||
cache-dependency-path: go.sum | ||
- name: Run go vet | ||
run: go vet ./... | ||
|
||
golang-fmt-check: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: go.mod | ||
cache-dependency-path: go.sum | ||
- name: Run go fmt | ||
run: go fmt ./... | ||
- name: Check diff | ||
run: | | ||
if [[ $(git status --porcelain) ]]; then | ||
git diff | ||
exit 1 | ||
fi | ||
golang-lint-check: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: go.mod | ||
cache-dependency-path: go.sum | ||
- uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1 | ||
|
||
golang-test-comment-check: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
env: | ||
HTML_REPORT_URL_PATH: reports/${{ github.ref_name }}/${{ github.run_id }}/${{ github.run_attempt }}/cov | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: go.mod | ||
cache-dependency-path: go.sum | ||
- uses: Homebrew/actions/setup-homebrew@064c96758610d925cdfa1878c508528f23dc6a58 | ||
- name: Run go test | ||
id: golang-test | ||
run: | | ||
set +e | ||
TEST_OUT=$(go test ./... -coverpkg=./... -coverprofile=coverage.txt -p=5) | ||
TEST_EXIT_CODE=$? | ||
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | ||
{ | ||
echo "comment<<$EOF" | ||
printf "# Test coverage\n\n" | ||
if [ $TEST_EXIT_CODE -eq 0 ]; then | ||
printf ":white_check_mark: All tests passed successfully.\n\n" | ||
printf "| Status | Package | Time | Coverage |\n" | ||
printf "|--------|---------|------|----------|\n" | ||
echo "$TEST_OUT" | sed -E "s/^\?\s+/?:/g; s/^ok\s+/ok:/g; s/^\s/:/g; s/\s+/ /g; s/coverage:/::/g; s/([0-9.]+)s\s::/\:\1s\:/g; s/ of statements//g;" | sed -e "s/in .\/...//g" | awk -F'[:]' '{ print "| " $1 " | " $2 " | " $3 " |" $4 " |"}' | ||
else | ||
printf ":red_circle: Some tests failed.\n\n" | ||
printf "<details>\n" | ||
printf "<summary>go test result</summary>\n" | ||
printf "\n\`\`\`\n\n" | ||
echo "$TEST_OUT" | ||
printf "\n\`\`\`\n\n" | ||
printf "</details>\n" | ||
fi | ||
echo "$EOF" | ||
} >> "$GITHUB_ENV" | ||
exit $TEST_EXIT_CODE | ||
continue-on-error: true | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@7f8b4b4bde536c465e797be725718b88c5d95e0e # v5.1.1 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
- name: Create PR comment | ||
uses: marocchino/sticky-pull-request-comment@44e0bad81007ecff41ba26d1cbf49a0267d28e9d # v2.9.0 | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
number: ${{ github.event.pull_request.number }} | ||
header: golang-test | ||
message: | | ||
${{ env.comment }} | ||
- name: Error check | ||
if: ${{ steps.golang-test.outcome != 'success' }} | ||
run: exit 1 | ||
|
||
golang-test-check: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: go.mod | ||
cache-dependency-path: go.sum | ||
- uses: Homebrew/actions/setup-homebrew@064c96758610d925cdfa1878c508528f23dc6a58 | ||
- name: Set up gotestfmt | ||
uses: gotesttools/gotestfmt-action@8b4478c7019be847373babde9300210e7de34bfb # v2.5.0 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Run go test | ||
id: golang-test | ||
run: | | ||
set +e | ||
TEST_OUT=$(go test -json -v ./... -p=5 2>&1) | ||
TEST_EXIT=$? | ||
echo "$TEST_OUT" | tee /tmp/gotest.log | gotestfmt | ||
exit $TEST_EXIT | ||
continue-on-error: true | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: test-log | ||
path: /tmp/gotest.log | ||
if-no-files-found: error | ||
- name: Error check | ||
if: ${{ steps.golang-test.outcome != 'success' }} | ||
run: exit 1 | ||
|
||
golang-generate-check: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: go.mod | ||
cache-dependency-path: go.sum | ||
- name: Run go generate | ||
run: go generate ./... | ||
- name: Check diff | ||
run: | | ||
if [[ $(git status --porcelain) ]]; then | ||
git diff | ||
exit 1 | ||
fi |
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,30 @@ | ||
# Created by https://www.toptal.com/developers/gitignore/api/go | ||
# Edit at https://www.toptal.com/developers/gitignore?templates=go | ||
|
||
### Go ### | ||
# If you prefer the allow list template instead of the deny list, see community template: | ||
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore | ||
# | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
# Go workspace file | ||
go.work | ||
|
||
# End of https://www.toptal.com/developers/gitignore/api/go | ||
|
||
bin/* | ||
!bin/.gitkeep |
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,14 @@ | ||
linters: | ||
enable-all: true | ||
disable: | ||
- exportloopref | ||
- depguard | ||
|
||
issues: | ||
exclude-rules: | ||
- path: 'cmd/' | ||
linters: | ||
- gochecknoinits | ||
- exhaustruct | ||
- gochecknoglobals | ||
- forbidigo |
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,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright © 2024 shiron-dev | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
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,24 @@ | ||
BINDIR:=./bin | ||
BINARIES:=$(BINDIR)/arcanumhue | ||
|
||
.PHONY: init | ||
init: | ||
@go mod tidy | ||
|
||
.PHONY: lint | ||
lint: | ||
@golangci-lint run --config=.golangci.yaml --fix | ||
|
||
.PHONY: run | ||
run: init lint | ||
@go run main.go | ||
|
||
.PHONY: run-% | ||
run-%: init lint | ||
@go run main.go ${@:run-%=%} | ||
|
||
.PHONY: build | ||
build: $(BINARIES) | ||
|
||
$(BINARIES): init | ||
@go build -o $@ main.go |
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 @@ | ||
# ArcanumHue | ||
|
||
ArcanumHue is a cli tool for integrated management of color themes. |
Empty file.
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,30 @@ | ||
package cmd | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
var RootCmd = &cobra.Command{ | ||
Use: "arcanum-hue", | ||
Short: "ArcanumHue is a cli tool for integrated management of color themes", | ||
Long: `ArcanumHue is a cli tool for integrated management of color themes. | ||
With ArcanumHue, you can manage color themes for various tools all at once.`, | ||
// Uncomment the following line if your bare application | ||
// has an action associated with it: | ||
// Run: func(cmd *cobra.Command, args []string) { }, | ||
} | ||
|
||
// Execute adds all child commands to the root command and sets flags appropriately. | ||
// This is called by main.main(). It only needs to happen once to the rootCmd. | ||
func Execute() { | ||
err := RootCmd.Execute() | ||
if err != nil { | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
func init() { | ||
RootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") | ||
} |
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,10 @@ | ||
module github.com/shiron-dev/arcanum-hue | ||
|
||
go 1.23.4 | ||
|
||
require github.com/spf13/cobra v1.8.1 | ||
|
||
require ( | ||
github.com/inconshreveable/mousetrap v1.1.0 // indirect | ||
github.com/spf13/pflag v1.0.5 // indirect | ||
) |
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,10 @@ | ||
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= | ||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= | ||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= | ||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= | ||
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= | ||
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= | ||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= | ||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
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,7 @@ | ||
package main | ||
|
||
import "github.com/shiron-dev/arcanum-hue/cmd" | ||
|
||
func main() { | ||
cmd.Execute() | ||
} |