Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .air.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
root = ""
testdata_dir = "testdata"
tmp_dir = "tmp"

[build]
args_bin = []
bin = "./main frontend"
cmd = "go build ./cmd/hotrod/main.go"
delay = 1000
exclude_dir = ["assets", "tmp", "vendor", "testdata", "services/frontend/web_assets/"]
exclude_file = []
exclude_regex = ["_test.go"]
exclude_unchanged = false
follow_symlink = false
full_bin = ""
include_dir = ["services/frontend"]
include_ext = ["go", "tpl", "tmpl", "html", "tsx", "ts"]
include_file = []
kill_delay = "0s"
log = "build-errors.log"
poll = false
poll_interval = 0
post_cmd = []
pre_cmd = ["make build-frontend-app"]
rerun = true
rerun_delay = 500
send_interrupt = false
stop_on_error = true

[color]
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"

[log]
main_only = false
time = false

[misc]
clean_on_exit = false

[screen]
clear_on_rebuild = true
keep_scroll = true
35 changes: 1 addition & 34 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
pull_request:
branches: [ main ]
env:
GO_VERSION: "1.21"
GO_VERSION: "1.22"

jobs:

Expand Down Expand Up @@ -197,15 +197,6 @@ jobs:
cat /tmp/signadot-proxy.log
kill ${PROXY_PID}

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
check_name: Route Test Results
files: |
*report.xml


sandbox-frontend:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && needs.changes.outputs.frontend == 'true' }}
Expand Down Expand Up @@ -305,14 +296,6 @@ jobs:
cat /tmp/signadot-proxy.log
kill ${PROXY_PID}

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
check_name: Frontend Test Results
files: |
*report.xml


sandbox-location:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -418,14 +401,6 @@ jobs:
cat /tmp/signadot-proxy.log
kill ${PROXY_PID}

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
check_name: Location Test Results
files: |
*report.xml


sandbox-driver:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -525,11 +500,3 @@ jobs:
echo "Stopping signadot proxy..."
cat /tmp/signadot-proxy.log
kill ${PROXY_PID}

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
check_name: Driver Test Results
files: |
*report.xml
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ dist/
node_modules/
hotrod
.idea/
.nocover
.nocover
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
33 changes: 33 additions & 0 deletions .signadot/testing/demo-playwright-job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
spec:
namePrefix: hotrod-playwright-e2e
runnerGroup: playwright
script: |
#!/bin/bash
set -e

# Clone the git repo
echo "Cloning signadot repo"
git clone --single-branch -b "@{branch}" \
https://github.com/signadot/hotrod.git

# Run all playwright tests
cd hotrod

export HOTROD_NAMESPACE="@{namespace}"
export CI=true

npm ci
set +e
npm run e2e:playwright --spec playwright-tests/basic.spec.ts
E2E_EXIT_CODE=$?
set -e

tar czf playwright-report.tar.gz playwright-report

exit $E2E_EXIT_CODE
routingContext:
sandbox: "@{sandbox}"
uploadArtifact:
- path: hotrod/playwright-report/index.html
- path: hotrod/playwright-report.tar.gz

11 changes: 11 additions & 0 deletions .signadot/testing/playwright-runner.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: playwright
spec:
cluster: "@{cluster}"
labels:
env: "@{env}"
namespace: signadot-tests
jobTimeout: 30m
image: mcr.microsoft.com/playwright:v1.45.1-jammy
scaling:
manual:
desiredPods: 1
11 changes: 11 additions & 0 deletions .signadot/testing/postman-runner.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: postman
spec:
cluster: "@{cluster}"
labels:
env: "@{env}"
namespace: signadot-tests
image: node:latest
jobTimeout: 30m
scaling:
manual:
desiredPods: 1
26 changes: 26 additions & 0 deletions .signadot/testing/postman-test-job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
spec:
namePrefix: hotrod-integration-api
runnerGroup: postman
script: |
#!/bin/bash
set -e

npm install -g newman
# Clone the git repo
echo "Cloning signadot repo"
git clone --single-branch -b "@{branch}" \
https://github.com/signadot/hotrod.git

# Run all postman tests
cd hotrod

newman run postman/hotrod.postman_collection.json \
-r cli,json \
-d postman/data.json \
--env-var namespace=@{namespace}

tar czf postman-report.tar.gz newman

uploadArtifact:
- path: hotrod/postman-report.tar.gz

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21-alpine
FROM golang:1.22-alpine

ARG TARGETPLATFORM

Expand Down
43 changes: 42 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ been modified considerably to showcase Signadot & Sandboxes.

## Running

