mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 04:37:36 +03:00
run the check for go generated files on Github Actions instead of Travis
This commit is contained in:
parent
4d1d05e4bf
commit
91e5ca4947
7 changed files with 49 additions and 32 deletions
21
.github/workflows/go-generate.sh
vendored
Executable file
21
.github/workflows/go-generate.sh
vendored
Executable file
|
@ -0,0 +1,21 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
find . -type f -name "*.go" -exec shasum {} \; > checksums_before.txt
|
||||||
|
# delete all go-generated files generated (that adhere to the comment convention)
|
||||||
|
grep --include \*.go --exclude-dir quictrace/ -lrIZ "^// Code generated .* DO NOT EDIT\.$" . | xargs --null rm
|
||||||
|
# delete all files generated by Genny
|
||||||
|
grep --include \*.go -lrIZ "This file was automatically generated by genny." . | xargs --null rm
|
||||||
|
# first generate Genny files to make the code compile
|
||||||
|
grep --include \*.go -lrI "//go:generate genny" | xargs -L 1 go generate
|
||||||
|
# now generate everything
|
||||||
|
go generate ./...
|
||||||
|
find . -type f -name "*.go" -exec shasum {} \; > checksums_after.txt
|
||||||
|
DIFF=$(diff checksums_before.txt checksums_after.txt) || true
|
||||||
|
echo "$DIFF"
|
||||||
|
if [ -n "$DIFF" ]; then
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "All generated files match."
|
||||||
|
fi
|
19
.github/workflows/go-generate.yml
vendored
Normal file
19
.github/workflows/go-generate.yml
vendored
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
gogenerate:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-go@v2.1.1
|
||||||
|
- name: Install dependencies
|
||||||
|
run: go build
|
||||||
|
- name: Install code generators
|
||||||
|
run: |
|
||||||
|
go install -v github.com/cheekybits/genny
|
||||||
|
go install -v github.com/golang/mock/mockgen
|
||||||
|
go install -v golang.org/x/tools/cmd/goimports
|
||||||
|
- name: Run code generators
|
||||||
|
run: |
|
||||||
|
export GOPATH=$(go env GOPATH)
|
||||||
|
export PATH=$PATH:$GOPATH/bin
|
||||||
|
.github/workflows/go-generate.sh
|
|
@ -14,7 +14,6 @@ env:
|
||||||
- TIMESCALE_FACTOR=20
|
- TIMESCALE_FACTOR=20
|
||||||
matrix:
|
matrix:
|
||||||
- TRAVIS_GOARCH=amd64 TESTMODE=lint
|
- TRAVIS_GOARCH=amd64 TESTMODE=lint
|
||||||
- TRAVIS_GOARCH=amd64 TESTMODE=gogenerate
|
|
||||||
- TRAVIS_GOARCH=amd64 TESTMODE=unit
|
- TRAVIS_GOARCH=amd64 TESTMODE=unit
|
||||||
- TRAVIS_GOARCH=amd64 TESTMODE=integration
|
- TRAVIS_GOARCH=amd64 TESTMODE=integration
|
||||||
- TRAVIS_GOARCH=386 TESTMODE=unit
|
- TRAVIS_GOARCH=386 TESTMODE=unit
|
||||||
|
@ -26,12 +25,6 @@ before_install:
|
||||||
- travis_retry go get golang.org/x/tools/cmd/cover
|
- travis_retry go get golang.org/x/tools/cmd/cover
|
||||||
- travis_retry go get github.com/onsi/ginkgo/ginkgo
|
- travis_retry go get github.com/onsi/ginkgo/ginkgo
|
||||||
- travis_retry go get github.com/onsi/gomega
|
- travis_retry go get github.com/onsi/gomega
|
||||||
- |
|
|
||||||
if [ ${TESTMODE} == "gogenerate" ]; then
|
|
||||||
travis_retry go get github.com/cheekybits/genny
|
|
||||||
travis_retry go get github.com/golang/mock/mockgen
|
|
||||||
travis_retry go get golang.org/x/tools/cmd/goimports
|
|
||||||
fi
|
|
||||||
- export GOARCH=$TRAVIS_GOARCH
|
- export GOARCH=$TRAVIS_GOARCH
|
||||||
- go env # for debugging
|
- go env # for debugging
|
||||||
- travis_retry go get -t ./...
|
- travis_retry go get -t ./...
|
||||||
|
|
|
@ -7,24 +7,6 @@ if [ "${TESTMODE}" == "lint" ]; then
|
||||||
./bin/golangci-lint run ./...
|
./bin/golangci-lint run ./...
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${TESTMODE}" == "gogenerate" ]; then
|
|
||||||
find . -type f -name "*.go" -exec shasum {} \; > checksums_before.txt
|
|
||||||
# delete all go-generated files generated (that adhere to the comment convention)
|
|
||||||
grep --include \*.go --exclude-dir quictrace/ -lrIZ "^// Code generated .* DO NOT EDIT\.$" . | xargs --null rm
|
|
||||||
# delete all files generated by Genny
|
|
||||||
grep --include \*.go -lrIZ "This file was automatically generated by genny." . | xargs --null rm
|
|
||||||
# first generate Genny files to make the code compile
|
|
||||||
grep --include \*.go -lrI "//go:generate genny" | xargs -L 1 go generate
|
|
||||||
# now generate everything
|
|
||||||
go generate ./...
|
|
||||||
find . -type f -name "*.go" -exec shasum {} \; > checksums_after.txt
|
|
||||||
DIFF=$(diff checksums_before.txt checksums_after.txt)
|
|
||||||
echo "$DIFF"
|
|
||||||
if [ -n "$DIFF" ]; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${TESTMODE}" == "unit" ]; then
|
if [ "${TESTMODE}" == "unit" ]; then
|
||||||
ginkgo -r -v -cover -randomizeAllSpecs -randomizeSuites -trace -skipPackage integrationtests,benchmark
|
ginkgo -r -v -cover -randomizeAllSpecs -randomizeSuites -trace -skipPackage integrationtests,benchmark
|
||||||
# run unit tests with the Go race detector
|
# run unit tests with the Go race detector
|
||||||
|
|
|
@ -5,13 +5,14 @@
|
||||||
package logging
|
package logging
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
net "net"
|
||||||
|
reflect "reflect"
|
||||||
|
time "time"
|
||||||
|
|
||||||
gomock "github.com/golang/mock/gomock"
|
gomock "github.com/golang/mock/gomock"
|
||||||
protocol "github.com/lucas-clemente/quic-go/internal/protocol"
|
protocol "github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
utils "github.com/lucas-clemente/quic-go/internal/utils"
|
utils "github.com/lucas-clemente/quic-go/internal/utils"
|
||||||
wire "github.com/lucas-clemente/quic-go/internal/wire"
|
wire "github.com/lucas-clemente/quic-go/internal/wire"
|
||||||
net "net"
|
|
||||||
reflect "reflect"
|
|
||||||
time "time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// MockConnectionTracer is a mock of ConnectionTracer interface
|
// MockConnectionTracer is a mock of ConnectionTracer interface
|
||||||
|
|
|
@ -5,11 +5,12 @@
|
||||||
package logging
|
package logging
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
net "net"
|
||||||
|
reflect "reflect"
|
||||||
|
|
||||||
gomock "github.com/golang/mock/gomock"
|
gomock "github.com/golang/mock/gomock"
|
||||||
protocol "github.com/lucas-clemente/quic-go/internal/protocol"
|
protocol "github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
wire "github.com/lucas-clemente/quic-go/internal/wire"
|
wire "github.com/lucas-clemente/quic-go/internal/wire"
|
||||||
net "net"
|
|
||||||
reflect "reflect"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// MockTracer is a mock of Tracer interface
|
// MockTracer is a mock of Tracer interface
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package logging
|
package logging
|
||||||
|
|
||||||
//go:generate sh -c "mockgen -package logging -destination mock_connection_tracer_test.go github.com/lucas-clemente/quic-go/logging ConnectionTracer"
|
//go:generate sh -c "mockgen -package logging -self_package github.com/lucas-clemente/quic-go/logging -destination mock_connection_tracer_test.go github.com/lucas-clemente/quic-go/logging ConnectionTracer && goimports -w mock_connection_tracer_test.go"
|
||||||
//go:generate sh -c "mockgen -package logging -destination mock_tracer_test.go github.com/lucas-clemente/quic-go/logging Tracer"
|
//go:generate sh -c "mockgen -package logging -self_package github.com/lucas-clemente/quic-go/logging -destination mock_tracer_test.go github.com/lucas-clemente/quic-go/logging Tracer && goimports -w mock_tracer_test.go"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue