Skip to content

Commit

Permalink
Merge pull request #5 from edwarnicke/cisimple
Browse files Browse the repository at this point in the history
Simplify CI
  • Loading branch information
edwarnicke authored Sep 28, 2020
2 parents 6f69a76 + e84e986 commit ac4a1ce
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 99 deletions.
118 changes: 23 additions & 95 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,80 +9,22 @@ on:
- master
jobs:
build:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.13.4
- run: |
go build -race ./...
build-win:
name: build-win
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.13.4
- run: |
go build -race ./...
build-osx:
name: build-osx
runs-on: macos-latest
name: build-and-test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.13.4
- run: |
go build -race ./...
test:
name: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.13.4
- name: Install gotestsum
run: go get gotest.tools/[email protected]
- name: Run tests
run: |
eval $(go env)
mkdir -p ~/junit/
${GOPATH}/bin/gotestsum --junitfile ~/junit/unit-tests.xml -- -race -short $(go list ./...)
test-win:
name: test-win
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.13.4
- name: Install gotestsum
run: go get gotest.tools/[email protected]
- name: Run tests
run: |
$env:Path += ";$(go env GOPATH)\bin"
mkdir $home/junit
gotestsum --junitfile $home\junit\unit-tests.xml -- -race -short $(go list .\...)
test-osx:
name: test-osx
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v1
with:
go-version: 1.13.4
- name: Install gotestsum
run: go get gotest.tools/[email protected]
- name: Run tests
run: |
eval $(go env)
mkdir -p ~/junit/
${GOPATH}/bin/gotestsum --junitfile ~/junit/unit-tests.xml -- -race -short $(go list ./...)
- name: Build
run: go build -race ./...
- name: Test
run: go test -race ./...
golangci-lint:
name: golangci-lint
runs-on: ubuntu-latest
Expand All @@ -91,10 +33,11 @@ jobs:
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Pull golangci-lint docker container
run: docker pull ${GOLANGCI_LINT_CONTAINER}
- name: Run golangci-lint
run: docker run --rm -v $(pwd):/app -w /app ${GOLANGCI_LINT_CONTAINER} golangci-lint run
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.31
checkgomod:
name: check go.mod and go.sum
runs-on: ubuntu-latest
Expand All @@ -107,20 +50,6 @@ jobs:
- name: Check for changes in go.mod or go.sum
run: |
git diff --name-only --exit-code $(ls -1 go.*) || ( echo "Run go tidy" && false )
license:
name: license header check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.13.4
- name: Install go-header
run: 'go get github.com/denis-tingajkin/[email protected]'
- name: Run go-header
run: |
eval $(go env)
${GOPATH}/bin/go-header
excludereplace:
name: Exclude replace in go.mod
runs-on: ubuntu-latest
Expand All @@ -137,9 +66,8 @@ jobs:
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v1
- name: Install yamllint
run: pip install --user yamllint
- name: Run yamllint
run: ~/.local/bin/yamllint -c .ci/yamllint.yml --strict .
- name: yaml-lint
uses: ibiqlik/action-yamllint@v1
with:
config_file: .ci/yamllint.yml
strict: true
10 changes: 10 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ run:
linters-settings:
funlen:
lines: 80
goheader:
template-path: ".license/template.txt"
values:
const:
year: 2020
regexp:
year-range: ((\d\d\d\d-{{year}})|({{year}}))
company: .*
copyright-holder: Copyright \(c\) {{year-range}} {{company}}\n\n
copyright-holders: ({{copyright-holder}})+
gosec:
settings:
exclude: "G204"
Expand Down
8 changes: 4 additions & 4 deletions exechelper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@ func TestWithEnvKV(t *testing.T) {

func TestWithGracePeriodWithContext(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
graceperiod := 200 * time.Millisecond
graceperiod := 500 * time.Millisecond
err := exechelper.Run("go build ./testcmds/afterterm")
require.NoError(t, err)
errCh := exechelper.Start(
fmt.Sprintf("./afterterm %s", graceperiod-50*time.Millisecond),
fmt.Sprintf("./afterterm %s", graceperiod-100*time.Millisecond),
exechelper.WithContext(ctx),
exechelper.WithGracePeriod(graceperiod),
exechelper.WithStdout(os.Stdout),
Expand All @@ -194,7 +194,7 @@ func TestWithGracePeriodWithContext(t *testing.T) {
select {
case err, ok = <-errCh:
require.NoError(t, err)
case <-time.After(graceperiod + 50*time.Millisecond):
case <-time.After(graceperiod + 100*time.Millisecond):
require.Failf(t, "", "failed to stop within graceperiod(%s): %s", graceperiod+50*time.Millisecond, time.Since(cancelTime))
ok = false
}
Expand All @@ -203,7 +203,7 @@ func TestWithGracePeriodWithContext(t *testing.T) {

func TestWithGracePeriodExceeded(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
graceperiod := 200 * time.Millisecond
graceperiod := 500 * time.Millisecond
err := exechelper.Run("go build ./testcmds/afterterm")
require.NoError(t, err)
errCh := exechelper.Start(
Expand Down

0 comments on commit ac4a1ce

Please sign in to comment.