Skip to content

Commit 51e9524

Browse files
committed
chore: Merge branch 'staging' into auto/A19S32-merge-master-into-staging
2 parents 79ef034 + 71b6baa commit 51e9524

25 files changed

Lines changed: 379 additions & 149 deletions

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
Dockerfile text eol=lf
3+
*.Dockerfile text eol=lf
4+
*.sh eol=lf

.github/workflows/master_com-keyman-status.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,27 @@ jobs:
2121
with:
2222
node-version: '24.x'
2323

24-
- name: npm install, build, and test
24+
- name: npm ci + build - public
2525
run: |
26-
npm install
27-
npm run build --if-present
28-
npm run test --if-present
26+
echo "- Building public for release"
27+
cd public
28+
npm ci
29+
./node_modules/.bin/ng build --configuration production
30+
cd ..
31+
32+
- name: npm ci + build - server
33+
run: |
34+
echo "- Building server for release"
35+
cd server
36+
npm ci
37+
./node_modules/.bin/tsc
38+
cd ..
39+
40+
- name: server test
41+
run: |
42+
cd server
43+
npx mocha --import=./_mocha_register.js
44+
cd ..
2945
3046
- name: 'Deploy to Azure Web App'
3147
uses: azure/webapps-deploy@v2

.github/workflows/test.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,4 @@ jobs:
2929

3030
- name: npm install, build, and test
3131
run: |
32-
npm install
33-
npm run build
34-
npm run test
32+
./build.sh configure build test --release

.gitignore

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
localenv.sh
22
node_modules/
33
.keymanapp-test-bot.*
4-
local*.sh
4+
local*.sh
5+
6+
# Shared files are bootstrapped:
7+
resources/bootstrap.inc.sh*
8+
resources/.bootstrap-version
9+
resources/.bootstrap-registry
10+
_common/
11+
12+
# State files
13+
_control/debug
14+
_control/release
15+
_control/ready

README.md

Lines changed: 80 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
1-
# Quick Start
1+
# status.keyman.com
22

3-
Clone the repo:
3+
## Overview
44

