-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Charly Molter <[email protected]>
- Loading branch information
Showing
24 changed files
with
1,750 additions
and
1,214 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
on: # yamllint disable-line rule:truthy | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
- next | ||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: go.mod | ||
- run: curl https://mise.run | sh | ||
- run: make check | ||
- run: make build | ||
- run: make test |
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
node_modules | ||
.idea | ||
bin/ | ||
dist/ |
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,3 @@ | ||
--- | ||
issues: | ||
exclude-rules: |
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,48 @@ | ||
--- | ||
# This is an example .goreleaser.yml file with some sensible defaults. | ||
# Make sure to check the documentation at https://goreleaser.com | ||
|
||
# The lines below are called `modelines`. See `:help modeline` | ||
# Feel free to remove those if you don't want/need to use them. | ||
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json | ||
# vim: set ts=2 sw=2 tw=0 fo=cnqoj | ||
|
||
version: 2 | ||
|
||
before: | ||
hooks: | ||
- make generate | ||
- make check | ||
|
||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
main: ./app | ||
id: kuma-counter-demo | ||
goos: | ||
- linux | ||
- darwin | ||
|
||
archives: | ||
- format: tar.gz | ||
# this name template makes the OS and Arch compatible with the results of `uname`. | ||
name_template: >- | ||
{{ .ProjectName }}_ | ||
{{- title .Os }}_ | ||
{{- if eq .Arch "amd64" }}x86_64 | ||
{{- else if eq .Arch "386" }}i386 | ||
{{- else }}{{ .Arch }}{{ end }} | ||
{{- if .Arm }}v{{ .Arm }}{{ end }} | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- '^docs:' | ||
- '^test:' | ||
|
||
dockers: | ||
- id: demo-app | ||
image_templates: | ||
- kumahq/kuma-counter-demo | ||
dockerfile: ./app/Dockerfile |
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,5 @@ | ||
[env] | ||
MISE_DATA_DIR='bin/' | ||
|
||
[settings] | ||
experimental = true # To enable installation of Go tools from source with mise. |
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,7 @@ | ||
--- | ||
# renovate: datasource=github-releases depName=golangci/golangci-lint | ||
golangci-lint: 1.61.0 | ||
# removate: datasource=github-releases depName=github.com/goreleaser/goreleaser/v2 | ||
goreleaser: 2.3.2 | ||
# removate: datasource=github-releases denName=com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen | ||
oapi-codegen: 2.4.1 |
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 |
---|---|---|
@@ -1,16 +1,8 @@ | ||
ARG ARCH=amd64 | ||
FROM --platform=linux/${ARCH} node:alpine | ||
FROM golang:1.19 | ||
|
||
RUN apk add dumb-init | ||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build ./... -o /kuma-counter-demo | ||
|
||
COPY /app/package.json /app/package.json | ||
RUN npm install --prefix /app | ||
FROM --platform=linux/${ARCH} distroless | ||
|
||
COPY /app/public /app/public | ||
COPY /app/server.js /app/server.js | ||
|
||
EXPOSE 5000 | ||
|
||
WORKDIR "/app" | ||
ENTRYPOINT ["dumb-init", "--"] | ||
CMD ["node", "./server.js"] | ||
CMD ["/kuma-counter-demo"] |
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,11 @@ | ||
# Errors | ||
|
||
The list of error details that can be returned by our app. | ||
|
||
## REDIS-FAILURE | ||
|
||
Redis failed in some way | ||
|
||
## DEMOAPP-FAILURE | ||
|
||
Demo-app failed |
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,71 @@ | ||
# Some sensible Make defaults: https://tech.davis-hansson.com/p/make/ | ||
SHELL := bash | ||
.SHELLFLAGS := -eu -o pipefail -c | ||
|
||
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) | ||
TOOLS_VERSIONS_FILE = $(PROJECT_DIR)/.tools_versions.yaml | ||
|
||
export MISE_DATA_DIR = $(PROJECT_DIR)/bin/ | ||
MISE := $(shell which mise) | ||
.PHONY: mise | ||
mise: | ||
@mise -V >/dev/null || (echo "mise - https://github.com/jdx/mise - not found. Please install it." && exit 1) | ||
|
||
GOLANGCI_LINT_VERSION = $(shell yq -ojson -r '.golangci-lint' < $(TOOLS_VERSIONS_FILE)) | ||
GOLANGCI_LINT = $(PROJECT_DIR)/bin/installs/golangci-lint/$(GOLANGCI_LINT_VERSION)/bin/golangci-lint | ||
.PHONY: golangci-lint.download | ||
golangci-lint.download: | mise ## Download golangci-lint locally if necessary. | ||
$(MISE) install -y -q golangci-lint@$(GOLANGCI_LINT_VERSION) | ||
|
||
GORELEASER_VERSION = $(shell yq -ojson -r '.goreleaser' < $(TOOLS_VERSIONS_FILE)) | ||
GORELEASER = $(PROJECT_DIR)/bin/installs/goreleaser/$(GORELEASER_VERSION)/bin/goreleaser | ||
.PHONY: goreleaser.download | ||
goreleaser.download: | mise ## Download goreleaser locally if necessary. | ||
$(MISE) install -y -q goreleaser@$(GORELEASER_VERSION) | ||
|
||
OAPI_CODEGEN_VERSION = $(shell yq -ojson -r '.oapi-codegen' < $(TOOLS_VERSIONS_FILE)) | ||
OAPI_CODEGEN = $(PROJECT_DIR)/bin/installs/oapi-codegen/$(OAPI_CODEGEN_VERSION)/bin/oapi-codegen | ||
.PHONY: oapi-codegen.download | ||
oapi-codegen.download: | mise ## Download oapi-codegen locally if necessary. | ||
$(MISE) install -y -q oapi-codegen@$(OAPI_CODEGEN_VERSION) | ||
|
||
app/internal/api/gen.go: openapi.yaml | oapi-codegen.download | ||
$(OAPI_CODEGEN) --config openapi-config.yaml $< | ||
|
||
.PHONY: clean | ||
clean: | ||
@rm -rf app/internal/api/gen.go | ||
@rm -rf dist/ | ||
@rm -rf bin/ | ||
|
||
.PHONY: all | ||
all: check build test run | ||
|
||
.PHONY: check | ||
check: tidy fmt lint | ||
|
||
.PHONY: fmt | ||
fmt: | ||
go fmt ./... | ||
|
||
.PHONY: lint | ||
lint: tidy golangci-lint | ||
|
||
.PHONY: tidy | ||
tidy: | ||
go mod tidy | ||
|
||
.PHONY: golangci-lint | ||
golangci-lint: | golangci-lint.download | ||
$(GOLANGCI_LINT) run --verbose --config $(PWD)/.golangci.yaml $(GOLANGCI_LINT_FLAGS) | ||
|
||
build: | goreleaser.download | ||
$(GORELEASER) release --snapshot --clean | ||
|
||
.PHONY: generate | ||
generate: app/internal/api/gen.go | ||
go generate ./... | ||
|
||
.PHONY: test | ||
test: | ||
go test $$(go list ./... | grep -v 'e2e') |
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,4 @@ | ||
FROM scratch | ||
|
||
ENTRYPOINT ["/kuma-counter-demo"] | ||
ADD kuma-counter-demo / |
Oops, something went wrong.