First, [install Signadot Operator](https://docs.signadot.com/docs/installation)
First, [install Signadot Operator](https://www.signadot.com/docs/installation/signadot-operator)
if you haven't already.

### Run everything in Kubernetes
Expand All @@ -24,3 +24,44 @@ To uninstall:
```bash
kubectl delete ns "${NAMESPACE}"
```


## Development

### Frontend

To run frontend you could easily run with `air` that helps with hot-reload.

Before running `air` or manual steps you have to set up the following env
```shell
export KAFKA_BROKER=kafka-headless.${NAMESPACE}.svc:9092
export REDIS_ADDR=redis.${NAMESPACE}.svc:6379
export FRONTEND_LOCATION_ADDR=location.${NAMESPACE}.svc:8081
```

Now let's run the frontend
```shell
air
```

That will listen for the changes and restart the server every change.

If no want to use this approach, you could
```shell
make build-frontend-app
go run ./cmd/hotrod/main.go frontend
```


## Deployment

### Release

To build and push new images, we can leverage by using the `make release`.

For the case of releasing latest images we can do `RELEASE_TAG=latest make release`.
Note that you can replace the `RELEASE_TAG` with the value you need.

### Considerations

You have to make sure you have the rights to write in signadot/hotrod.
2 changes: 2 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ module.exports = defineConfig({
e2e: {
video: true,
experimentalStudio: true,
viewportWidth: 1024,
viewportHeight: 780,
env: {
HOTROD_NAMESPACE: 'hotrod',
SIGNADOT_ROUTING_KEY: '',
Expand Down
35 changes: 0 additions & 35 deletions cypress/e2e/hotrod-e2e.cy.js

This file was deleted.

7 changes: 4 additions & 3 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// Request a HotRod ride
Cypress.Commands.add('requestRide', (from, to) => {
var frontendURL = 'http://frontend.' + Cypress.env('HOTROD_NAMESPACE') + ':8080';
var frontendURL = 'http://frontend.' + Cypress.env('HOTROD_NAMESPACE') + ':8080/';
// inject routing key
cy.intercept(frontendURL + '/*', (req) => {
cy.intercept('**', (req) => {
req.headers['baggage'] += ',sd-routing-key=' + Cypress.env('SIGNADOT_ROUTING_KEY');
})

cy.visit(frontendURL);
cy.get(':nth-child(1) > .chakra-select__wrapper > .chakra-select').select(from);
cy.get(':nth-child(3) > .chakra-select__wrapper > .chakra-select').select(to);
cy.get('.chakra-button').click();
cy.contains('button', 'Request Ride').click();
cy.contains('button', 'Show Logs').click();
})
7 changes: 6 additions & 1 deletion cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
// require('./commands')

Cypress.on('uncaught:exception', (err, runnable) => {
// returning false here prevents Cypress from failing the test
return false
})
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/signadot/hotrod

go 1.21.4
go 1.22

require (
github.com/IBM/sarama v1.42.1
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ github.com/redis/go-redis/v9 v9.4.0/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/signadot/routesapi/go-routesapi v0.0.0-20240110192923-d8598a020267 h1:qP5ozxT0AMVxWrGZt7kyj8U7K/hl5tnIZuAW3vwpcVM=
github.com/signadot/routesapi/go-routesapi v0.0.0-20240110192923-d8598a020267/go.mod h1:Noxoutt2PEwMSPbQdWnPQdQUBc2oPSNbtSuLg9jG0r4=
github.com/signadot/routesapi/go-routesapi v0.0.0-20240202080216-ff62bea925c3 h1:Z9Hsn+dNBEq7kA7xqtHPXEil+yAvGoN0x1iYk69QpM4=
github.com/signadot/routesapi/go-routesapi v0.0.0-20240202080216-ff62bea925c3/go.mod h1:Noxoutt2PEwMSPbQdWnPQdQUBc2oPSNbtSuLg9jG0r4=
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
Expand Down
10 changes: 10 additions & 0 deletions k8s/overlays/dev-minikube/linkerd/driver-image-pull-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: driver
spec:
template:
spec:
containers:
- name: hotrod
imagePullPolicy: Never
10 changes: 10 additions & 0 deletions k8s/overlays/dev-minikube/linkerd/frontend-image-pull-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: frontend
spec:
template:
spec:
containers:
- name: hotrod
imagePullPolicy: Never
10 changes: 10 additions & 0 deletions k8s/overlays/dev-minikube/linkerd/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

resources:
- ../../prod/linkerd
- ../../../base/jaeger

patches:
- path: frontend-image-pull-config.yaml
- path: driver-image-pull-config.yaml
- path: route-image-pull-config.yaml
- path: location-image-pull-config.yaml
Loading
Loading