From 381cd2938506fb1b1fb59b249f41d15a9091ee6e Mon Sep 17 00:00:00 2001 From: umarcor Date: Tue, 2 Feb 2021 01:09:48 +0100 Subject: [PATCH 1/4] ci: add GitHub Actions workflow 'Test' --- .github/workflows/Test.yml | 80 ++++++++++++++++++++++++++++++++++++++ README.md | 1 + 2 files changed, 81 insertions(+) create mode 100644 .github/workflows/Test.yml diff --git a/.github/workflows/Test.yml b/.github/workflows/Test.yml new file mode 100644 index 000000000..eb92b8048 --- /dev/null +++ b/.github/workflows/Test.yml @@ -0,0 +1,80 @@ +name: Test + +on: + push: + pull_request: + +env: + GO111MODULE: on + +jobs: + + + test-unix: + strategy: + fail-fast: false + matrix: + platform: + - { icon: 🐧, os: ubuntu } + - { icon: 🍎, os: macOS } + go: + - 1.14.x + - 1.15.x + name: '${{ matrix.platform.icon }} ${{ matrix.go }}' + runs-on: ${{ matrix.platform.os }}-latest + steps: + + - name: '⚙️ Setup go' + uses: actions/setup-go@v1 + with: + go-version: ${{ matrix.go }} + + - name: '🧰 Checkout' + uses: actions/checkout@v2 + + - name: '⚙️ Install deps' + run: | + export GOBIN=$HOME/go/bin + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s -- -b $GOBIN latest + go install github.com/kyoh86/richgo + go install github.com/mitchellh/gox + + - name: '🚧 Run tests' + run: PATH=$HOME/go/bin/:$PATH make + + + test-win: + name: '🟪 MINGW64' + defaults: + run: + shell: msys2 {0} + runs-on: windows-latest + steps: + + - name: '⚙️ Git config' + shell: bash + run: git config --global core.autocrlf input + + - name: '🟪 Setup MSYS2' + uses: msys2/setup-msys2@v2 + with: + msystem: MINGW64 + update: true + install: > + git + make + unzip + mingw-w64-x86_64-go + + - name: '🧰 Checkout' + uses: actions/checkout@v2 + + - name: '⚙️ Install deps' + run: | + export GOBIN=$HOME/go/bin + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s -- -b $GOBIN latest + go install github.com/kyoh86/richgo + go install github.com/mitchellh/gox + + - name: '🚧 Run tests' + run: PATH=$HOME/go/bin:$PATH make diff --git a/README.md b/README.md index 4a8811f37..d143e323d 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ Cobra is used in many Go projects such as [Kubernetes](http://kubernetes.io/), [Hugo](https://gohugo.io), and [Github CLI](https://github.com/cli/cli) to name a few. [This list](./projects_using_cobra.md) contains a more extensive list of projects using Cobra. +[![](https://img.shields.io/github/workflow/status/spf13/cobra/Test?longCache=tru&label=Test&logo=github%20actions&logoColor=fff)](https://github.com/spf13/cobra/actions?query=workflow%3ATest) [![Build Status](https://travis-ci.org/spf13/cobra.svg "Travis CI status")](https://travis-ci.org/spf13/cobra) [![GoDoc](https://godoc.org/github.com/spf13/cobra?status.svg)](https://godoc.org/github.com/spf13/cobra) [![Go Report Card](https://goreportcard.com/badge/github.com/spf13/cobra)](https://goreportcard.com/report/github.com/spf13/cobra) From 0af3679488342330fc98fe5337610cfddf9a1ab9 Mon Sep 17 00:00:00 2001 From: umarcor Date: Tue, 9 Feb 2021 06:20:41 +0100 Subject: [PATCH 2/4] ci: remove emojis/icons --- .github/workflows/Test.yml | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/.github/workflows/Test.yml b/.github/workflows/Test.yml index eb92b8048..fba61684d 100644 --- a/.github/workflows/Test.yml +++ b/.github/workflows/Test.yml @@ -15,48 +15,42 @@ jobs: fail-fast: false matrix: platform: - - { icon: 🐧, os: ubuntu } - - { icon: 🍎, os: macOS } + - ubuntu + - macOS go: - 1.14.x - 1.15.x - name: '${{ matrix.platform.icon }} ${{ matrix.go }}' - runs-on: ${{ matrix.platform.os }}-latest + name: '${{ matrix.platform }} | ${{ matrix.go }}' + runs-on: ${{ matrix.platform }}-latest steps: - - name: '⚙️ Setup go' - uses: actions/setup-go@v1 + - uses: actions/setup-go@v1 with: go-version: ${{ matrix.go }} - - name: '🧰 Checkout' - uses: actions/checkout@v2 + - uses: actions/checkout@v2 - - name: '⚙️ Install deps' - run: | + - run: | export GOBIN=$HOME/go/bin curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s -- -b $GOBIN latest go install github.com/kyoh86/richgo go install github.com/mitchellh/gox - - name: '🚧 Run tests' - run: PATH=$HOME/go/bin/:$PATH make + - run: PATH=$HOME/go/bin/:$PATH make test-win: - name: '🟪 MINGW64' + name: MINGW64 defaults: run: shell: msys2 {0} runs-on: windows-latest steps: - - name: '⚙️ Git config' - shell: bash + - shell: bash run: git config --global core.autocrlf input - - name: '🟪 Setup MSYS2' - uses: msys2/setup-msys2@v2 + - uses: msys2/setup-msys2@v2 with: msystem: MINGW64 update: true @@ -66,15 +60,12 @@ jobs: unzip mingw-w64-x86_64-go - - name: '🧰 Checkout' - uses: actions/checkout@v2 + - uses: actions/checkout@v2 - - name: '⚙️ Install deps' - run: | + - run: | export GOBIN=$HOME/go/bin curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s -- -b $GOBIN latest go install github.com/kyoh86/richgo go install github.com/mitchellh/gox - - name: '🚧 Run tests' - run: PATH=$HOME/go/bin:$PATH make + - run: PATH=$HOME/go/bin:$PATH make From 88e36a6c3f45898dfa825da060db75910291ca0d Mon Sep 17 00:00:00 2001 From: umarcor Date: Tue, 9 Feb 2021 06:22:37 +0100 Subject: [PATCH 3/4] ci: add actions/cache step Co-Authored-By: John McBride --- .github/workflows/Test.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/Test.yml b/.github/workflows/Test.yml index fba61684d..e89e3fe19 100644 --- a/.github/workflows/Test.yml +++ b/.github/workflows/Test.yml @@ -30,6 +30,12 @@ jobs: - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-${{ matrix.go }}-${{ hashFiles('**/go.sum') }} + restore-keys: ${{ runner.os }}-${{ matrix.go }}- + - run: | export GOBIN=$HOME/go/bin curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s -- -b $GOBIN latest @@ -62,6 +68,12 @@ jobs: - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-${{ matrix.go }}-${{ hashFiles('**/go.sum') }} + restore-keys: ${{ runner.os }}-${{ matrix.go }}- + - run: | export GOBIN=$HOME/go/bin curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s -- -b $GOBIN latest From cca4c9ece970dbfb03fa3c567dd91d9a5b793b16 Mon Sep 17 00:00:00 2001 From: umarcor Date: Tue, 9 Feb 2021 06:36:19 +0100 Subject: [PATCH 4/4] ci: bump actions/setup-go to v2 --- .github/workflows/Test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Test.yml b/.github/workflows/Test.yml index e89e3fe19..260948cfb 100644 --- a/.github/workflows/Test.yml +++ b/.github/workflows/Test.yml @@ -24,7 +24,7 @@ jobs: runs-on: ${{ matrix.platform }}-latest steps: - - uses: actions/setup-go@v1 + - uses: actions/setup-go@v2 with: go-version: ${{ matrix.go }}