Skip to content

Commit 1a7dc54

Browse files
authored
sync: update CI config files (#137)
1 parent bcf09ff commit 1a7dc54

File tree

8 files changed

+42
-41
lines changed

8 files changed

+42
-41
lines changed

.github/workflows/go-check.yml

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,20 @@ jobs:
88
unit:
99
runs-on: ubuntu-latest
1010
name: All
11-
env:
12-
RUNGOGENERATE: false
1311
steps:
14-
- uses: actions/checkout@v2
12+
- uses: actions/checkout@v3
1513
with:
1614
submodules: recursive
17-
- uses: actions/setup-go@v2
15+
- id: config
16+
uses: protocol/.github/.github/actions/read-config@master
17+
- uses: actions/setup-go@v3
1818
with:
19-
go-version: "1.18.x"
19+
go-version: 1.20.x
2020
- name: Run repo-specific setup
2121
uses: ./.github/actions/go-check-setup
2222
if: hashFiles('./.github/actions/go-check-setup') != ''
23-
- name: Read config
24-
if: hashFiles('./.github/workflows/go-check-config.json') != ''
25-
run: |
26-
if jq -re .gogenerate ./.github/workflows/go-check-config.json; then
27-
echo "RUNGOGENERATE=true" >> $GITHUB_ENV
28-
fi
2923
- name: Install staticcheck
30-
run: go install honnef.co/go/tools/cmd/staticcheck@d7e217c1ff411395475b2971c0824e1e7cc1af98 # 2022.1 (v0.3.0)
24+
run: go install honnef.co/go/tools/cmd/staticcheck@4970552d932f48b71485287748246cf3237cebdf # 2023.1 (v0.4.0)
3125
- name: Check that go.mod is tidy
3226
uses: protocol/[email protected]
3327
with:
@@ -39,32 +33,32 @@ jobs:
3933
fi
4034
git diff --exit-code -- go.sum go.mod
4135
- name: gofmt
42-
if: ${{ success() || failure() }} # run this step even if the previous one failed
36+
if: success() || failure() # run this step even if the previous one failed
4337
run: |
4438
out=$(gofmt -s -l .)
4539
if [[ -n "$out" ]]; then
4640
echo $out | awk '{print "::error file=" $0 ",line=0,col=0::File is not gofmt-ed."}'
4741
exit 1
4842
fi
4943
- name: go vet
50-
if: ${{ success() || failure() }} # run this step even if the previous one failed
44+
if: success() || failure() # run this step even if the previous one failed
5145
uses: protocol/[email protected]
5246
with:
5347
run: go vet ./...
5448
- name: staticcheck
55-
if: ${{ success() || failure() }} # run this step even if the previous one failed
49+
if: success() || failure() # run this step even if the previous one failed
5650
uses: protocol/[email protected]
5751
with:
5852
run: |
5953
set -o pipefail
6054
staticcheck ./... | sed -e 's@\(.*\)\.go@./\1.go@g'
6155
- name: go generate
6256
uses: protocol/[email protected]
63-
if: (success() || failure()) && env.RUNGOGENERATE == 'true'
57+
if: (success() || failure()) && fromJSON(steps.config.outputs.json).gogenerate == true
6458
with:
6559
run: |
6660
git clean -fd # make sure there aren't untracked files / directories
67-
go generate ./...
61+
go generate -x ./...
6862
# check if go generate modified or added any files
6963
if ! $(git add . && git diff-index HEAD --exit-code --quiet); then
7064
echo "go generated caused changes to the repository:"

.github/workflows/go-test.yml

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,26 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
os: [ "ubuntu", "windows", "macos" ]
13-
go: [ "1.17.x", "1.18.x" ]
13+
go: ["1.19.x","1.20.x"]
1414
env:
1515
COVERAGES: ""
16-
runs-on: ${{ format('{0}-latest', matrix.os) }}
16+
runs-on: ${{ fromJSON(vars[format('UCI_GO_TEST_RUNNER_{0}', matrix.os)] || format('"{0}-latest"', matrix.os)) }}
1717
name: ${{ matrix.os }} (go ${{ matrix.go }})
1818
steps:
19-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v3
2020
with:
2121
submodules: recursive
22-
- uses: actions/setup-go@v2
22+
- id: config
23+
uses: protocol/.github/.github/actions/read-config@master
24+
- uses: actions/setup-go@v3
2325
with:
2426
go-version: ${{ matrix.go }}
2527
- name: Go information
2628
run: |
2729
go version
2830
go env
2931
- name: Use msys2 on windows
30-
if: ${{ matrix.os == 'windows' }}
32+
if: matrix.os == 'windows'
3133
shell: bash
3234
# The executable for msys2 is also called bash.cmd
3335
# https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md#shells
@@ -38,31 +40,37 @@ jobs:
3840
uses: ./.github/actions/go-test-setup
3941
if: hashFiles('./.github/actions/go-test-setup') != ''
4042
- name: Run tests
43+
if: contains(fromJSON(steps.config.outputs.json).skipOSes, matrix.os) == false
4144
uses: protocol/[email protected]
4245
with:
4346
# Use -coverpkg=./..., so that we include cross-package coverage.
4447
# If package ./A imports ./B, and ./A's tests also cover ./B,
4548
# this means ./B's coverage will be significantly higher than 0%.
46-
run: go test -v -coverprofile=module-coverage.txt -coverpkg=./... ./...
49+
run: go test -v -shuffle=on -coverprofile=module-coverage.txt -coverpkg=./... ./...
4750
- name: Run tests (32 bit)
48-
if: ${{ matrix.os != 'macos' }} # can't run 32 bit tests on OSX.
51+
# can't run 32 bit tests on OSX.
52+
if: matrix.os != 'macos' &&
53+
fromJSON(steps.config.outputs.json).skip32bit != true &&
54+
contains(fromJSON(steps.config.outputs.json).skipOSes, matrix.os) == false
4955
uses: protocol/[email protected]
5056
env:
5157
GOARCH: 386
5258
with:
5359
run: |
54-
export "PATH=${{ env.PATH_386 }}:$PATH"
55-
go test -v ./...
60+
export "PATH=$PATH_386:$PATH"
61+
go test -v -shuffle=on ./...
5662
- name: Run tests with race detector
57-
if: ${{ matrix.os == 'ubuntu' }} # speed things up. Windows and OSX VMs are slow
63+
# speed things up. Windows and OSX VMs are slow
64+
if: matrix.os == 'ubuntu' &&
65+
contains(fromJSON(steps.config.outputs.json).skipOSes, matrix.os) == false
5866
uses: protocol/[email protected]
5967
with:
6068
run: go test -v -race ./...
6169
- name: Collect coverage files
6270
shell: bash
6371
run: echo "COVERAGES=$(find . -type f -name 'module-coverage.txt' | tr -s '\n' ',' | sed 's/,$//')" >> $GITHUB_ENV
6472
- name: Upload coverage to Codecov
65-
uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
73+
uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
6674
with:
6775
files: '${{ env.COVERAGES }}'
6876
env_vars: OS=${{ matrix.os }}, GO=${{ matrix.go }}

.github/workflows/release-check.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33

44
name: Release Checker
55
on:
6-
pull_request:
6+
pull_request_target:
77
paths: [ 'version.json' ]
88

99
jobs:
1010
release-check:
1111
uses: protocol/.github/.github/workflows/release-check.yml@master
12+
with:
13+
go-version: 1.20.x

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ require (
1111
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
1212
)
1313

14-
go 1.17
14+
go 1.19

path_other.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build !windows
2-
// +build !windows
32

43
package log
54

path_windows.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build windows
2-
// +build windows
32

43
package log
54

pipe.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ func (p *PipeReader) Close() error {
3333
//
3434
// By default, it:
3535
//
36-
// 1. Logs JSON. This can be changed by passing the PipeFormat option.
37-
// 2. Logs everything that would otherwise be logged to the "primary" log
38-
// output. That is, everything enabled by SetLogLevel. The minimum log level
39-
// can be increased by passing the PipeLevel option.
36+
// 1. Logs JSON. This can be changed by passing the PipeFormat option.
37+
// 2. Logs everything that would otherwise be logged to the "primary" log
38+
// output. That is, everything enabled by SetLogLevel. The minimum log level
39+
// can be increased by passing the PipeLevel option.
4040
func NewPipeReader(opts ...PipeReaderOption) *PipeReader {
4141
opt := pipeReaderOptions{
4242
format: JSONOutput,

setup_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package log
33
import (
44
"bytes"
55
"io"
6-
"io/ioutil"
76
"os"
87
"strings"
98
"testing"
@@ -55,7 +54,7 @@ func TestLogToFileAndStderr(t *testing.T) {
5554
}()
5655

5756
// setup file
58-
logfile, err := ioutil.TempFile("", "go-log-test")
57+
logfile, err := os.CreateTemp("", "go-log-test")
5958
if err != nil {
6059
t.Fatal(err)
6160
}
@@ -85,7 +84,7 @@ func TestLogToFileAndStderr(t *testing.T) {
8584
t.Errorf("got %q, wanted it to contain log output", buf.String())
8685
}
8786

88-
content, err := ioutil.ReadFile(logfile.Name())
87+
content, err := os.ReadFile(logfile.Name())
8988
if err != nil {
9089
t.Fatal(err)
9190
}
@@ -98,7 +97,7 @@ func TestLogToFileAndStderr(t *testing.T) {
9897

9998
func TestLogToFile(t *testing.T) {
10099
// get tmp log file
101-
logfile, err := ioutil.TempFile("", "go-log-test")
100+
logfile, err := os.CreateTemp("", "go-log-test")
102101
if err != nil {
103102
t.Fatal(err)
104103
}
@@ -117,7 +116,7 @@ func TestLogToFile(t *testing.T) {
117116
log.Error(want)
118117

119118
// read log file and check contents
120-
content, err := ioutil.ReadFile(logfile.Name())
119+
content, err := os.ReadFile(logfile.Name())
121120
if err != nil {
122121
t.Fatal(err)
123122
}

0 commit comments

Comments
 (0)