github action: update for go1.17 and fix checks for PRs

- Use go1.17 for github actions.
- Use go mod edit instead of go get for testing other packages. There's two
  benefits:
  - This removes the round trip to pkg.go.dev and use the already present local
    checkout.
  - The go get periph.io/x/conn/v3@${GITHUB_SHA} command worked if a maintainer
    push a branch, but fails for a PR. This is because the go get command does a
    clone with all the branches, so it finds the commit even if it's not in main.
    For a PR, one has to pull a specific refs/pull/ID/head ref that is not a
    branch, thus go get cannot find it because git clone doesn't know about it.
    The only way to work around is to git clone manually.
- Remove 'go version' and 'go env' since they are already run as part of
  setup-go@v2.
- Fix a new check in go vet in example code.
pull/18/head
Marc-Antoine Ruel 5 years ago
parent 440ba6e652
commit 97998e315b

@ -24,7 +24,7 @@ jobs:
matrix: matrix:
os: [ubuntu-latest, macos-latest, windows-latest] os: [ubuntu-latest, macos-latest, windows-latest]
# Do not forget to bump every 6 months! # Do not forget to bump every 6 months!
gover: ["1.16"] gover: ["1.17"]
runs-on: "${{matrix.os}}" runs-on: "${{matrix.os}}"
name: "go${{matrix.gover}}.x on ${{matrix.os}}" name: "go${{matrix.gover}}.x on ${{matrix.os}}"
steps: steps:
@ -36,10 +36,6 @@ jobs:
- name: Turn off git core.autocrlf - name: Turn off git core.autocrlf
run: git config --global core.autocrlf false run: git config --global core.autocrlf false
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: 'go version'
run: go version
- name: 'go env'
run: go env
- name: "Debug" - name: "Debug"
run: | run: |
echo HOME = $HOME echo HOME = $HOME
@ -53,7 +49,7 @@ jobs:
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ~/go path: ~/go
key: "${{runner.os}}-gopkg-${{hashFiles('go.sum', '.github/workflows/*.yml')}}-v2" key: "${{runner.os}}-gopkg-${{hashFiles('go.sum', '.github/workflows/*.yml')}}"
# Fetch the tools before checking out, so they don't modify go.mod/go.sum. # Fetch the tools before checking out, so they don't modify go.mod/go.sum.
- name: 'go get necessary tools' - name: 'go get necessary tools'
@ -148,9 +144,11 @@ jobs:
run: rm coverage.txt run: rm coverage.txt
# Don't run go test -race if anything failed, to speed up the results. # Don't run go test -race if anything failed, to speed up the results.
- name: 'Check: go test -race' - name: 'Check: go test -race'
run: go test -timeout=40s -race ./... run: go test -timeout=60s -race ./...
- name: 'Check: go test -bench .' - name: 'Check: go test -bench .'
run: go test -timeout=40s -bench . -benchtime=100ms -cpu=1 ./... run: go test -timeout=40s -bench . -benchtime=100ms -cpu=1 ./...
- name: 'Check: CGO_ENABLED=0 go test -short'
run: CGO_ENABLED=0 go test -timeout=40s -short ./...
- name: "Check: tree is clean" - name: "Check: tree is clean"
run: | run: |
@ -195,7 +193,8 @@ jobs:
cd .. cd ..
git clone https://github.com/periph/cmd git clone https://github.com/periph/cmd
cd cmd cd cmd
go get periph.io/x/devices/v3@${GITHUB_SHA} go mod edit -replace=periph.io/x/devices/v3=../devices
go get ./...
go test -short ./... go test -short ./...
- name: 'Send comments' - name: 'Send comments'

@ -63,7 +63,7 @@ func Example() {
}() }()
//Control-C trap //Control-C trap
c := make(chan os.Signal) c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM) signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() { go func() {
<-c <-c

Loading…
Cancel
Save