Skip to content

Commit

Permalink
Update build scripts, fix windows test issues (#11)
Browse files Browse the repository at this point in the history
- Update rakefile and workflows (from maargnton/go-testreport)
- Upload coverage file on linux runner, latest go only
- Fix build badge in README.md
- Fix Ruby STDOUT buffering on windows
- Disable `-race` option when running tests on windows
- Use proper shell escaping.for `git describe` on windows
- Remove extra leading space in `git unshallow` command
  • Loading branch information
maargenton authored Jul 29, 2023
1 parent 1adf00a commit 2090d7e
Show file tree
Hide file tree
Showing 4 changed files with 264 additions and 71 deletions.
49 changes: 25 additions & 24 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,47 +1,48 @@
name: build

on: [push, pull_request]

jobs:
test:
name: Tests
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
go:
- "1.17.x"
- "1.18.x"
- 1.17.x
- 1.18.x
- 1.19.x
- 1.20.x
os:
- ubuntu-latest
- macos-latest
- macos-12
- windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install Go
uses: actions/setup-go@v2
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: "2.5"
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}

- name: Check version
run: go version

- name: Run tests with coverage
if: matrix.os != 'windows-latest'
run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...

- name: Run tests without coverage (windows)
if: matrix.os == 'windows-latest'
run: go test -race ./...
- name: Test and build package
run: rake --trace build

- name: Upload coverage
if: matrix.os != 'windows-latest'
uses: codecov/codecov-action@v2
if: matrix.os == 'ubuntu-latest' && matrix.go == '1.20.x'
uses: codecov/codecov-action@v3
with:
# token: ${{ secrets.CODECOV_TOKEN }}
# fail_ci_if_error: true
verbose: true
flags: unittests
file: coverage.txt
file: build/go-test-coverage.txt

- name: Archive action artifacts
if: always() # Always run step even if other steps fail
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }}-${{ matrix.go }}
path: |
build/*
51 changes: 25 additions & 26 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,33 @@ on:
- v*

jobs:
build:
release:
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-ruby@v1
with:
ruby-version: '2.5'
- uses: actions/setup-go@v2
with:
go-version: 1.17
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: "2.5"
- uses: actions/setup-go@v3
with:
go-version: 1.20.x

- name: Run tests
if: matrix.os == 'windows-latest'
run: go test -race ./...
- name: Test and build package
run: rake build

- name: Build and publish
run: rake build
- name: Archive action artifacts
if: always() # Always run step even if other steps fail
uses: actions/upload-artifact@v3
with:
name: release
path: |
build/*
# - name: Archive action artifacts
# uses: actions/upload-artifact@v2
# with:
# name: artifacts
# path: build/artifacts/*

- name: Upload artifacts to release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: ncipollo/release-action@v1
with:
artifacts: "build/artifacts/*"
bodyFile: "build/release_notes"
token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifacts to release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: ncipollo/release-action@v1
with:
artifacts: "build/artifacts/*"
bodyFile: "build/release_notes.md"
token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A library to define command line interfaces in Go.
https://img.shields.io/github/v/tag/maargenton/go-cli?color=blue&label=latest&logo=go&logoColor=white&sort=semver)](
https://pkg.go.dev/github.com/maargenton/go-cli)
[![Build](
https://img.shields.io/github/workflow/status/maargenton/go-cli/build?label=build&logo=github&logoColor=aaaaaa)](
https://img.shields.io/github/actions/workflow/status/maargenton/go-cli/build.yaml?branch=master&label=build&logo=github&logoColor=aaaaaa)](
https://github.com/maargenton/go-cli/actions?query=branch%3Amaster)
[![Codecov](
https://img.shields.io/codecov/c/github/maargenton/go-cli?label=codecov&logo=codecov&logoColor=aaaaaa&token=1JFLIu042X)](
Expand Down
Loading

0 comments on commit 2090d7e

Please sign in to comment.