Merge pull request #1017 from urfave/github-actions-windows

GitHub actions windows
This commit is contained in:
lynn [they] 2020-01-14 09:36:33 -08:00 committed by GitHub
commit 565ec5884d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 48 deletions

View File

@ -10,15 +10,12 @@ on:
- master - master
- v1 - v1
env:
GO111MODULE: on
GOPROXY: https://proxy.golang.org
jobs: jobs:
test: test:
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest, macos-latest] os: [ubuntu-latest, macos-latest, windows-latest]
go: [1.11, 1.12, 1.13] go: [1.11, 1.12, 1.13]
name: ${{ matrix.os }} @ Go ${{ matrix.go }} name: ${{ matrix.os }} @ Go ${{ matrix.go }}
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
@ -28,14 +25,50 @@ jobs:
with: with:
go-version: ${{ matrix.go }} go-version: ${{ matrix.go }}
- name: Set GOPATH, PATH and ENV
run: |
echo "::set-env name=GOPATH::$(dirname $GITHUB_WORKSPACE)"
echo "::set-env name=GO111MODULE::on"
echo "::set-env name=GOPROXY::https://proxy.golang.org"
echo "::add-path::$(dirname $GITHUB_WORKSPACE)/bin"
shell: bash
- name: Checkout Code
uses: actions/checkout@v1
with:
ref: ${{ github.ref }}
- name: Run Tests
run: |
go run build.go vet
go run build.go test
- name: Upload coverage to Codecov
if: success() && matrix.go == 1.13 && matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v1
with:
token: 0a8cc73b-bb7c-480b-8626-38a461643761
fail_ci_if_error: true
test-docs:
name: test-docs
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.13
uses: actions/setup-go@v1
with:
go-version: 1.13
- name: Use Node.js 12.x - name: Use Node.js 12.x
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: 12.x node-version: 12.x
- name: Set GOPATH and PATH - name: Set GOPATH, PATH and ENV
run: | run: |
echo "::set-env name=GOPATH::$(dirname $GITHUB_WORKSPACE)" echo "::set-env name=GOPATH::$(dirname $GITHUB_WORKSPACE)"
echo "::set-env name=GO111MODULE::on"
echo "::set-env name=GOPROXY::https://proxy.golang.org"
echo "::add-path::$(dirname $GITHUB_WORKSPACE)/bin" echo "::add-path::$(dirname $GITHUB_WORKSPACE)/bin"
shell: bash shell: bash
@ -51,11 +84,6 @@ jobs:
chmod +x $GOPATH/bin/gfmrun chmod +x $GOPATH/bin/gfmrun
npm install -g markdown-toc@1.2.0 npm install -g markdown-toc@1.2.0
- name: Run Tests
run: |
go run build.go vet
go run build.go test
- name: Run Tests (v1) - name: Run Tests (v1)
if: contains(github.base_ref, 'v1') if: contains(github.base_ref, 'v1')
run: | run: |
@ -67,10 +95,3 @@ jobs:
run: | run: |
go run build.go gfmrun docs/v2/manual.md go run build.go gfmrun docs/v2/manual.md
go run build.go toc docs/v2/manual.md go run build.go toc docs/v2/manual.md
- name: Upload coverage to Codecov
if: success() && matrix.go == 1.13 && matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v1
with:
token: 0a8cc73b-bb7c-480b-8626-38a461643761
fail_ci_if_error: true

View File

@ -190,7 +190,7 @@ func TestPathApplyInputSourceMethodSet(t *testing.T) {
expected := "/path/to/source/hello" expected := "/path/to/source/hello"
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
expected = `C:\path\to\source\hello` expected = `D:\path\to\source\hello`
} }
expect(t, expected, c.String("test")) expect(t, expected, c.String("test"))
} }

View File

@ -1,28 +0,0 @@
version: "{build}"
os: Windows Server 2016
image: Visual Studio 2017
clone_folder: c:\gopath\src\github.com\urfave\cli
cache:
- node_modules
environment:
GOPATH: C:\gopath
GOVERSION: 1.11.x
GO111MODULE: on
GOPROXY: https://proxy.golang.org
install:
- set PATH=%GOPATH%\bin;C:\go\bin;%PATH%
- go version
- go env
- go get github.com/urfave/gfmrun/cmd/gfmrun
- go mod tidy
build_script:
- go run build.go vet
- go run build.go test
- go run build.go gfmrun docs/v1/manual.md

View File

@ -1,6 +1,7 @@
package cli package cli
import ( import (
"bytes"
"io/ioutil" "io/ioutil"
"testing" "testing"
) )
@ -77,6 +78,9 @@ func testApp() *App {
func expectFileContent(t *testing.T, file, expected string) { func expectFileContent(t *testing.T, file, expected string) {
data, err := ioutil.ReadFile(file) data, err := ioutil.ReadFile(file)
// Ignore windows line endings
// TODO: Replace with bytes.ReplaceAll when support for Go 1.11 is dropped
data = bytes.Replace(data, []byte("\r\n"), []byte("\n"), -1)
expect(t, err, nil) expect(t, err, nil)
expect(t, string(data), expected) expect(t, string(data), expected)
} }