Skip to content

Commit

Permalink
updated workflows
Browse files Browse the repository at this point in the history
- goimports
- go fmt ./...
- GitClone method
  • Loading branch information
Phillip Miller committed Nov 24, 2021
1 parent 84d3697 commit 80ffa9c
Show file tree
Hide file tree
Showing 29 changed files with 353 additions and 60 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codacy-coverage-reporter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
go install github.com/axw/gocov/gocov@latest
go install github.com/AlekSi/gocov-xml@latest
go get -u github.com/jstemmer/go-junit-report
go get -u github.com/kyoh86/richgo
sudo apt-get update -y || true
# Run build of the application
Expand All @@ -59,8 +60,7 @@ jobs:
# Run Tests and Coverage
- name: Run Tests and Coverage
run: |
go test -v -coverprofile=coverage.out ./... | tee test.out
cat test.out | go-junit-report > coverage/${{ runner.OS }}-report.xml
go test -v -coverprofile=coverage.out ./... | tee >(richgo testfilter) | go-junit-report > coverage/${{ runner.OS }}-report.xml
gocov convert coverage.out | gocov-xml > coverage/${{ runner.OS }}-report.xml
- name: Run codacy-coverage-reporter
Expand Down
14 changes: 9 additions & 5 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,15 @@ jobs:
./pimp-my-shell
cat "$HOME/.zshrc"
# Run vet & lint on the code
- name: Run vet & lint
# Run Tests
- name: Tests
run: |
go vet ./...
golint ./...
make -f MakeFile test || true
# Run golangci-lint
- name: Lint
run: |
make -f MakeFile lint || true
generate-milestone:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -135,7 +139,7 @@ jobs:
go env -w GOFLAGS=-mod=mod
go mod tidy
go build -v .
make -f MakeFile all
make -f MakeFile release
- name: Get current tag name
run: |
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: golangci-lint
on:
push:
tags:
- *
branches:
- master
- main
pull_request:
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
pull-requests: read
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
args: --config .golangci-lint.yml

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true then the action will use pre-installed Go.
# skip-go-installation: true

# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true
52 changes: 52 additions & 0 deletions .golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
run:
timeout: 5m

linters:
disable-all: true
enable:
#- bodyclose
- deadcode
#- depguard
#- dogsled
#- dupl
- errcheck
#- exhaustive
#- funlen
- gas
#- gochecknoinits
- goconst
#- gocritic
#- gocyclo
#- gofmt
- goimports
#- golint
#- gomnd
#- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
#- interfacer
#- lll
#- maligned
- megacheck
#- misspell
#- nakedret
#- noctx
#- nolintlint
#- rowserrcheck
#- scopelint
- staticcheck
- structcheck
#- stylecheck
- typecheck
- unconvert
#- unparam
- unused
- varcheck
#- whitespace
fast: false

linters-settings:
gosimple:
checks: ["all", "-S1028"]
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## [Unreleased](https://github.com/mr-pmillz/pimp-my-shell/tree/HEAD)

