Skip to content

Commit

Permalink
enhanced ci workflow
Browse files Browse the repository at this point in the history
- better actions test output
- added fd | fd-find
  • Loading branch information
Phillip Miller committed Dec 29, 2021
1 parent 39d53c5 commit c2334f8
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 61 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/codacy-coverage-reporter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ jobs:
go-version: ${{ matrix.go-version }}

- name: Cache Go modules
uses: actions/cache@preview
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-build-${{ hashFiles('**/go.sum') }}
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-codacy-coverage-reporter-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.OS }}-build-${{ env.cache-name }}-
${{ runner.OS }}-build-
${{ runner.OS }}-codacy-coverage-reporter-${{ env.cache-name }}-
${{ runner.OS }}-codacy-coverage-reporter-
${{ runner.OS }}-
# Remove apt repos that are known to break from time to time
Expand All @@ -53,9 +55,7 @@ jobs:
# Run build of the application
- name: Run build
run: |
go env -w GOFLAGS=-mod=mod
go mod tidy
go build -v .
make -f MakeFile build
# Run Tests and Coverage
- name: Run Tests and Coverage
Expand Down
139 changes: 98 additions & 41 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
# This is a basic workflow

name: CI

# Controls when the action will run. Triggers the workflow on push with tags
on:
push:
tags:
- '*'
pull_request:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# The "build" workflow
build:
# The type of runner that the job will run on
strategy:
matrix:
go-version: [1.17.x]
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# Setup Go
Expand All @@ -32,46 +23,117 @@ jobs:
go-version: ${{ matrix.go-version }}

- name: Cache Go modules
uses: actions/cache@preview
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
key: ${{ runner.os }}-build-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.OS }}-build-${{ env.cache-name }}-
${{ runner.OS }}-build-
${{ runner.OS }}-
# Install all the dependencies
- name: Install dependencies
run: |
go version
go get -u golang.org/x/lint/golint
go get github.com/mattn/[email protected]
run: go get github.com/mattn/[email protected]

# Run build of the application
- name: Run build
run: |
go env -w GOFLAGS=-mod=mod
go mod tidy
go build -v .
make -f MakeFile build
# Run pimp-my-shell
- name: Run pimp-my-shell
run: |
./pimp-my-shell
cat "$HOME/.zshrc"
test:
strategy:
matrix:
go-version: [1.17.x]
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2

# Setup Go
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}

- name: Cache Go modules
uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
key: ${{ runner.os }}-test-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.OS }}-test-${{ env.cache-name }}-
${{ runner.OS }}-test-
${{ runner.OS }}-
- name: Install dependencies
run: go get github.com/mattn/[email protected]

# Run Tests
- name: Tests
run: |
make -f MakeFile test || true
# Upload the original go test log as an artifact for later review.
- name: Upload test log
uses: actions/upload-artifact@v2
if: always()
with:
name: test-log
path: /tmp/gotest.log
if-no-files-found: error

run-pimp-my-shell:
strategy:
matrix:
go-version: [1.17.x]
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}

- name: Cache Go modules
uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
key: ${{ runner.os }}-run-pimp-my-shell-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.OS }}-run-pimp-my-shell-${{ env.cache-name }}-
${{ runner.OS }}-run-pimp-my-shell-
${{ runner.OS }}-
- name: Install dependencies
run: go get github.com/mattn/[email protected]

- name: Run pimp-my-shell
run: |
echo "::group::Pimp My Shell"
./pimp-my-shell
echo "::endgroup::"
echo "::group::Final ZSHRC"
cat "$HOME/.zshrc"
echo "::endgroup::"
generate-milestone:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Required due to the weg Git works, without it this action won't be able to find any or the correct tags
fetch-depth: 0 # Required due to the way Git works, without it this action won't be able to find any or the correct tags
- name: Get Previous tag
id: previoustag
uses: WyriHaximus/github-action-get-previous-tag@v1
Expand All @@ -96,7 +158,7 @@ jobs:
# only runs on push "v*" tag
# ================
release:
needs: build
needs: [build, test, run-pimp-my-shell]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
Expand All @@ -105,41 +167,36 @@ jobs:
with:
fetch-depth: 1000

# Setup Go
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.17.x

- name: Cache Go modules
uses: actions/cache@preview
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-build-${{ hashFiles('**/go.sum') }}
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-release-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.OS }}-build-${{ env.cache-name }}-
${{ runner.OS }}-build-
${{ runner.OS }}-release-${{ env.cache-name }}-
${{ runner.OS }}-release-
${{ runner.OS }}-
# Install all the dependencies
- name: Install dependencies
run: |
go version
go get github.com/mattn/[email protected]
run: go get github.com/mattn/[email protected]

# Run build of the application
- name: Run build and MakeFile
- name: Generate Binaries
id: binaries
run: |
go env -w GOFLAGS=-mod=mod
go mod tidy
go build -v .
make -f MakeFile release
- name: Get current tag name
run: |
echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
echo "PREVIOUS_TAG=$(git describe --abbrev=0 --tags $(git rev-list --tags --skip=1 --max-count=1))" >> $GITHUB_ENV
- name: "Build Changelog"
id: github_release
uses: mikepenz/release-changelog-builder-action@v1
Expand Down
29 changes: 22 additions & 7 deletions MakeFile
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ CURRENT_TAG=$(shell git describe --tags --abbrev=0)

