Skip to content

Commit

Permalink
feat: implement basic functions
Browse files Browse the repository at this point in the history
  • Loading branch information
suzuki-shunsuke committed Aug 25, 2021
1 parent 2e86e08 commit f56f549
Show file tree
Hide file tree
Showing 20 changed files with 1,178 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .cmdx.yaml
@@ -0,0 +1,56 @@
---
# the configuration file of cmdx - task runner
# https://github.com/suzuki-shunsuke/cmdx
tasks:
- name: init
short: i
script: bash scripts/githook.sh
description: setup git hooks
usage: setup git hooks
- name: coverage
short: c
description: test a package
usage: test a package
script: "bash scripts/coverage.sh {{.path}}"
args:
- name: path
- name: test
short: t
description: test
usage: test
script: go test -v ./... -race -covermode=atomic
- name: fmt
description: format the go code
usage: format the go code
script: bash scripts/fmt.sh
require:
exec:
- gofumpt
- name: vet
short: v
description: go vet
usage: go vet
script: go vet ./...
- name: lint
short: l
description: lint the go code
usage: lint the go code
script: golangci-lint run
- name: release
short: r
description: release the new version
usage: release the new version
script: "bash scripts/release.sh {{.version}}"
args:
- name: version
required: true
validate:
- regexp: "^v\\d+\\.\\d+.\\d+(-\\d+)?$"
- name: install
description: go install
usage: go install
script: go install ./cmd/aqua
- name: build
description: go build
usage: go build
script: go build -o dist/aqua ./cmd/aqua
45 changes: 45 additions & 0 deletions .github/workflows/test.yml
@@ -0,0 +1,45 @@
---
name: test
on:
push:
branches: [master]
tags: [v*]
pull_request:
branches: [master]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.15.0'
- run: go version
- run: go mod download

- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.33

- name: remove changes
# Sometimes it is failed to release by goreleaser due to changes of go.sum
run: git checkout -- .
- name: fetch tags to release
run: git fetch --tags
- name: Unshallow
run: git fetch --prune --unshallow
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
if: startsWith(github.ref, 'refs/tags/')
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run GoReleaser (skip publish)
uses: goreleaser/goreleaser-action@v2
if: "! startsWith(github.ref, 'refs/tags/')"
with:
version: latest
args: release --rm-dist --snapshot
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
dist
16 changes: 16 additions & 0 deletions .golangci.yml
@@ -0,0 +1,16 @@
---
linters:
enable-all: true
disable:
- maligned # WARN [runner] The linter 'maligned' is deprecated (since v1.38.0) due to: The repository of the linter has been archived by the owner. Replaced by govet 'fieldalignment'.
- interfacer # WARN [runner] The linter 'interfacer' is deprecated (since v1.38.0) due to: The repository of the linter has been archived by the owner.
- scopelint # WARN [runner] The linter 'scopelint' is deprecated (since v1.39.0) due to: The repository of the linter has been deprecated by the owner. Replaced by exportloopref.
- wsl
- goerr113
- lll
- godot
- nlreturn
- godox
- golint
- tagliatelle
- exhaustivestruct # https://github.com/mbilski/exhaustivestruct
17 changes: 17 additions & 0 deletions .goreleaser.yml
@@ -0,0 +1,17 @@
---
project_name: aqua
archives:
- name_template: "{{.ProjectName}}_{{.Os}}_{{.Arch}}"
builds:
- binary: aqua
main: cmd/aqua/main.go
env:
- CGO_ENABLED=0
goos:
- windows
- darwin
- linux
goarch:
- amd64
release:
prerelease: true
27 changes: 27 additions & 0 deletions cmd/aqua/main.go
@@ -0,0 +1,27 @@
package main

import (
"context"
"os"
"os/signal"

"github.com/sirupsen/logrus"
"github.com/suzuki-shunsuke/aqua/pkg/cli"
)

func main() {
if err := core(); err != nil {
logrus.Fatal(err)
}
}

func core() error {
runner := cli.Runner{
Stdin: os.Stdin,
Stdout: os.Stdout,
Stderr: os.Stderr,
}
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)
defer stop()
return runner.Run(ctx, os.Args...) //nolint:wrapcheck
}
9 changes: 9 additions & 0 deletions cube.yaml
@@ -0,0 +1,9 @@
packages:
- name: akoi
repository: inline
version: v2.2.1
inline_repository:
- name: akoi
type: github_release
repo: suzuki-shunsuke/akoi
artifact: 'akoi_{{trimPrefix "v" .Package.Version}}_{{.OS}}_{{.Arch}}.tar.gz'
16 changes: 16 additions & 0 deletions go.mod
@@ -0,0 +1,16 @@
module github.com/suzuki-shunsuke/aqua

go 1.16

require (
github.com/Masterminds/sprig/v3 v3.2.2
github.com/google/go-github/v38 v38.1.0
github.com/mholt/archiver/v3 v3.5.0
github.com/sirupsen/logrus v1.8.1
github.com/suzuki-shunsuke/go-findconfig v1.0.0
github.com/suzuki-shunsuke/go-template-unmarshaler v0.1.0
github.com/suzuki-shunsuke/go-timeout v1.0.0
github.com/urfave/cli/v2 v2.3.0
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f
gopkg.in/yaml.v2 v2.4.0
)

0 comments on commit f56f549

Please sign in to comment.