[Full Changelog](https://github.com/mr-pmillz/pimp-my-shell/compare/v1.7.1...HEAD)

**Merged pull requests:**

- Bump gopkg.in/ini.v1 from 1.63.2 to 1.64.0 [\#7](https://github.com/mr-pmillz/pimp-my-shell/pull/7) ([dependabot[bot]](https://github.com/apps/dependabot))
- Bump github.com/tidwall/gjson from 1.10.2 to 1.11.0 [\#5](https://github.com/mr-pmillz/pimp-my-shell/pull/5) ([dependabot[bot]](https://github.com/apps/dependabot))

## [v1.7.1](https://github.com/mr-pmillz/pimp-my-shell/tree/v1.7.1) (2021-10-26)

[Full Changelog](https://github.com/mr-pmillz/pimp-my-shell/compare/v1.7.0...v1.7.1)

## [v1.7.0](https://github.com/mr-pmillz/pimp-my-shell/tree/v1.7.0) (2021-10-25)

[Full Changelog](https://github.com/mr-pmillz/pimp-my-shell/compare/v1.6.9...v1.7.0)
Expand Down
40 changes: 32 additions & 8 deletions MakeFile
Original file line number Diff line number Diff line change
@@ -1,21 +1,45 @@
all: clean compile chmodx compress
.PHONY: all
BIN="./bin"
SRC=$(shell find . -name "*.go")
CURRENT_TAG=$(shell git describe --tags --abbrev=0)

CURRENT_TAG := $(shell git describe --tags --abbrev=0)
ifeq (, $(shell which golangci-lint))
$(warning "could not find golangci-lint in $(PATH), run: curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh")
endif

ifeq (, $(shell which richgo))
$(warning "could not find richgo in $(PATH), run: go get github.com/kyoh86/richgo")
endif

.PHONY: fmt lint test clean compile chmodX compress

default: all

all: fmt lint test release

release: clean compile chmodX compress

fmt:
$(info ******************** checking formatting ********************)
@test -z $(shell gofmt -l $(SRC)) || (gofmt -d $(SRC); exit 1)

lint:
$(info ******************** running lint tools ********************)
golangci-lint run -c .golangci-lint.yml -v ./...

test:
$(info ******************** running tests ********************)
richgo test -v ./...

clean:
rm -rf bin/linux/amd64/pimp-my-shell-$(CURRENT_TAG)-linux-amd64.gz 2>/dev/null
rm -rf bin/linux/arm64/pimp-my-shell-$(CURRENT_TAG)-linux-arm64.gz 2>/dev/null
rm -rf bin/darwin/amd64/pimp-my-shell-$(CURRENT_TAG)-x86_64-apple-darwin_amd64.gz 2>/dev/null
rm -rf bin/darwin/arm64/pimp-my-shell-$(CURRENT_TAG)-x86_64-apple-darwin_arm64.gz 2>/dev/null
rm -rf $(BIN) 2>/dev/null

compile:
GOOS=linux GOARCH=amd64 go build -o bin/linux/amd64/pimp-my-shell-$(CURRENT_TAG)-linux-amd64 main.go
GOOS=linux GOARCH=arm64 go build -o bin/linux/arm64/pimp-my-shell-$(CURRENT_TAG)-linux-arm64 main.go
GOOS=darwin GOARCH=amd64 go build -o bin/darwin/amd64/pimp-my-shell-$(CURRENT_TAG)-x86_64-apple-darwin_amd64 main.go
GOOS=darwin GOARCH=arm64 go build -o bin/darwin/arm64/pimp-my-shell-$(CURRENT_TAG)-x86_64-apple-darwin_arm64 main.go

chmodx:
chmodX:
chmod +x bin/linux/amd64/pimp-my-shell-$(CURRENT_TAG)-linux-amd64
chmod +x bin/linux/arm64/pimp-my-shell-$(CURRENT_TAG)-linux-arm64
chmod +x bin/darwin/amd64/pimp-my-shell-$(CURRENT_TAG)-x86_64-apple-darwin_amd64
Expand Down
11 changes: 5 additions & 6 deletions cheat/cheat.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import (
"bytes"
_ "embed" // single file embed
"fmt"
"github.com/mr-pmillz/pimp-my-shell/localio"
"os"
"text/template"

"github.com/mr-pmillz/pimp-my-shell/localio"
)

type cheatConfigOptions struct {
Expand Down Expand Up @@ -56,13 +58,10 @@ func InstallCheat(osType string, dirs *localio.Directories, packages *localio.In
}
}
if exists, err := localio.Exists(fmt.Sprintf("%s/.config/cheat", dirs.HomeDir)); err == nil && !exists {
if err := localio.RunCommandPipeOutput(fmt.Sprintf("mkdir -p %s/.config/cheat/cheatsheets", dirs.HomeDir)); err != nil {
return err
}
if err := localio.RunCommandPipeOutput(fmt.Sprintf("mkdir -p %s/.config/cheat/cheatsheets/personal", dirs.HomeDir)); err != nil {
if err = os.MkdirAll(fmt.Sprintf("%s/.config/cheat/cheatsheets/personal", dirs.HomeDir), 0750); err != nil {
return err
}
if err := localio.RunCommandPipeOutput(fmt.Sprintf("git clone https://github.com/cheat/cheatsheets.git %s/.config/cheat/cheatsheets/community", dirs.HomeDir)); err != nil {
if err = localio.GitClone("https://github.com/cheat/cheatsheets.git", fmt.Sprintf("%s/.config/cheat/cheatsheets/community", dirs.HomeDir)); err != nil {
return err
}
generatedCheatConfig, err := generateCheatConfig(dirs)
Expand Down
3 changes: 2 additions & 1 deletion cheat/cheat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package cheat
import (
_ "embed"
"fmt"
"github.com/mr-pmillz/pimp-my-shell/localio"
"os"
"testing"

"github.com/mr-pmillz/pimp-my-shell/localio"
)

func TestInstallCheat(t *testing.T) {
Expand Down
4 changes: 3 additions & 1 deletion extra/extra.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package extra
import (
"embed"
"fmt"
"os"

"github.com/mr-pmillz/pimp-my-shell/githubapi"
"github.com/mr-pmillz/pimp-my-shell/localio"
"gopkg.in/ini.v1"
Expand Down Expand Up @@ -115,7 +117,7 @@ func InstallExtraPackages(osType string, dirs *localio.Directories, packages *lo
}

// add batcat to path as bat
if err := localio.RunCommandPipeOutput(fmt.Sprintf("mkdir -p %s/.local/bin", dirs.HomeDir)); err != nil {
if err := os.MkdirAll(fmt.Sprintf("%s/.local/bin", dirs.HomeDir), 0750); err != nil {
return err
}

Expand Down
3 changes: 2 additions & 1 deletion extra/extra_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package extra

import (
"github.com/mr-pmillz/pimp-my-shell/localio"
"runtime"
"testing"
"time"

"github.com/mr-pmillz/pimp-my-shell/localio"
)

func TestInstallExtraPackages(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion githubapi/githubapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package githubapi
import (
"context"
"fmt"
"github.com/mr-pmillz/pimp-my-shell/localio"
"path"
"strings"

"github.com/mr-pmillz/pimp-my-shell/localio"

"github.com/google/go-github/v39/github"
)

Expand Down
3 changes: 2 additions & 1 deletion githubapi/githubapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package githubapi

import (
"fmt"
"github.com/mr-pmillz/pimp-my-shell/localio"
"log"
"reflect"
"testing"

"github.com/mr-pmillz/pimp-my-shell/localio"
)

func TestDownloadLatestRelease(t *testing.T) {
Expand Down
15 changes: 15 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.17

require (
github.com/Masterminds/semver v1.5.0
github.com/go-git/go-git/v5 v5.4.2
github.com/google/go-github/v39 v39.2.0
github.com/google/periph v3.6.8+incompatible
github.com/jubnzv/go-tmux v0.0.0-20210107170159-c6ae3ccbe820
Expand All @@ -14,14 +15,28 @@ require (
)

require (
github.com/Microsoft/go-winio v0.4.16 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 // indirect
github.com/acomagu/bufpipe v1.0.3 // indirect
github.com/emirpasic/gods v1.12.0 // indirect
github.com/go-git/gcfg v1.5.0 // indirect
github.com/go-git/go-billy/v5 v5.3.1 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/xanzy/ssh-agent v0.3.0 // indirect
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
golang.org/x/net v0.0.0-20210326060303-6b1517762897 // indirect
golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0 // indirect
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
periph.io/x/periph v3.6.8+incompatible // indirect
)
Loading

0 comments on commit 80ffa9c

Please sign in to comment.