Skip to content

Commit 2a35386

Browse files
authored
ci: uci/copy-templates (#140)
* chore: add or force update .github/workflows/go-test.yml * chore: add or force update .github/workflows/go-check.yml
1 parent 4e389a9 commit 2a35386

File tree

2 files changed

+30
-137
lines changed

2 files changed

+30
-137
lines changed

.github/workflows/go-check.yml

Lines changed: 15 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,18 @@
1-
# File managed by web3-bot. DO NOT EDIT.
2-
# See https://github.com/protocol/.github/ for details.
3-
4-
on: [push, pull_request]
51
name: Go Checks
62

3+
on:
4+
pull_request:
5+
push:
6+
branches: ["main"]
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
14+
cancel-in-progress: true
15+
716
jobs:
8-
unit:
9-
runs-on: ubuntu-latest
10-
name: All
11-
steps:
12-
- uses: actions/checkout@v3
13-
with:
14-
submodules: recursive
15-
- id: config
16-
uses: protocol/.github/.github/actions/read-config@master
17-
- uses: actions/setup-go@v3
18-
with:
19-
go-version: 1.20.x
20-
- name: Run repo-specific setup
21-
uses: ./.github/actions/go-check-setup
22-
if: hashFiles('./.github/actions/go-check-setup') != ''
23-
- name: Install staticcheck
24-
run: go install honnef.co/go/tools/cmd/staticcheck@4970552d932f48b71485287748246cf3237cebdf # 2023.1 (v0.4.0)
25-
- name: Check that go.mod is tidy
26-
uses: protocol/[email protected]
27-
with:
28-
run: |
29-
go mod tidy
30-
if [[ -n $(git ls-files --other --exclude-standard --directory -- go.sum) ]]; then
31-
echo "go.sum was added by go mod tidy"
32-
exit 1
33-
fi
34-
git diff --exit-code -- go.sum go.mod
35-
- name: gofmt
36-
if: success() || failure() # run this step even if the previous one failed
37-
run: |
38-
out=$(gofmt -s -l .)
39-
if [[ -n "$out" ]]; then
40-
echo $out | awk '{print "::error file=" $0 ",line=0,col=0::File is not gofmt-ed."}'
41-
exit 1
42-
fi
43-
- name: go vet
44-
if: success() || failure() # run this step even if the previous one failed
45-
uses: protocol/[email protected]
46-
with:
47-
run: go vet ./...
48-
- name: staticcheck
49-
if: success() || failure() # run this step even if the previous one failed
50-
uses: protocol/[email protected]
51-
with:
52-
run: |
53-
set -o pipefail
54-
staticcheck ./... | sed -e 's@\(.*\)\.go@./\1.go@g'
55-
- name: go generate
56-
uses: protocol/[email protected]
57-
if: (success() || failure()) && fromJSON(steps.config.outputs.json).gogenerate == true
58-
with:
59-
run: |
60-
git clean -fd # make sure there aren't untracked files / directories
61-
go generate -x ./...
62-
# check if go generate modified or added any files
63-
if ! $(git add . && git diff-index HEAD --exit-code --quiet); then
64-
echo "go generated caused changes to the repository:"
65-
git status --short
66-
exit 1
67-
fi
17+
go-check:
18+
uses: pl-strflt/uci/.github/workflows/[email protected]

.github/workflows/go-test.yml

Lines changed: 15 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,18 @@
1-
# File managed by web3-bot. DO NOT EDIT.
2-
# See https://github.com/protocol/.github/ for details.
3-
4-
on: [push, pull_request]
51
name: Go Test
62

3+
on:
4+
pull_request:
5+
push:
6+
branches: ["main"]
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
14+
cancel-in-progress: true
15+
716
jobs:
8-
unit:
9-
strategy:
10-
fail-fast: false
11-
matrix:
12-
os: [ "ubuntu", "windows", "macos" ]
13-
go: ["1.19.x","1.20.x"]
14-
env:
15-
COVERAGES: ""
16-
runs-on: ${{ fromJSON(vars[format('UCI_GO_TEST_RUNNER_{0}', matrix.os)] || format('"{0}-latest"', matrix.os)) }}
17-
name: ${{ matrix.os }} (go ${{ matrix.go }})
18-
steps:
19-
- uses: actions/checkout@v3
20-
with:
21-
submodules: recursive
22-
- id: config
23-
uses: protocol/.github/.github/actions/read-config@master
24-
- uses: actions/setup-go@v3
25-
with:
26-
go-version: ${{ matrix.go }}
27-
- name: Go information
28-
run: |
29-
go version
30-
go env
31-
- name: Use msys2 on windows
32-
if: matrix.os == 'windows'
33-
shell: bash
34-
# The executable for msys2 is also called bash.cmd
35-
# https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md#shells
36-
# If we prepend its location to the PATH
37-
# subsequent 'shell: bash' steps will use msys2 instead of gitbash
38-
run: echo "C:/msys64/usr/bin" >> $GITHUB_PATH
39-
- name: Run repo-specific setup
40-
uses: ./.github/actions/go-test-setup
41-
if: hashFiles('./.github/actions/go-test-setup') != ''
42-
- name: Run tests
43-
if: contains(fromJSON(steps.config.outputs.json).skipOSes, matrix.os) == false
44-
uses: protocol/[email protected]
45-
with:
46-
# Use -coverpkg=./..., so that we include cross-package coverage.
47-
# If package ./A imports ./B, and ./A's tests also cover ./B,
48-
# this means ./B's coverage will be significantly higher than 0%.
49-
run: go test -v -shuffle=on -coverprofile=module-coverage.txt -coverpkg=./... ./...
50-
- name: Run tests (32 bit)
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
55-
uses: protocol/[email protected]
56-
env:
57-
GOARCH: 386
58-
with:
59-
run: |
60-
export "PATH=$PATH_386:$PATH"
61-
go test -v -shuffle=on ./...
62-
- name: Run tests with race detector
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
66-
uses: protocol/[email protected]
67-
with:
68-
run: go test -v -race ./...
69-
- name: Collect coverage files
70-
shell: bash
71-
run: echo "COVERAGES=$(find . -type f -name 'module-coverage.txt' | tr -s '\n' ',' | sed 's/,$//')" >> $GITHUB_ENV
72-
- name: Upload coverage to Codecov
73-
uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
74-
with:
75-
files: '${{ env.COVERAGES }}'
76-
env_vars: OS=${{ matrix.os }}, GO=${{ matrix.go }}
17+
go-test:
18+
uses: pl-strflt/uci/.github/workflows/[email protected]

0 commit comments

Comments
 (0)