Skip to content

Commit d908619

Browse files
authored
Build(v2): fix usage by moving code to a v2 subfolder (#927)
1 parent eda2790 commit d908619

File tree

859 files changed

+101
-72
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

859 files changed

+101
-72
lines changed

.circleci/config.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ jobs:
2222
command: go version
2323
- run:
2424
name: Core and drivers tests
25-
command: go test -v -coverprofile=coverage.txt -covermode=atomic . ./drivers/...
25+
command: |
26+
cd ./v2
27+
go test -v -coverprofile=coverage.txt -covermode=atomic . ./drivers/...
2628
- run:
2729
name: Code coverage
2830
command: |
@@ -39,7 +41,9 @@ jobs:
3941
- run:
4042
# digispark needs libusb, joystick needs sdl2, opencv needs opencv
4143
name: Platform tests (except digispark, joystick, opencv)
42-
command: go test -v $(go list ./platforms/... | grep -v platforms/digispark | grep -v platforms/joystick | grep -v platforms/opencv)
44+
command: |
45+
cd ./v2
46+
go test -v $(go list ./platforms/... | grep -v platforms/digispark | grep -v platforms/joystick | grep -v platforms/opencv)
4347
4448
"check_examples":
4549
docker:
@@ -53,6 +57,7 @@ jobs:
5357
# digispark needs libusb, joystick needs sdl2, opencv needs opencv
5458
name: Check examples (except digispark, joystick, opencv)
5559
command: |
60+
cd ./v2
5661
ALL=$(grep -l -r --include "*.go" 'build example' ./)
5762
SOME=$(grep -L 'digispark' $(grep -L 'joystick' $(grep -L 'gocv' ${ALL})))
5863
for e in ${SOME} ; do go vet "${e}" ; done

.github/workflows/golangci-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
version: v1.52.2
2828

2929
# Optional: working directory, useful for monorepos
30-
# working-directory: somedir
30+
working-directory: v2
3131

3232
# Optional: golangci-lint command line arguments.
3333
# mostly there is no problem locally, but on server: "could not import C (cgo preprocessing failed) (typecheck)"

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# note: GolangCI-Lint also searches for config files in all directories from the directory of the first analyzed path up to the root.
12
run:
23
# Timeout for analysis, e.g. 30s, 5m.
34
# gobot is very expensive, on a machine with heavy load it takes some minutes

Makefile

Lines changed: 9 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,16 @@
1-
# include also examples in other than ./examples folder
2-
ALL_EXAMPLES := $(shell grep -l -r --include "*.go" 'build example' ./)
3-
# prevent examples with gocv (opencv) dependencies
4-
EXAMPLES_NO_GOCV := $(shell grep -L 'gocv' $(ALL_EXAMPLES))
5-
# prevent examples with joystick (sdl2) dependencies
6-
EXAMPLES_NO_JOYSTICK := $(shell grep -L 'joystick' $(ALL_EXAMPLES))
7-
# prevent examples with joystick (sdl2) and gocv (opencv) dependencies
8-
EXAMPLES_NO_GOCV_JOYSTICK := $(shell grep -L 'joystick' $$(grep -L 'gocv' $(EXAMPLES_NO_GOCV)))
9-
# used examples
10-
EXAMPLES := $(EXAMPLES_NO_GOCV_JOYSTICK)
1+
# this file is just a forwarder to the folder with go.mod for common use cases
2+
# it is working since Go 1.18 is installed locally
113

12-
.PHONY: test test_race test_cover robeaux version_check fmt_check fmt_fix examples examples_check $(EXAMPLES)
4+
gomoddir := $(shell go list -f '{{.Dir}}' -m)
135

14-
# opencv platform currently skipped to prevent install of preconditions
15-
including_except := $(shell go list ./... | grep -v platforms/opencv)
166

17-
# Run tests on nearly all directories without test cache
18-
test:
19-
go test -count=1 -v $(including_except)
20-
21-
# Run tests with race detection
22-
test_race:
23-
go test -race $(including_except)
24-
25-
# Test, generate and show coverage in browser
26-
test_cover:
27-
go test -v $(including_except) -coverprofile=coverage.txt ; \
28-
go tool cover -html=coverage.txt ; \
29-
30-
robeaux:
31-
ifeq (,$(shell which go-bindata))
32-
$(error robeaux not built! https://github.com/jteeuwen/go-bindata is required to build robeaux assets )
33-
endif
34-
cd api ; \
35-
npm install robeaux ; \
36-
cp -r node_modules/robeaux robeaux-tmp ; \
37-
cd robeaux-tmp ; \
38-
rm Makefile package.json README.markdown ; \
39-
touch css/fonts.css ; \
40-
echo "Updating robeaux..." ; \
41-
go-bindata -pkg="robeaux" -o robeaux.go -ignore=\\.git ./... ; \
42-
mv robeaux.go ../robeaux ; \
43-
cd .. ; \
44-
rm -rf robeaux-tmp/ ; \
45-
rm -rf node_modules/ ; \
46-
go fmt ./robeaux/robeaux.go ; \
7+
.PHONY: test fmt_check examples_check
478

48-
# Check for installed and module version match. Will exit with code 50 if not match.
49-
# There is nothing bad in general, if you program with a higher version.
50-
# At least the recipe "fmt_fix" will not work in that case.
51-
version_check:
52-
@gv=$$(echo $$(go version) | sed "s/^.* go\([0-9].[0-9]*\).*/\1/") ; \
53-
mv=$$(grep -m 1 'go 1.' ./go.mod | sed "s/^go \([0-9].[0-9]*\).*/\1/") ; \
54-
echo "go: $${gv}.*, go.mod: $${mv}" ; \
55-
if [ "$${gv}" != "$${mv}" ]; then exit 50; fi ; \
9+
test:
10+
cd $(gomoddir) && make test && cd ..
5611

57-
# Check for bad code style and other issues
5812
fmt_check:
59-
gofmt -l ./
60-
golangci-lint run -v
61-
62-
# Fix bad code style (will only be executed, on version match)
63-
fmt_fix: version_check
64-
go fmt ./...
65-
66-
examples: $(EXAMPLES)
67-
68-
examples_check:
69-
$(MAKE) CHECK=ON examples
13+
cd $(gomoddir) && make fmt_check && cd ..
7014

71-
$(EXAMPLES):
72-
ifeq ($(CHECK),ON)
73-
go vet ./$@
74-
else
75-
go build -o /tmp/gobot_examples/$@ ./$@
76-
endif
15+
examples_check:
16+
cd $(gomoddir) && make examples_check && cd ..

appveyor.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ before_test:
1313
- go env
1414

1515
build_script:
16+
- cd ./v2
1617
- go test -v -cpu=2 .
1718
- go test -v -cpu=2 ./drivers/aio/...
1819
- go test -v -cpu=2 ./drivers/i2c/...
1920
- go test -v -cpu=2 ./platforms/firmata/...
2021
- go test -v -cpu=2 ./platforms/ble/...
22+
- cd ..

go.work

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
go 1.17
2+
3+
// this helps go tools and golangci-lint to find the subfolder
4+
// it is working since Go 1.18 is installed
5+
use ./v2

v2/Makefile

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# include also examples in other than ./examples folder
2+
ALL_EXAMPLES := $(shell grep -l -r --include "*.go" 'build example' ./)
3+
# prevent examples with gocv (opencv) dependencies
4+
EXAMPLES_NO_GOCV := $(shell grep -L 'gocv' $(ALL_EXAMPLES))
5+
# prevent examples with joystick (sdl2) dependencies
6+
EXAMPLES_NO_JOYSTICK := $(shell grep -L 'joystick' $(ALL_EXAMPLES))
7+
# prevent examples with joystick (sdl2) and gocv (opencv) dependencies
8+
EXAMPLES_NO_GOCV_JOYSTICK := $(shell grep -L 'joystick' $$(grep -L 'gocv' $(EXAMPLES_NO_GOCV)))
9+
# used examples
10+
EXAMPLES := $(EXAMPLES_NO_GOCV_JOYSTICK)
11+
12+
.PHONY: test test_race test_cover robeaux version_check fmt_check fmt_fix examples examples_check $(EXAMPLES)
13+
14+
# opencv platform currently skipped to prevent install of preconditions
15+
including_except := $(shell go list ./... | grep -v platforms/opencv)
16+
17+
# Run tests on nearly all directories without test cache
18+
test:
19+
go test -count=1 -v $(including_except)
20+
21+
# Run tests with race detection
22+
test_race:
23+
go test -race $(including_except)
24+
25+
# Test, generate and show coverage in browser
26+
test_cover:
27+
go test -v $(including_except) -coverprofile=coverage.txt ; \
28+
go tool cover -html=coverage.txt ; \
29+
30+
robeaux:
31+
ifeq (,$(shell which go-bindata))
32+
$(error robeaux not built! https://github.com/jteeuwen/go-bindata is required to build robeaux assets )
33+
endif
34+
cd api ; \
35+
npm install robeaux ; \
36+
cp -r node_modules/robeaux robeaux-tmp ; \
37+
cd robeaux-tmp ; \
38+
rm Makefile package.json README.markdown ; \
39+
touch css/fonts.css ; \
40+
echo "Updating robeaux..." ; \
41+
go-bindata -pkg="robeaux" -o robeaux.go -ignore=\\.git ./... ; \
42+
mv robeaux.go ../robeaux ; \
43+
cd .. ; \
44+
rm -rf robeaux-tmp/ ; \
45+
rm -rf node_modules/ ; \
46+
go fmt ./robeaux/robeaux.go ; \
47+
48+
# Check for installed and module version match. Will exit with code 50 if not match.
49+
# There is nothing bad in general, if you program with a higher version.
50+
# At least the recipe "fmt_fix" will not work in that case.
51+
version_check:
52+
@gv=$$(echo $$(go version) | sed "s/^.* go\([0-9].[0-9]*\).*/\1/") ; \
53+
mv=$$(grep -m 1 'go 1.' ./go.mod | sed "s/^go \([0-9].[0-9]*\).*/\1/") ; \
54+
echo "go: $${gv}.*, go.mod: $${mv}" ; \
55+
if [ "$${gv}" != "$${mv}" ]; then exit 50; fi ; \
56+
57+
# Check for bad code style and other issues
58+
fmt_check:
59+
gofmt -l ./
60+
golangci-lint run -v
61+
62+
# Fix bad code style (will only be executed, on version match)
63+
fmt_fix: version_check
64+
go fmt ./...
65+
66+
examples: $(EXAMPLES)
67+
68+
examples_check:
69+
$(MAKE) CHECK=ON examples
70+
71+
$(EXAMPLES):
72+
ifeq ($(CHECK),ON)
73+
go vet ./$@
74+
else
75+
go build -o /tmp/gobot_examples/$@ ./$@
76+
endif
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)