Skip to content
This repository was archived by the owner on Jul 19, 2023. It is now read-only.

Commit 9b4b1a7

Browse files
eh-amsimonswine
andauthored
feat: run under a subpath (#663)
Adds a `-api.base-url` flag to support running the UI under a different baseUrl. Closes #638 --------- Co-authored-by: Christian Simon <simon@swine.de>
1 parent 3163440 commit 9b4b1a7

File tree

34 files changed

+1521
-47
lines changed

34 files changed

+1521
-47
lines changed

.github/workflows/e2e.yaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: e2e
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
8+
concurrency:
9+
# Cancel any running workflow for the same branch when new commits are pushed.
10+
# We group both by ref_name (available when CI is triggered by a push to a branch/tag)
11+
# and head_ref (available when CI is triggered by a PR).
12+
group: "e2e-${{ github.ref_name }}-${{ github.head_ref }}"
13+
cancel-in-progress: true
14+
15+
jobs:
16+
regular-path:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v3
21+
- uses: actions/setup-node@v3
22+
with:
23+
node-version: 18.15.0
24+
cache: yarn
25+
- name: Install Go
26+
uses: actions/setup-go@v4
27+
with:
28+
go-version: "1.19.9"
29+
cache: true
30+
- run: yarn --frozen-lockfile
31+
- run: make build
32+
- name: Cypress run
33+
uses: cypress-io/github-action@v5
34+
with:
35+
wait-on: http://localhost:4100/ui/
36+
start: make run
37+
config-file: cypress/ci.ts
38+
env:
39+
ELECTRON_ENABLE_LOGGING: 1
40+
- uses: actions/upload-artifact@v2
41+
if: always()
42+
with:
43+
name: regular-path-cypress-screenshots
44+
path: cypress/screenshots
45+
46+
base-path:
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Checkout code
50+
uses: actions/checkout@v3
51+
- uses: actions/setup-node@v3
52+
with:
53+
node-version: 18.15.0
54+
cache: yarn
55+
- name: Install Go
56+
uses: actions/setup-go@v4
57+
with:
58+
go-version: "1.19.9"
59+
cache: true
60+
- run: yarn --frozen-lockfile
61+
- run: make build
62+
- name: run nginx with /foobar/
63+
run: docker-compose -f scripts/base-url/docker-compose.yaml up -d
64+
- name: Cypress run
65+
uses: cypress-io/github-action@v5
66+
with:
67+
wait-on: http://localhost:8080/foobar/
68+
start: |
69+
make run PARAMS=-api.base-url=/foobar/
70+
config-file: cypress/ci-base-path.ts
71+
env:
72+
ELECTRON_ENABLE_LOGGING: 1
73+
- uses: actions/upload-artifact@v2
74+
if: always()
75+
with:
76+
name: base-path-cypress-screenshots
77+
path: cypress/screenshots

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ public/build
3535

3636
# Contains the docker image id for phlare
3737
/.docker-image-id-phlare
38+
39+
cypress/screenshots

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,3 +371,7 @@ deploy-demo: $(BIN)/kind
371371
.PHONY: docs/%
372372
docs/%:
373373
$(MAKE) -C docs $*
374+
375+
.PHONY: run
376+
run: ## Run the phlare binary (pass parameters with 'make run PARAMS=-myparam')
377+
./phlare $(PARAMS)

cmd/phlare/help-all.txt.tmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
Usage of ./phlare:
2+
-api.base-url string
3+
base URL for when the server is behind a reverse proxy with a different path
24
-auth.multitenancy-enabled
35
When set to true, incoming HTTP requests must specify tenant ID in HTTP X-Scope-OrgId header. When set to false, tenant ID anonymous is used instead.
46
-client.tenant-id string

cmd/phlare/help.txt.tmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
Usage of ./phlare:
2+
-api.base-url string
3+
base URL for when the server is behind a reverse proxy with a different path
24
-auth.multitenancy-enabled
35
When set to true, incoming HTTP requests must specify tenant ID in HTTP X-Scope-OrgId header. When set to false, tenant ID anonymous is used instead.
46
-client.tenant-id string

cypress.config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { defineConfig } from 'cypress';
2+
3+
export default defineConfig({
4+
e2e: {
5+
baseUrl: 'http://localhost:4040',
6+
video: false,
7+
},
8+
});

cypress/ci-base-path.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { defineConfig } from 'cypress';
2+
3+
export default defineConfig({
4+
e2e: {
5+
baseUrl: 'http://localhost:8080/foobar/ui/',
6+
env: {
7+
apiBasePath: '/foobar',
8+
},
9+
video: false,
10+
},
11+
});

cypress/ci.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { defineConfig } from 'cypress';
2+
3+
export default defineConfig({
4+
e2e: {
5+
baseUrl: 'http://localhost:4100/ui/',
6+
video: false,
7+
},
8+
});

cypress/e2e/smoke.cy.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// / <reference types="cypress" />
2+
describe('smoke', () => {
3+
beforeEach(function () {
4+
const apiBasePath = Cypress.env('apiBasePath') || '';
5+
6+
cy.intercept(`${apiBasePath}/pyroscope/label-values?label=__name__`, {
7+
fixture: 'profileTypes.json',
8+
}).as('profileTypes');
9+
});
10+
11+
it('loads admin page', () => {
12+
cy.visit('../');
13+
});
14+
15+
it('loads single view (/)', () => {
16+
cy.visit('/');
17+
cy.wait(`@profileTypes`);
18+
});
19+
20+
it('loads comparison view (/comparison)', () => {
21+
cy.visit('/comparison');
22+
cy.wait(`@profileTypes`);
23+
});
24+
25+
it('loads diff view (/comparison-diff)', () => {
26+
cy.visit('/comparison-diff');
27+
cy.wait(`@profileTypes`);
28+
});
29+
});

cypress/fixtures/profileTypes.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
["memory:alloc_objects:count::","memory:alloc_space:bytes::","memory:inuse_objects:count::","memory:inuse_space:bytes::","process_cpu:cpu:nanoseconds:cpu:nanoseconds"]
2+

0 commit comments

Comments
 (0)