Skip to content

Commit

Permalink
feat: scaffolding ca certs
Browse files Browse the repository at this point in the history
  • Loading branch information
lkingland committed Jun 21, 2023
1 parent 8dc5a76 commit 247d1c4
Show file tree
Hide file tree
Showing 14 changed files with 22,734 additions and 11,994 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/cmd/func.yaml
/templates/typescript/cloudevents/build
/templates/typescript/http/build
/templates/go/cloudevents/go.sum
/coverage.out
/coverage.txt
/.coverage
Expand Down
83 changes: 59 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@ LDFLAGS := "-X main.date=$(DATE) -X main.vers=$(VERS) -X main.kver=$(KVER) -X ma
CODE := $(shell find . -name '*.go') generate/zz_filesystem_generated.go go.mod schema/func_yaml-schema.json
TEMPLATES := $(shell find templates -name '*' -type f)

.PHONY: test docs

# Default Targets
# Default Target
all: build docs

# Help Text
# Headings: lines with `##$` comment prefix
# Targets: printed if their line includes a `##` comment
.PHONY: help
help:
@echo 'Usage: make <OPTIONS> ... <TARGETS>'
@echo ''
Expand All @@ -49,24 +48,46 @@ help:
##@ Development
###############

.PHONY: build
build: $(BIN) ## (default) Build binary for current OS

$(BIN): $(CODE)
env CGO_ENABLED=0 go build -ldflags $(LDFLAGS) ./cmd/$(BIN)

.PHONY: test
test: $(CODE) ## Run core unit tests
go test -race -cover -coverprofile=coverage.txt ./...

.PHONY: check
check: bin/golangci-lint ## Check code quality (lint)
./bin/golangci-lint run --timeout 300s
cd test && ../bin/golangci-lint run --timeout 300s

bin/golangci-lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./bin v1.53.2

.PHONY: clean_templates
.PHONY: clean
clean: ## Remove generated artifacts such as binaries and schemas
rm -f $(BIN) $(BIN_WINDOWS) $(BIN_LINUX) $(BIN_DARWIN_AMD64) $(BIN_DARWIN_ARM64)
rm -f templates/certs/ca-certificates.crt
rm -f schema/func_yaml-schema.json
rm -f coverage.txt

.PHONY: docs
docs:
# Generating command reference doc
go run docs/generator/main.go

#############
##@ Templates
#############

.PHONY: templates
templates: generate/zz_filesystem_generated.go ## Build the embedded templates

clean_templates:
# the filesysetm file itself is defined as being fresh if all the files in
# templates are fresh as well as the certificates file.
generate/zz_filesystem_generated.go: $(TEMPLATES) templates/certs/ca-certificates.crt
# Removing temporary template files
@rm -f templates/go/cloudevents/go.sum
@rm -f templates/go/http/go.sum
Expand All @@ -86,121 +107,132 @@ clean_templates:
@rm -rf templates/springboot/http/target
@rm -f templates/**/.DS_Store

.PHONY: generate/zz_filesystem_generated.go

generate/zz_filesystem_generated.go: clean_templates
# Generating the embedded file
go generate pkg/functions/templates_embedded.go

.PHONY: clean

clean: clean_templates ## Remove generated artifacts such as binaries and schemas
rm -f $(BIN) $(BIN_WINDOWS) $(BIN_LINUX) $(BIN_DARWIN_AMD64) $(BIN_DARWIN_ARM64)
rm -f schema/func_yaml-schema.json
rm -f coverage.txt

docs:
# Generating command reference doc
go run docs/generator/main.go

#############
##@ Templates
#############

# TODO: add linters for other templates
check-templates: check-rust

check-rust: ## Lint Rust templates
cd templates/rust/cloudevents && cargo clippy && cargo clean
cd templates/rust/http && cargo clippy && cargo clean

.PHONY: test-templates
test-templates: test-go test-node test-python test-quarkus test-springboot test-rust test-typescript ## Run all template tests

.PHONY: test-go
test-go: ## Test Go templates
cd templates/go/cloudevents && go mod tidy && go test
cd templates/go/http && go mod tidy && go test

.PHONY: test-node
test-node: ## Test Node templates
cd templates/node/cloudevents && npm ci && npm test && rm -rf node_modules
cd templates/node/http && npm ci && npm test && rm -rf node_modules

.PHONY: test-python
test-python: ## Test Python templates
cd templates/python/cloudevents && pip3 install -r requirements.txt && python3 test_func.py && rm -rf __pycache__
cd templates/python/http && python3 test_func.py && rm -rf __pycache__

.PHONY: test-quarkus
test-quarkus: ## Test Quarkus templates
cd templates/quarkus/cloudevents && mvn test && mvn clean
cd templates/quarkus/http && mvn test && mvn clean

.PHONY: test-springboot
test-springboot: ## Test Spring Boot templates
cd templates/springboot/cloudevents && mvn test && mvn clean
cd templates/springboot/http && mvn test && mvn clean

