Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@
"name": "Launch Karma (Chrome)",
"type": "chrome",
"request": "launch",
"url": "http://localhost:9876",
"url": "http://127.0.0.1:9876",
"webRoot": "${workspaceFolder}/web",
"preLaunchTask": "Start Karma",
"sourceMaps": true,
"sourceMapPathOverrides": {
"http://localhost:9876/base/*": "${webRoot}/*"
"http://127.0.0.1:9876/base/*": "${webRoot}/*"
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": ".*server started at http://localhost:9876.*"
"regexp": ".*server started at http://(localhost|127\\.0\\.0\\.1):[0-9]+.*"
},
"endsPattern": {
"regexp": ".*Executed .* FAILURE.*|.*Executed .* SUCCESS.*"
Expand Down
15 changes: 12 additions & 3 deletions scripts/make/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@
# This file contains make tasks for building.


WEB_HOST ?= localhost
WEB_PORT ?= 4200
WEB_ALLOWED_HOSTS_FLAG ?= $(if $(filter 0.0.0.0,$(WEB_HOST)),--allowed-hosts,)
Comment thread
kyasbal marked this conversation as resolved.
STORYBOOK_HOST ?= localhost
STORYBOOK_PORT ?= 6006
KARMA_PORT ?= 9876
BACKEND_PORT ?= $(or $(PORT),8080)
BACKEND_HOST ?= $(if $(filter 0.0.0.0,$(HOST)),127.0.0.1,$(or $(HOST),127.0.0.1))

.PHONY: watch-web
watch-web: $(GENERATE_FRONTEND_DUMMY) ## Run frontend development server
cd web && npx ng serve -c dev
cd web && BACKEND_PORT=$(BACKEND_PORT) BACKEND_HOST=$(BACKEND_HOST) npx ng serve -c dev --host $(WEB_HOST) --port $(WEB_PORT) $(WEB_ALLOWED_HOSTS_FLAG)

$(FRONTEND_ARTIFACT_FILES_DUMMY): $(GENERATE_FRONTEND_DUMMY) $(FRONTEND_SOURCE_FILES) $(FRONTEND_GENERATED_SRCS)## Build frontend for production
cd web && npx ng build --output-path ../pkg/server/dist -c prod
Expand All @@ -15,15 +24,15 @@ build-web: $(FRONTEND_ARTIFACT_FILES_DUMMY) ## Build frontend for production

.PHONY: watch-storybook
watch-storybook: $(GENERATE_FRONTEND_DUMMY) ## Run storybook development server
cd web && npm run storybook
cd web && npm run storybook -- --host $(STORYBOOK_HOST) --port $(STORYBOOK_PORT)

.PHONY: build-storybook
build-storybook: $(GENERATE_FRONTEND_DUMMY) ## Build storybook
cd web && npm run build-storybook

.PHONY: watch-karma
watch-karma: $(GENERATE_FRONTEND_DUMMY) ## Run karma test server
cd web && npm run test
cd web && KARMA_PORT=$(KARMA_PORT) npm run test

khi: $(GENERATE_BACKEND_DUMMY) $(FRONTEND_ARTIFACT_FILES_DUMMY) $(BACKEND_SRCS)
CGO_ENABLED=0 go build -ldflags="-s -w -X github.com/GoogleCloudPlatform/khi/pkg/common/constants.VERSION=$(shell cat ./VERSION)" -o ./khi ./cmd/kubernetes-history-inspector/...
Expand Down
8 changes: 5 additions & 3 deletions scripts/make/testing.mk
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
# testing.mk
# This file contains make tasks related to testing.

KARMA_PORT ?= 9876

.PHONY: test-web
test-web: $(GENERATE_FRONTEND_DUMMY) $(FRONTEND_SOURCE_FILES)## Run frontend tests
cd web && npx ng test --browsers ChromeHeadlessNoSandbox --watch=false
cd web && KARMA_PORT=$(KARMA_PORT) npx ng test --browsers ChromeHeadlessNoSandbox --watch=false

.PHONY: watch-test-web
watch-test-web: $(GENERATE_FRONTEND_DUMMY) ## Run frontend tests in watch mode
cd web && npx ng test
cd web && KARMA_PORT=$(KARMA_PORT) npx ng test

.PHONY: test-go
test-go: $(GENERATE_BACKEND_DUMMY) $(BACKEND_TEST_SRCS) $(FRONTEND_ARTIFACT_FILES_DUMMY) ## Run backend tests
go test ./...

.PHONY: coverage-web
coverage-web: $(GENERATE_FRONTEND_DUMMY) $(FRONTEND_SOURCE_FILES)## Run frontend tests and generate coverage report
cd web && npx ng test --code-coverage --browsers ChromeHeadlessNoSandbox --watch false --progress false
cd web && KARMA_PORT=$(KARMA_PORT) npx ng test --code-coverage --browsers ChromeHeadlessNoSandbox --watch false --progress false

.PHONY: coverage-go
coverage-go: $(GENERATE_BACKEND_DUMMY) $(BACKEND_TEST_SRCS) $(FRONTEND_ARTIFACT_FILES_DUMMY)## Run backend tests and generate coverage report
Expand Down
7 changes: 5 additions & 2 deletions web/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ module.exports = function (config) {
]
},
reporters: ['progress', 'kjhtml'],
port: 9876,
port: parseInt(process.env.KARMA_PORT, 10) || 9876,
hostname: '127.0.0.1',
listenAddress: '127.0.0.1',
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
Expand All @@ -71,7 +73,8 @@ module.exports = function (config) {
'--no-sandbox',
'--enable-unsafe-swiftshader',
'--enable-webgl',
'--disable-gpu'
'--disable-gpu',
'--remote-debugging-port=0'
]
}
},
Expand Down
8 changes: 6 additions & 2 deletions web/proxy.conf.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@
* Angular Proxy Configuration
*
* This file defines the proxy configuration for the Angular development server.
* During development, requests to the /api/ path are forwarded to localhost:8080.
* During development, requests to the /api/ path are forwarded to the backend server.
*/

const backendPort = process.env.BACKEND_PORT || process.env.PORT || "8080";
const rawHost = process.env.BACKEND_HOST || process.env.HOST || "127.0.0.1";
const backendHost = rawHost === "0.0.0.0" ? "127.0.0.1" : rawHost;

export default {
"/api": {
target: "http://127.0.0.1:8080",
target: `http://${backendHost}:${backendPort}`,
secure: false,
changeOrigin: true,
logLevel: "debug",
Expand Down
Loading