GOLANGCI := $(shell command -v golangci-lint 2>/dev/null)
RICHGO := $(shell command -v richgo 2>/dev/null)
GOTESTFMT := $(shell command -v gotestfmt 2>/dev/null)
MIN_GOLANGCI_LINT_VERSION := 001043000

.PHONY: fmt lint test clean compile chmodX compress
.PHONY: fmt lint build test clean compile chmodX compress

default: all

all: fmt lint test release
all: fmt lint build test release

release: clean compile chmodX compress
release: clean build compile chmodX compress

fmt:
$(info ******************** checking formatting ********************)
Expand All @@ -39,15 +40,29 @@ lint: golangci-lint-check

test:
$(info ******************** running tests ********************)
ifndef RICHGO
$(warning "could not find richgo in $(PATH), running: go get github.com/kyoh86/richgo")
$(shell go get github.com/kyoh86/richgo)
ifeq ($(GITHUB_ACTIONS), "true")
ifndef GOTESTFMT
$(warning "could not find gotestfmt in $(PATH), running: go install github.com/haveyoudebuggedit/gotestfmt/v2/cmd/gotestfmt@latest")
$(shell go install github.com/haveyoudebuggedit/gotestfmt/v2/cmd/gotestfmt@latest)
endif
set -euo pipefail
go test -json -v ./... 2>&1 | tee /tmp/gotest.log | gotestfmt
else
ifndef RICHGO
$(warning "could not find richgo in $(PATH), running: go get github.com/kyoh86/richgo")
$(shell go get -u github.com/kyoh86/richgo)
endif
richgo test -v ./...
endif
richgo test -v ./...

clean:
rm -rf $(BIN) 2>/dev/null

build:
go env -w GOFLAGS=-mod=mod
go mod tidy
go build -v .

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
Expand Down
8 changes: 6 additions & 2 deletions extra/extra.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ func InstallExtraPackages(osType string, dirs *localio.Directories, packages *lo
if err := localio.BrewInstallProgram("bat", "bat", packages); err != nil {
return err
}
// install fd
if err := localio.BrewInstallProgram("fd", "fd", packages); err != nil {
return err
}
// install fzf
if _, exists := localio.CommandExists("fzf"); !exists {
if err := localio.BrewInstallProgram("fzf", "fzf", packages); err != nil {
Expand Down Expand Up @@ -111,8 +115,8 @@ func InstallExtraPackages(osType string, dirs *localio.Directories, packages *lo
}
}

// install cowsay
if err := localio.AptInstall(packages, "cowsay", "bat"); err != nil {
// install cowsay, bat, fd-find
if err := localio.AptInstall(packages, "cowsay", "bat", "fd-find"); err != nil {
return err
}

Expand Down
1 change: 0 additions & 1 deletion zsh/templates/darwin/aliases.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ alias myip='dig +short myip.opendns.com @resolver1.opendns.com'
alias pyup='python3 -m http.server'
alias a2='curl wttr.in/Ann_Arbor'
alias gs='git status'
alias gcmsg='git commit -m '
alias nstat='netstat -p tcp -van | grep LISTEN'
alias gl="git log --all --graph --pretty=tformat:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --date=short"
alias gll="git log --all --stat --pretty=tformat:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
Expand Down
1 change: 0 additions & 1 deletion zsh/templates/linux/aliases.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ alias myip='dig +short myip.opendns.com @resolver1.opendns.com'
alias pyup='python3 -m http.server'
alias a2='curl wttr.in/Ann_Arbor'
alias gs='git status'
alias gcmsg='git commit -m '
alias gl="git log --all --graph --pretty=tformat:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --date=short"
alias gll="git log --all --stat --pretty=tformat:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
alias gln="git --no-pager log --all --stat --pretty=tformat:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative -n 10"
Expand Down
2 changes: 1 addition & 1 deletion zsh/zsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func updateZSHPlugins(zshrcPath string) error {
if err != nil {
return err
}
newPlugins := []string{"git", "zsh-syntax-highlighting", "tmux", "golang", "zsh-autosuggestions", "virtualenv", "ansible", "docker", "docker-compose", "terraform", "kubectl", "helm", "fzf"}
newPlugins := []string{"git", "zsh-syntax-highlighting", "tmux", "golang", "zsh-autosuggestions", "virtualenv", "ansible", "docker", "docker-compose", "terraform", "kubectl", "helm", "fzf", "fd"}
currentlyInstalledPlugins := re.FindStringSubmatch(string(input))
//fmt.Printf("Plugins: %+v\n", currentlyInstalledPlugins[1])
installedPlugins := strings.Fields(currentlyInstalledPlugins[1])
Expand Down

0 comments on commit c2334f8

Please sign in to comment.