5-
```bash
6-
git clone https://github.com/keymanapp/status.keyman.com
7-
cd status.keyman.com/
8-
```
5+
* Back end is a node server in `/server`.
6+
* Front end is an Angular app in `/public`.
7+
* The [Keyman Test-bot](https://github.com/keymanapp/keyman/wiki/User-Testing-Workflows)
8+
(@keymanapp-test-bot) is in `/server/keymanapp-test-bot`.
99

10-
Build status.keyman.com:
10+
The site is setup to run in Docker container(s).
1111

12-
```bash
13-
cd server
14-
npm install
15-
npm run-script build
16-
cd ../public
17-
npm install
18-
npm run-script build
19-
cd ..
20-
```
12+
The site can be setup in development (`--debug`) or production (`--release`)
13+
modes. When in development mode, the front end is hosted (on
14+
http://localhost:8061) in a separate container to the back end (on
15+
http://localhost:8060) in order to facilitate live-reload on changes.
16+
17+
For production mode, the front end is compiled to static pages which are then
18+
served by the back end (on http://localhost:8060).
19+
20+
## Prerequisites
21+
22+
* Docker Desktop
23+
* On Windows, you'll need to have Git Bash installed in `C:\Program Files\git\bin\bash.exe`.
2124

22-
Before running the node server, you need to have two API tokens set as environment variables. You might want to add these to script `server/localenv.sh`.
25+
Before building and starting the site, you need to have API tokens set as
26+
environment variables. These should be added in script `server/localenv.sh`.
2327

2428
```bash
2529
export KEYMANSTATUS_TEAMCITY_TOKEN=[your personal auth token here]
@@ -28,35 +32,54 @@ export KEYMANSTATUS_SENTRY_TOKEN=[your personal auth token here]
2832
# export KEYMANSTATUS_GITHUB_WEBHOOK_SECRET=[github webhook secret here] # optional unless testing the github webhook
2933
```
3034

31-
On Windows, you'll also need to have Git Bash installed in `C:\Program Files\git\bin\bash.exe`.
35+
### @keymanapp-test-bot
36+
37+
Three files are needed for development:
38+
39+
* `.keymanapp-test-bot.appid`: integer appid (e.g. 134443 for the normal test app)
40+
* `.keymanapp-test-bot.pem`: certificate for GitHub integration for app
41+
* `.keymanapp-test-bot.secret`: secret for GitHub integration for app
42+
43+
## Development setup
44+
45+
Clone the repo:
46+
47+
```bash
48+
git clone https://github.com/keymanapp/status.keyman.com
49+
cd status.keyman.com/
50+
```
3251

33-
## Development server
52+
### Build the docker containers
3453

35-
This repo is configured for live build and reload of both the client and server. You'll need two terminals open. In the first, run:
54+
Build status.keyman.com, in development mode:
3655

3756
```bash
38-
npm run start-server
57+
./build.sh stop build --debug
3958
```
4059

41-
and in the second, run:
60+
### Start the development server
61+
62+
This repo is configured for live build and reload of both the client and server,
63+
running in Docker.
4264

4365
```bash
44-
npm run start-client
66+
./build.sh start --debug
4567
```
4668

47-
* Point your browser to <http://localhost:4200> to view the live reload version of the application.
48-
* The query parameter `?c=1` adds a contributions view which is not visible by default.
49-
* Another query parameter `?sprint=P8S4` parameter to view sprint contributions data for P8S4
69+
* Point your browser to <http://localhost:8061> to view the live reload version
70+
of the application.
71+
* The site takes a moment to compile and load; you can watch the logs to see
72+
when it is ready.
5073

51-
### @keymanapp-test-bot
74+
### Running unit tests
5275

53-
Three files needed for development:
76+
The unit tests will currently stop the back end container before running.
5477

55-
* `.keymanapp-test-bot.appid`: integer appid (e.g. 134443 for the normal test app)
56-
* `.keymanapp-test-bot.pem`: certificate for GitHub integration for app
57-
* `.keymanapp-test-bot.secret`: secret for GitHub integration for app
78+
```bash
79+
./build.sh test --debug
80+
```
5881

59-
### Webhooks
82+
## Webhooks
6083

6184
* GitHub: 2 webhooks are configured to the same endpoint /webhook/github to POST
6285
events from keymanapp organization. These are split to make log review
@@ -71,3 +94,28 @@ Three files needed for development:
7194
* Sentry: /webhook/sentry - when new errors are logged
7295

7396
* GitHub Testbot app: /webhook/keymanapp-test-bot
97+
98+
## Production setup
99+
100+
This site is deployed to a Kubernetes cluster via configuration in a private
101+
repo to status.keyman.com.
102+
103+
You can run the production mode site locally with:
104+
105+
```bash
106+
./build.sh stop build start --release
107+
```
108+
109+
* Point your browser to <http://localhost:8060> to view the production version
110+
of the application.
111+
112+
## Site query parameters
113+
114+
* The following query parameters are available:
115+
* `?c=1` shows contributions at the top center
116+
* `?o=1` shows owner for each platform
117+
* `?a=1` shows build agent status at the top right
118+
* `?r=1` adds a refresh button to force a server-side full refresh (this is
119+
costly, so only press this when there has been a data error such as a
120+
network failure making status data out of date; most errors are
121+
actually self-healing)

_control/.keep

Whitespace-only changes.

build.sh

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#!/usr/bin/env bash
2+
## START STANDARD SITE BUILD SCRIPT INCLUDE
3+
readonly THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
4+
readonly BOOTSTRAP="$(dirname "$THIS_SCRIPT")/resources/bootstrap.inc.sh"
5+
readonly BOOTSTRAP_VERSION=v1.0.10
6+
if ! [ -f "$BOOTSTRAP" ] || ! source "$BOOTSTRAP"; then
7+
curl -H "Cache-Control: no-cache" --fail --silent --show-error -w "curl: Finished attempt to download %{url}" "https://raw.githubusercontent.com/keymanapp/shared-sites/$BOOTSTRAP_VERSION/bootstrap.inc.sh" -o "$BOOTSTRAP.tmp" || exit 1
8+
source "$BOOTSTRAP.tmp"
9+
rm -f "$BOOTSTRAP.tmp"
10+
fi
11+
## END STANDARD SITE BUILD SCRIPT INCLUDE
12+
13+
source _common/keyman-local-ports.inc.sh
14+
source _common/docker.inc.sh
15+
16+
readonly HOST_STATUS_KEYMAN_COM=status.keyman.com.localhost
17+
18+
readonly THIS_CONTAINER_NAME=status-keyman-website
19+
readonly PUBLIC_CONTAINER_NAME=status-keyman-public
20+
readonly THIS_CONTAINER_DESC=status-keyman-com-app
21+
readonly PUBLIC_CONTAINER_DESC=status-keyman-com-public
22+
readonly THIS_IMAGE_NAME=status-keyman-website
23+
readonly PUBLIC_IMAGE_NAME=status-keyman-public
24+
readonly THIS_HOST="$HOST_STATUS_KEYMAN_COM"
25+
readonly PUBLIC_HOST="$HOST_STATUS_KEYMAN_COM" # same host
26+
readonly THIS_PORT="$PORT_STATUS_KEYMAN_COM"
27+
readonly PUBLIC_PORT="$PORT_STATUS_KEYMAN_COM_PUBLIC"
28+
29+
30+
################################ Main script ################################
31+
32+
builder_describe \
33+
"Setup status.keyman.com site to run via Docker." \
34+
configure \
35+
clean \
36+
build \
37+
start \
38+
stop \
39+
test
40+
41+
builder_parse "$@"
42+
43+
function build_docker_containers() {
44+
NEWVERSION="$(git rev-parse HEAD)"
45+
echo "Writing version '$NEWVERSION' to version.ts"
46+
echo "export const buildVersion = '$NEWVERSION';" > shared/version.ts
47+
48+
build_docker_container $THIS_IMAGE_NAME $THIS_CONTAINER_NAME $BUILDER_CONFIGURATION server.Dockerfile
49+
if builder_is_debug_build; then
50+
build_docker_container $PUBLIC_IMAGE_NAME $PUBLIC_CONTAINER_NAME $BUILDER_CONFIGURATION public.Dockerfile
51+
fi
52+
53+
git checkout shared/version.ts
54+
}
55+
56+
function start_docker_containers() {
57+
start_docker_container $THIS_IMAGE_NAME $THIS_CONTAINER_NAME $THIS_CONTAINER_DESC $THIS_HOST $THIS_PORT $BUILDER_CONFIGURATION
58+
if builder_is_debug_build; then
59+
start_docker_container $PUBLIC_IMAGE_NAME $PUBLIC_CONTAINER_NAME $PUBLIC_CONTAINER_DESC $PUBLIC_HOST $PUBLIC_PORT $BUILDER_CONFIGURATION
60+
fi
61+
}
62+
63+
function stop_docker_containers() {
64+
rm -f ./_control/ready
65+
stop_docker_container $THIS_IMAGE_NAME $THIS_CONTAINER_NAME
66+
# always stop all containers - even in release build
67+
stop_docker_container $PUBLIC_IMAGE_NAME $PUBLIC_CONTAINER_NAME
68+
}
69+
70+
function clean_docker_containers() {
71+
clean_docker_container $THIS_IMAGE_NAME $THIS_CONTAINER_NAME
72+
# always clean all containers - even in release build
73+
clean_docker_container $PUBLIC_IMAGE_NAME $PUBLIC_CONTAINER_NAME
74+
}
75+
76+
function do_clean() {
77+
clean_docker_containers
78+
rm -rf ./server/node_modules ./server/dist
79+
rm -rf ./public/node_modules ./public/angular ./public/dist
80+
rm -rf ./public/angular
81+
rm -rf ./_common
82+
rm -rf ./resources/.bootstrap-registry ./resources/bootstrap-version ./resources/bootstrap.inc.sh
83+
}
84+
85+
function test_docker_container() {
86+
stop_docker_container $THIS_IMAGE_NAME $THIS_CONTAINER_NAME
87+
MSYS_NO_PATHCONV=1 start_docker_container $THIS_IMAGE_NAME $THIS_CONTAINER_NAME $THIS_CONTAINER_DESC $THIS_HOST $THIS_PORT $BUILDER_CONFIGURATION "/bin/sh" "./resources/test.sh"
88+
}
89+
90+
builder_run_action configure bootstrap_configure
91+
builder_run_action clean do_clean
92+
builder_run_action stop stop_docker_containers
93+
builder_run_action build build_docker_containers
94+
builder_run_action start start_docker_containers
95+
builder_run_action test test_docker_container

package-lock.json

Lines changed: 1 addition & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,7 @@
22
"name": "keyman-status",
33
"version": "1.0.0",
44
"description": "Report on status of Keyman projects",
5-
"main": "server/dist/server/code.js",
65
"type": "module",
7-
"scripts": {
8-
"prebuild": "run-script-os",
9-
"prebuild:windows": "tools\\_prebuild.bat",
10-
"prebuild:default": "./tools/_prebuild.sh",
11-
"postbuild": "git checkout shared/version.ts",
12-
"build": "npm ci && npm run-script prebuild && npm run-script build-server && npm run-script build-client && npm run-script postbuild",
13-
"build-client": "cd public && npm ci && npm run-script build",
14-
"build-server": "cd server && npm ci && npm run-script build",
15-
"start-client": "cd public && npm run-script start",
16-
"start-server": "cd server && npm run-script start",
17-
"test": "cd server && npx mocha --import=./_mocha_register.js",
18-
"log": "az webapp log tail --resource-group keyman --name com-keyman-status"
19-
},
206
"author": "Marc Durdin",
21-
"license": "MIT",
22-
"devDependencies": {
23-
"run-script-os": "^1.1.6"
24-
}
7+
"license": "MIT"
258
}

public.Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# syntax=docker/dockerfile:1
2+
3+
FROM node:22@sha256:cd6fb7efa6490f039f3471a189214d5f548c11df1ff9e5b181aa49e22c14383e AS node-builder
4+
5+
WORKDIR /var/www/html
6+
7+
ARG BUILDER_CONFIGURATION="debug"
8+
ENV BUILDER_CONFIGURATION=$BUILDER_CONFIGURATION
9+
10+
# DOCKER_RUNTIME_PUBLIC env var helps prevent the resource scripts running on the host
11+
ENV DOCKER_RUNTIME_PUBLIC=1
12+
13+
CMD [ "/bin/sh", "./resources/start-public.sh" ]

0 commit comments

Comments
 (0)