.PHONY: test-rust
test-rust: ## Test Rust templates
cd templates/rust/cloudevents && cargo test && cargo clean
cd templates/rust/http && cargo test && cargo clean

.PHONY: test-typescript
test-typescript: ## Test Typescript templates
cd templates/typescript/cloudevents && npm ci && npm test && rm -rf node_modules build
cd templates/typescript/http && npm ci && npm test && rm -rf node_modules build

###############
##@ Scaffolding
###############

.PHONY: certs
certs: templates/certs/ca-certificates.crt ## Ensure the certs exist

templates/certs/ca-certificates.crt:
curl --output templates/certs/ca-certificates.crt https://curl.se/ca/cacert.pem

###################
##@ Extended Testing (cluster required)
###################

.PHONY: test-integration
test-integration: ## Run integration tests using an available cluster.
go test -tags integration -timeout 30m --coverprofile=coverage.txt ./... -v

.PHONY: func-instrumented

func-instrumented: ## Func binary that is instrumented for e2e tests
env CGO_ENABLED=1 go build -ldflags $(LDFLAGS) -cover -o func ./cmd/func

.PHONY: test-e2e
test-e2e: func-instrumented ## Run end-to-end tests using an available cluster.
./test/e2e_extended_tests.sh

.PHONY: test-e2e-runtime
test-e2e-runtime: func-instrumented ## Run end-to-end lifecycle tests using an available cluster for a single runtime.
./test/e2e_lifecycle_tests.sh $(runtime)

.PHONY: test-e2e-on-cluster
test-e2e-on-cluster: func-instrumented ## Run end-to-end on-cluster build tests using an available cluster.
./test/e2e_oncluster_tests.sh

######################
##@ Release Artifacts
######################

.PHONY: cross-platform
cross-platform: darwin-arm64 darwin-amd64 linux-amd64 linux-arm64 linux-ppc64le linux-s390x windows ## Build all distributable (cross-platform) binaries

.PHONY: darwin-arm64
darwin-arm64: $(BIN_DARWIN_ARM64) ## Build for mac M1

$(BIN_DARWIN_ARM64): generate/zz_filesystem_generated.go
env CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o $(BIN_DARWIN_ARM64) -ldflags $(LDFLAGS) ./cmd/$(BIN)

.PHONY: darwin-amd64
darwin-amd64: $(BIN_DARWIN_AMD64) ## Build for Darwin (macOS)

$(BIN_DARWIN_AMD64): generate/zz_filesystem_generated.go
env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o $(BIN_DARWIN_AMD64) -ldflags $(LDFLAGS) ./cmd/$(BIN)

.PHONY: linux-amd64
linux-amd64: $(BIN_LINUX_AMD64) ## Build for Linux amd64

$(BIN_LINUX_AMD64): generate/zz_filesystem_generated.go
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $(BIN_LINUX_AMD64) -ldflags $(LDFLAGS) ./cmd/$(BIN)

.PHONY: linux-arm64
linux-arm64: $(BIN_LINUX_ARM64) ## Build for Linux arm64

$(BIN_LINUX_ARM64): generate/zz_filesystem_generated.go
env CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o $(BIN_LINUX_ARM64) -ldflags $(LDFLAGS) ./cmd/$(BIN)

.PHONY: linux-ppc64le
linux-ppc64le: $(BIN_LINUX_PPC64LE) ## Build for Linux ppc64le

$(BIN_LINUX_PPC64LE): generate/zz_filesystem_generated.go
env CGO_ENABLED=0 GOOS=linux GOARCH=ppc64le go build -o $(BIN_LINUX_PPC64LE) -ldflags $(LDFLAGS) ./cmd/$(BIN)

.PHONY: linux-s390x
linux-s390x: $(BIN_LINUX_S390X) ## Build for Linux s390x

$(BIN_LINUX_S390X): generate/zz_filesystem_generated.go
env CGO_ENABLED=0 GOOS=linux GOARCH=s390x go build -o $(BIN_LINUX_S390X) -ldflags $(LDFLAGS) ./cmd/$(BIN)

.PHONY: windows
windows: $(BIN_WINDOWS) ## Build for Windows

$(BIN_WINDOWS): generate/zz_filesystem_generated.go
Expand All @@ -209,10 +241,13 @@ $(BIN_WINDOWS): generate/zz_filesystem_generated.go
######################
##@ Schemas
######################

.PHONY: schema-generate
schema-generate: schema/func_yaml-schema.json ## Generate func.yaml schema
schema/func_yaml-schema.json: pkg/functions/function.go pkg/functions/function_*.go
go run schema/generator/main.go

.PHONY: schema-check
schema-check: ## Check that func.yaml schema is up-to-date
mv schema/func_yaml-schema.json schema/func_yaml-schema-previous.json
make schema-generate
Expand Down
Loading

0 comments on commit 247d1c4

Please sign in to comment.