Skip to content

Commit 0fadeb4

Browse files
authored
Merge pull request spacemonkeygo#17 from libp2p/web3-bot/sync
sync: update CI config files
2 parents a04acfd + 1cac8de commit 0fadeb4

13 files changed

+261
-1
lines changed
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Go Test Setup
2+
description: Set up the environment for go test
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Common setup
7+
shell: bash
8+
run: |
9+
echo 'CGO_ENABLED=1' >> $GITHUB_ENV
10+
- name: Windows setup
11+
shell: bash
12+
if: ${{ runner.os == 'Windows' }}
13+
run: |
14+
echo '/c/msys64/mingw64/bin' >> $GITHUB_PATH
15+
echo 'PATH_386=/c/msys64/mingw32/bin:${{ env.PATH_386 }}' >> $GITHUB_ENV
16+
- name: Linux setup
17+
shell: bash
18+
if: ${{ runner.os == 'Linux' }}
19+
run: |
20+
sudo apt-get install gcc-multilib
21+
sudo dpkg --add-architecture i386
22+
sudo apt-get update
23+
sudo apt-get install libssl-dev:i386
24+
echo 'CC_FOR_linux_386=i686-w64-mingw32-gcc'

.github/workflows/automerge.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# File managed by web3-bot. DO NOT EDIT.
2+
# See https://github.com/protocol/.github/ for details.
3+
4+
# Automatically merge pull requests opened by web3-bot, as soon as (and only if) all tests pass.
5+
# This reduces the friction associated with updating with our workflows.
6+
7+
on: [ pull_request ]
8+
name: Automerge
9+
10+
jobs:
11+
automerge-check:
12+
if: github.event.pull_request.user.login == 'web3-bot'
13+
runs-on: ubuntu-latest
14+
outputs:
15+
status: ${{ steps.should-automerge.outputs.status }}
16+
steps:
17+
- uses: actions/checkout@v2
18+
with:
19+
fetch-depth: 0
20+
- name: Check if we should automerge
21+
id: should-automerge
22+
run: |
23+
for commit in $(git rev-list --first-parent origin/${{ github.event.pull_request.base.ref }}..${{ github.event.pull_request.head.sha }}); do
24+
committer=$(git show --format=$'%ce' -s $commit)
25+
echo "Committer: $committer"
26+
if [[ "$committer" != "[email protected]" ]]; then
27+
echo "Commit $commit wasn't committed by web3-bot, but by $committer."
28+
echo "::set-output name=status::false"
29+
exit
30+
fi
31+
done
32+
echo "::set-output name=status::true"
33+
automerge:
34+
needs: automerge-check
35+
runs-on: ubuntu-latest
36+
# The check for the user is redundant here, as this job depends on the automerge-check job,
37+
# but it prevents this job from spinning up, just to be skipped shortly after.
38+
if: github.event.pull_request.user.login == 'web3-bot' && needs.automerge-check.outputs.status == 'true'
39+
steps:
40+
- name: Wait on tests
41+
uses: lewagon/wait-on-check-action@bafe56a6863672c681c3cf671f5e10b20abf2eaa # v0.2
42+
with:
43+
ref: ${{ github.event.pull_request.head.sha }}
44+
repo-token: ${{ secrets.GITHUB_TOKEN }}
45+
wait-interval: 10
46+
running-workflow-name: 'automerge' # the name of this job
47+
- name: Merge PR
48+
uses: pascalgn/automerge-action@741c311a47881be9625932b0a0de1b0937aab1ae # v0.13.1
49+
env:
50+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
51+
MERGE_LABELS: ""
52+
MERGE_METHOD: "squash"
53+
MERGE_DELETE_BRANCH: true

.github/workflows/go-check.yml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# File managed by web3-bot. DO NOT EDIT.
2+
# See https://github.com/protocol/.github/ for details.
3+
4+
on: [push, pull_request]
5+
name: Go Checks
6+
7+
jobs:
8+
unit:
9+
runs-on: ubuntu-latest
10+
name: All
11+
env:
12+
RUNGOGENERATE: false
13+
steps:
14+
- uses: actions/checkout@v2
15+
with:
16+
submodules: recursive
17+
- uses: actions/setup-go@v2
18+
with:
19+
go-version: "1.17.x"
20+
- name: Run repo-specific setup
21+
uses: ./.github/actions/go-check-setup
22+
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
29+
- name: Install staticcheck
30+
run: go install honnef.co/go/tools/cmd/staticcheck@c8caa92bad8c27ae734c6725b8a04932d54a147b # 2021.1.2 (v0.2.2)
31+
- name: Check that go.mod is tidy
32+
uses: protocol/[email protected]
33+
with:
34+
run: |
35+
go mod tidy
36+
if [[ -n $(git ls-files --other --exclude-standard --directory -- go.sum) ]]; then
37+
echo "go.sum was added by go mod tidy"
38+
exit 1
39+
fi
40+
git diff --exit-code -- go.sum go.mod
41+
- name: gofmt
42+
if: ${{ success() || failure() }} # run this step even if the previous one failed
43+
run: |
44+
out=$(gofmt -s -l .)
45+
if [[ -n "$out" ]]; then
46+
echo $out | awk '{print "::error file=" $0 ",line=0,col=0::File is not gofmt-ed."}'
47+
exit 1
48+
fi
49+
- name: go vet
50+
if: ${{ success() || failure() }} # run this step even if the previous one failed
51+
uses: protocol/[email protected]
52+
with:
53+
run: go vet ./...
54+
- name: staticcheck
55+
if: ${{ success() || failure() }} # run this step even if the previous one failed
56+
uses: protocol/[email protected]
57+
with:
58+
run: |
59+
set -o pipefail
60+
staticcheck ./... | sed -e 's@\(.*\)\.go@./\1.go@g'
61+
- name: go generate
62+
uses: protocol/[email protected]
63+
if: (success() || failure()) && env.RUNGOGENERATE == 'true'
64+
with:
65+
run: |
66+
git clean -fd # make sure there aren't untracked files / directories
67+
go generate ./...
68+
# check if go generate modified or added any files
69+
if ! $(git add . && git diff-index HEAD --exit-code --quiet); then
70+
echo "go generated caused changes to the repository:"
71+
git status --short
72+
exit 1
73+
fi
74+

