Skip to content

Commit 9d9af79

Browse files
committed
chore: Merge branch 'staging' into auto/A19S28-merge-master-into-staging
2 parents 6ad0a61 + 98b743f commit 9d9af79

26 files changed

Lines changed: 387 additions & 156 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: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,29 @@ jobs:
1919
- name: Set up Node.js version
2020
uses: actions/setup-node@v1
2121
with:
22-
node-version: '20.x'
22+
node-version: '22.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: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ jobs:
2525
- name: Set up Node.js version
2626
uses: actions/setup-node@v1
2727
with:
28-
node-version: '20.x'
28+
node-version: '22.x'
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: 76 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,45 @@
1-
# Quick Start
1+
# status.keyman.com
2+
3+
## Overview
4+
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`.
9+
10+
The site is setup to run in Docker container(s).
11+
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`.
24+
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`.
27+
28+
```bash
29+
export KEYMANSTATUS_TEAMCITY_TOKEN=[your personal auth token here]
30+
export KEYMANSTATUS_GITHUB_TOKEN=[your personal auth token here]
31+
export KEYMANSTATUS_SENTRY_TOKEN=[your personal auth token here]
32+
```
33+
34+
### @keymanapp-test-bot
35+
36+
Three files are needed for development:
37+
38+
* `.keymanapp-test-bot.appid`: integer appid (e.g. 134443 for the normal test app)
39+
* `.keymanapp-test-bot.pem`: certificate for GitHub integration for app
40+
* `.keymanapp-test-bot.secret`: secret for GitHub integration for app
41+
42+
## Development setup
243

344
Clone the repo:
445

@@ -7,50 +48,57 @@ git clone https://github.com/keymanapp/status.keyman.com
748
cd status.keyman.com/
849
```
950

10-
Build status.keyman.com:
51+
### Build the docker containers
52+
53+
Build status.keyman.com, in development mode:
1154

1255
```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 ..
56+
./build.sh stop build --debug
2057
```
2158

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`.
59+
### Start the development server
60+
61+
This repo is configured for live build and reload of both the client and server,
62+
running in Docker.
2363

2464
```bash
25-
export KEYMANSTATUS_TEAMCITY_TOKEN=[your personal auth token here]
26-
export KEYMANSTATUS_GITHUB_TOKEN=[your personal auth token here]
27-
export KEYMANSTATUS_SENTRY_TOKEN=[your personal auth token here]
65+
./build.sh start --debug
2866
```
2967

30-
On Windows, you'll also need to have Git Bash installed in `C:\Program Files\git\bin\bash.exe`.
68+
* Point your browser to <http://localhost:8061> to view the live reload version
69+
of the application.
70+
* The site takes a moment to compile and load; you can watch the logs to see
71+
when it is ready.
3172

32-
## Development server
73+
### Running unit tests
3374

34-
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:
75+
The unit tests will currently stop the back end container before running.
3576

3677
```bash
37-
npm run start-server
78+
./build.sh test --debug
3879
```
3980

40-
and in the second, run:
81+
## Production setup
82+
83+
This site is deployed to a Kubernetes cluster via configuration in a private
84+
repo to status.keyman.com.
85+
86+
You can run the production mode site locally with:
4187

4288
```bash
43-
npm run start-client
89+
./build.sh stop build start --release
4490
```
4591

46-
* Point your browser to <http://localhost:4200> to view the live reload version of the application.
47-
* The query parameter `?c=1` adds a contributions view which is not visible by default.
48-
* Another query parameter `?sprint=P8S4` parameter to view sprint contributions data for P8S4
49-
50-
### @keymanapp-test-bot
92+
* Point your browser to <http://localhost:8060> to view the production version
93+
of the application.
5194

52-
Three files needed for development:
95+
## Site query parameters
5396

54-
* `.keymanapp-test-bot.appid`: integer appid (e.g. 134443 for the normal test app)
55-
* `.keymanapp-test-bot.pem`: certificate for GitHub integration for app
56-
* `.keymanapp-test-bot.secret`: secret for GitHub integration for app
97+
* The following query parameters are available:
98+
* `?c=1` shows contributions at the top center
99+
* `?o=1` shows owner for each platform
100+
* `?a=1` shows build agent status at the top right
101+
* `?r=1` adds a refresh button to force a server-side full refresh (this is
102+
costly, so only press this when there has been a data error such as a
103+
network failure making status data out of date; most errors are
104+
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)