-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Modualize the samples so that they can be gonew (#130)
* refactor: Modularization * refactor: Modularization * refactor: Modularization * chore: Fix the gen target * refactor: Modularization * refactor: Modularization * refactor: Modularization * refactor: Modularization * refactor: Modularization * refactor: Modularization * refactor: Modularization * refactor: Modularization * refactor: Modularization * refactor: Modularization * chore: Remve unused files * chore: Update * fix: Fix copy errors * chore: go mod tidy * chore: Add temporarily replacing * Add information about cloning templates using command * doc: Fix gonew command in README * chore: Temporary remove * doc: Add Goa clue example information to README
- Loading branch information
Showing
342 changed files
with
2,767 additions
and
1,246 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,10 +7,6 @@ jobs: | |
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Collect Workflow Telemetry | ||
uses: runforesight/foresight-workflow-kit-action@v1 | ||
if: success() || failure() | ||
|
||
- name: Set up Go 1.21 | ||
uses: actions/[email protected] | ||
with: | ||
|
@@ -25,18 +21,9 @@ jobs: | |
run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH | ||
id: setup_path | ||
|
||
- name: Build | ||
run: make ci | ||
|
||
- name: Compute code coverage | ||
run: go test -v -json -coverprofile=coverage.out ./...> ./test-report.json || true | ||
|
||
- name: Analyze Test and/or Coverage Results | ||
uses: runforesight/foresight-test-kit-action@v1 | ||
if: success() || failure() | ||
with: | ||
test_format: JSON | ||
test_framework: GOLANG | ||
test_path: "./test-report.json" | ||
coverage_format: GOLANG | ||
coverage_path: ./coverage.out | ||
- name: Run CI for each Makefile | ||
run: | | ||
for makefile in $(find . -type f -name Makefile); do | ||
make -C $(dirname $makefile) test | ||
done | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#! /usr/bin/make | ||
# | ||
# Makefile for Goa examples | ||
# | ||
# Targets: | ||
# - "depend" retrieves the Go packages needed to run the linter and tests | ||
# - "gen" invokes the "goa" tool to generate the examples source code | ||
# - "build" compiles the example microservices and client CLIs | ||
# - "clean" deletes the output of "build" | ||
# - "lint" runs the linter and checks the code format using goimports | ||
# - "test" runs the tests | ||
# | ||
# Meta targets: | ||
# - "all" is the default target, it runs all the targets in the order above. | ||
# | ||
GO_FILES=$(shell find . -type f -name '*.go') | ||
MODULE=$(shell go list -m) | ||
APP=calc | ||
|
||
# Only list test and build dependencies | ||
# Standard dependencies are installed via go get | ||
DEPEND=\ | ||
github.com/hashicorp/go-getter \ | ||
github.com/cheggaaa/pb \ | ||
github.com/golang/protobuf/protoc-gen-go \ | ||
github.com/golang/protobuf/proto \ | ||
goa.design/goa/... \ | ||
golang.org/x/lint/golint \ | ||
golang.org/x/tools/cmd/goimports \ | ||
honnef.co/go/tools/cmd/staticcheck | ||
|
||
.phony: all depend lint test build clean | ||
|
||
all: gen lint test | ||
@echo DONE! | ||
|
||
# Install protoc | ||
GOOS=$(shell go env GOOS) | ||
PROTOC_VERSION=3.6.1 | ||
ifeq ($(GOOS),linux) | ||
PROTOC=protoc-$(PROTOC_VERSION)-linux-x86_64 | ||
PROTOC_EXEC=$(PROTOC)/bin/protoc | ||
GOBIN=$(GOPATH)/bin | ||
else | ||
ifeq ($(GOOS),darwin) | ||
PROTOC=protoc-$(PROTOC_VERSION)-osx-x86_64 | ||
PROTOC_EXEC=$(PROTOC)/bin/protoc | ||
GOBIN=$(GOPATH)/bin | ||
else | ||
ifeq ($(GOOS),windows) | ||
PROTOC=protoc-$(PROTOC_VERSION)-win32 | ||
PROTOC_EXEC="$(PROTOC)\bin\protoc.exe" | ||
GOBIN="$(GOPATH)\bin" | ||
endif | ||
endif | ||
endif | ||
depend: | ||
@echo INSTALLING DEPENDENCIES... | ||
@go get -v $(DEPEND) | ||
@go install github.com/hashicorp/go-getter/cmd/go-getter && \ | ||
go-getter https://github.com/google/protobuf/releases/download/v$(PROTOC_VERSION)/$(PROTOC).zip $(PROTOC) && \ | ||
cp $(PROTOC_EXEC) $(GOBIN) && \ | ||
rm -r $(PROTOC) | ||
@go install github.com/golang/protobuf/protoc-gen-go | ||
@go get -t -v ./... | ||
|
||
lint: | ||
@echo LINTING CODE... | ||
@if [ "`goimports -l $(GO_FILES) | grep -v .pb.go | tee /dev/stderr`" ]; then \ | ||
echo "^ - Repo contains improperly formatted go files" && echo && exit 1; \ | ||
fi | ||
@if [ "`staticcheck -checks all,-ST1000,-ST1001 ./... | grep -v ".pb.go" | tee /dev/stderr`" ]; then \ | ||
echo "^ - staticcheck errors!" && echo && exit 1; \ | ||
fi | ||
|
||
.PHONY: gen | ||
gen: | ||
@# NOTE: not all command line tools are generated | ||
@echo GENERATING CODE... | ||
goa gen "$(MODULE)/design" && \ | ||
goa example "$(MODULE)/design" | ||
|
||
build: | ||
@go build "./cmd/$(APP)" && go build "./cmd/$(APP)-cli" | ||
|
||
clean: | ||
@rm -rf "./cmd/$(APP)" "./cmd/$(APP)-cli" | ||
|
||
test: | ||
@echo TESTING... | ||
@go test ./... > /dev/null | ||
|
||
check-freshness: | ||
@if [ "`git diff | wc -l`" -gt "0" ]; then \ | ||
echo "[ERROR] generated code not in-sync with design:"; \ | ||
echo; \ | ||
git status -s; \ | ||
git --no-pager diff; \ | ||
echo; \ | ||
exit 1; \ | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.