.github/workflows/go-test.yml

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# File managed by web3-bot. DO NOT EDIT.
2+
# See https://github.com/protocol/.github/ for details.
3+
4+
on: [push, pull_request]
5+
name: Go Test
6+
7+
jobs:
8+
unit:
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
os: [ "ubuntu", "windows", "macos" ]
13+
go: [ "1.16.x", "1.17.x" ]
14+
env:
15+
COVERAGES: ""
16+
runs-on: ${{ format('{0}-latest', matrix.os) }}
17+
name: ${{ matrix.os }} (go ${{ matrix.go }})
18+
steps:
19+
- uses: actions/checkout@v2
20+
with:
21+
submodules: recursive
22+
- uses: actions/setup-go@v2
23+
with:
24+
go-version: ${{ matrix.go }}
25+
- name: Go information
26+
run: |
27+
go version
28+
go env
29+
- name: Use msys2 on windows
30+
if: ${{ matrix.os == 'windows' }}
31+
shell: bash
32+
# The executable for msys2 is also called bash.cmd
33+
# https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md#shells
34+
# If we prepend its location to the PATH
35+
# subsequent 'shell: bash' steps will use msys2 instead of gitbash
36+
run: echo "C:/msys64/usr/bin" >> $GITHUB_PATH
37+
- name: Run repo-specific setup
38+
uses: ./.github/actions/go-test-setup
39+
if: hashFiles('./.github/actions/go-test-setup') != ''
40+
- name: Run tests
41+
uses: protocol/[email protected]
42+
with:
43+
# Use -coverpkg=./..., so that we include cross-package coverage.
44+
# If package ./A imports ./B, and ./A's tests also cover ./B,
45+
# this means ./B's coverage will be significantly higher than 0%.
46+
run: go test -v -coverprofile=module-coverage.txt -coverpkg=./... ./...
47+
- name: Run tests (32 bit)
48+
if: ${{ matrix.os != 'macos' }} # can't run 32 bit tests on OSX.
49+
uses: protocol/[email protected]
50+
env:
51+
GOARCH: 386
52+
with:
53+
run: |
54+
export "PATH=${{ env.PATH_386 }}:$PATH"
55+
go test -v ./...
56+
- name: Run tests with race detector
57+
if: ${{ matrix.os == 'ubuntu' }} # speed things up. Windows and OSX VMs are slow
58+
uses: protocol/[email protected]
59+
with:
60+
run: go test -v -race ./...
61+
- name: Collect coverage files
62+
shell: bash
63+
run: echo "COVERAGES=$(find . -type f -name 'module-coverage.txt' | tr -s '\n' ',' | sed 's/,$//')" >> $GITHUB_ENV
64+
- name: Upload coverage to Codecov
65+
uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
66+
with:
67+
files: '${{ env.COVERAGES }}'
68+
env_vars: OS=${{ matrix.os }}, GO=${{ matrix.go }}

.github/workflows/release-check.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# File managed by web3-bot. DO NOT EDIT.
2+
# See https://github.com/protocol/.github/ for details.
3+
4+
name: Release Checker
5+
on:
6+
pull_request:
7+
paths: [ 'version.json' ]
8+
9+
jobs:
10+
release-check:
11+
uses: protocol/.github/.github/workflows/release-check.yml@master

.github/workflows/releaser.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# File managed by web3-bot. DO NOT EDIT.
2+
# See https://github.com/protocol/.github/ for details.
3+
4+
name: Releaser
5+
on:
6+
push:
7+
paths: [ 'version.json' ]
8+
9+
jobs:
10+
releaser:
11+
uses: protocol/.github/.github/workflows/releaser.yml@master

.github/workflows/tagpush.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# File managed by web3-bot. DO NOT EDIT.
2+
# See https://github.com/protocol/.github/ for details.
3+
4+
name: Tag Push Checker
5+
on:
6+
push:
7+
tags:
8+
- v*
9+
10+
jobs:
11+
releaser:
12+
uses: protocol/.github/.github/workflows/tagpush.yml@master

build.go

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
//go:build !openssl_static
1516
// +build !openssl_static
1617

1718
package openssl

build_static.go

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
//go:build openssl_static
1516
// +build openssl_static
1617

1718
package openssl

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ require (
66
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb // indirect
77
)
88

9-
go 1.12
9+
go 1.16

init_posix.go

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
//go:build (linux || darwin || solaris || freebsd || openbsd) && !windows
1516
// +build linux darwin solaris freebsd openbsd
1617
// +build !windows
1718

init_windows.go

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
//go:build windows
1516
// +build windows
1617

1718
package openssl

version.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"version": "v0.0.7"
3+
}

0 commit comments

Comments
 (0)