Skip to content

Commit

Permalink
feat: end to end testing (#16)
Browse files Browse the repository at this point in the history
* feat: end to end testing
  • Loading branch information
clement2026 authored Sep 6, 2024
1 parent 034c5a3 commit 4bd1962
Show file tree
Hide file tree
Showing 15 changed files with 408 additions and 63 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: Build binary

on:
push:
branches: [ "main" ]
paths:
- '**'
- '!README.md'
pull_request:
branches: [ "main" ]
paths:
- '**'
- '!README.md'
# push:
# branches: [ "main" ]
# paths:
# - '**'
# - '!README.md'
# pull_request:
# branches: [ "main" ]
# paths:
# - '**'
# - '!README.md'
workflow_dispatch:

jobs:
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ permissions:
contents: write

jobs:
testing:
uses: ./.github/workflows/test-unit-and-e2e.yml

release:
needs: [ testing ]
name: Release
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -43,8 +47,8 @@ jobs:
- name: Build binary
run: make release

- name: ls build
run: ls build
- name: ls ./build
run: ls ./build

- name: Upload the artifacts
uses: skx/[email protected]
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/test-go.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
name: Test go

on:
push:
branches: [ "main" ]
paths:
- '**'
- '!ts/**'
- '!README.md'
pull_request:
branches: [ "main" ]
paths:
- '**'
- '!ts/**'
- '!README.md'
# push:
# branches: [ "main" ]
# paths:
# - '**'
# - '!ts/**'
# - '!README.md'
# pull_request:
# branches: [ "main" ]
# paths:
# - '**'
# - '!ts/**'
# - '!README.md'
workflow_dispatch:

jobs:
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/test-ts.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
name: Test TS

on:
push:
branches: [ "main" ]
paths:
- ts/**
- proto/**
- .github/**
pull_request:
branches: [ "main" ]
paths:
- ts/**
- proto/**
- .github/**
# push:
# branches: [ "main" ]
# paths:
# - ts/**
# - proto/**
# - .github/**
# pull_request:
# branches: [ "main" ]
# paths:
# - ts/**
# - proto/**
# - .github/**
workflow_dispatch:

jobs:
Expand Down
71 changes: 71 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Unit testing and E2E testing

on:
push:
branches: [ "main" ]
paths:
- '**'
- '!README.md'
pull_request:
branches: [ "main" ]
paths:
- '**'
- '!README.md'
workflow_dispatch:

jobs:
testing:
name: Unit testing and E2E testing
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 9
run_install: false

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'pnpm'
cache-dependency-path: 'ts/package.json'

- name: Install ts dependencies
run: cd ts && pnpm install

- uses: actions/setup-go@v5
with:
go-version: '^1.23'
cache-dependency-path: "go.sum"

- name: Install Protoc
uses: arduino/setup-protoc@v3

- name: Unit testing
run: make protoc && make test

- name: Build binary
run: make build

- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: live-pprof
path: build/live-pprof
compression-level: 9
retention-days: 10

- name: E2E testing with binary
run: make test-e2e

- name: Build binary for release
run: make clean && make release

- name: E2E testing with binary for release
run: make test-e2e


8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ define print_step
endef
.PHONY: build

all: protoc test build
all: protoc build
$(call print_step, Done)

release: protoc test build-for-release
release: protoc build-for-release
$(call print_step, Done)

protoc:
Expand All @@ -24,6 +24,10 @@ test:
$(MAKE) -f go.mk test
$(MAKE) -C ts test

test-e2e:
$(call print_step, Testing e2e)
$(MAKE) -f go.mk test-e2e

build:
$(call print_step, Building)
$(MAKE) -C ts build
Expand Down
5 changes: 4 additions & 1 deletion go.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ protoc:
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
protoc --go_out=./api --go_opt=paths=source_relative --go-grpc_out=./api --go-grpc_opt=paths=source_relative --proto_path ./proto ./proto/api.proto


build:
@echo "Building go"
go build -ldflags="-s -w" -tags prod -o build/${BINARY_NAME} ${ENTRY}
Expand All @@ -40,6 +39,10 @@ test:
@echo "Testing go"
go test ./...

test-e2e:
@echo "Testing go"
go test ./... -tags e2e -timeout 30s

clean:
@echo "Cleaning go"
go clean; rm -rf build; rm -rf assets/web/html
24 changes: 21 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ go 1.23.0
require (
github.com/brpaz/echozap v1.1.3
github.com/go-chi/chi/v5 v5.1.0
github.com/go-cmd/cmd v1.4.3
github.com/improbable-eng/grpc-web v0.15.0
github.com/labstack/echo/v4 v4.12.0
github.com/labstack/gommon v0.4.2
github.com/moderato-app/pprof v0.0.0-20240823224210-78ccd2f4d170
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
github.com/psanford/memfs v0.0.0-20230130182539-4dbf7e3e865e
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.9.0
go.uber.org/zap v1.27.0
Expand All @@ -20,26 +22,42 @@ require (
)

require (
github.com/Eun/go-convert v1.2.12 // indirect
github.com/Eun/go-doppelgangerreader v0.0.0-20220728163552-459d94705224 // indirect
github.com/Eun/go-hit v0.5.23 // indirect
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de // indirect
github.com/cenkalti/backoff/v4 v4.1.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/gookit/color v1.5.4 // indirect
github.com/ianlancetaylor/demangle v0.0.0-20240805132620-81f5be970eca // indirect
github.com/itchyny/gojq v0.12.16 // indirect
github.com/itchyny/timefmt-go v0.1.6 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/k0kubun/pp v3.0.1+incompatible // indirect
github.com/klauspost/compress v1.11.7 // indirect
github.com/lunixbochs/vtclean v1.0.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/psanford/memfs v0.0.0-20230130182539-4dbf7e3e865e // indirect
github.com/rs/cors v1.7.0 // indirect
github.com/samber/lo v1.47.0 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
go.uber.org/multierr v1.10.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
google.golang.org/genproto v0.0.0-20210126160654-44e461bb6506 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
nhooyr.io/websocket v1.8.6 // indirect
Expand Down
Loading

0 comments on commit 4bd1962

Please sign in to comment.