Merge branch 'daniellacosse/issue-1003' into daniellacosse/issue-1003-reqcheck

This commit is contained in:
Daniel LaCosse 2021-11-02 15:28:20 +00:00 committed by GitHub
commit 359295d2e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 66 additions and 69 deletions

View file

@ -39,7 +39,7 @@ jobs:
- name: Release Linux
if: runner.os == 'Linux'
run: npm run do server_manager/electron_app/release_linux
run: npm run action server_manager/electron_app/release_linux
- name: Release MacOS
if: runner.os == 'macOS'
@ -51,7 +51,7 @@ jobs:
run: |
openssl aes-256-cbc -K $ENCRYPTED_SIGNING_CERT_KEY -iv $ENCRYPTED_SIGNING_CERT_IV -in macos-signing-certificate.p12.enc -out macos-signing-certificate.p12 -d -md sha256
export CSC_LINK=$(pwd)/macos-signing-certificate.p12
npm run do server_manager/electron_app/release_macos
npm run action server_manager/electron_app/release_macos
- name: Deploy
uses: softprops/action-gh-release@v1

View file

@ -34,26 +34,23 @@ jobs:
run: NODE_DTRACE_PROVIDER_REQUIRE=hard npm ci
- name: Lint
run: yarn lint
run: npm run lint
- name: Manager
run: |
SENTRY_DSN='test' npm run do server_manager/electron_app/release_linux
npm run do server_manager/test
npm run action server_manager/test
- name: Shadowbox
if: runner.os == 'Linux'
run: |
npm run do shadowbox/server/build
npm run do shadowbox/test
npm run do shadowbox/integration_test/run
npm run action shadowbox/server/build
npm run action shadowbox/test
npm run action shadowbox/integration_test/run
- name: Metrics Server
if: runner.os == 'Linux'
run: |
npm run do metrics_server/build
npm run do metrics_server/test
npm run action metrics_server/build
npm run action metrics_server/test
- name: Sentry Webhook
if: runner.os == 'Linux'
run: npm run do sentry_webhook/build

View file

@ -47,15 +47,15 @@ jobs:
curl -L https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m) > docker-compose
chmod +x docker-compose
sudo mv docker-compose /usr/local/bin
- npm run do shadowbox/test
- npm run do shadowbox/docker/build && cd src/shadowbox/integration_test && ./test.sh
- npm run action shadowbox/test
- npm run action shadowbox/docker/build && cd src/shadowbox/integration_test && ./test.sh
- stage: "Deploy Server"
name: Server Docker Image
sudo: required
services: docker
script:
- npm run do shadowbox/docker/build
- npm run action shadowbox/docker/build
- docker login quay.io -u="$QUAY_IO_USERNAME" -p="$QUAY_IO_PASSWORD"
- docker tag outline/shadowbox quay.io/outline/shadowbox:$TRAVIS_TAG
- docker push quay.io/outline/shadowbox:$TRAVIS_TAG
@ -70,7 +70,7 @@ jobs:
apt:
packages:
- rpm
script: npm run do server_manager/electron_app/release_linux
script: npm run action server_manager/electron_app/release_linux
- stage: "Manager Release"
os: osx
@ -81,7 +81,7 @@ jobs:
- openssl aes-256-cbc -K $encrypted_61a49da75942_key -iv $encrypted_61a49da75942_iv -in macos-signing-certificate.p12.enc -out macos-signing-certificate.p12 -d
- export CSC_LINK=$(pwd)/macos-signing-certificate.p12
# Must run npm again due to the OS change, required for signing to work.
- npm install && npm run do server_manager/electron_app/release_macos
- npm install && npm run action server_manager/electron_app/release_macos
deploy:
provider: releases

View file

@ -54,20 +54,20 @@ and a thin wrapper for what we call build "actions".
We've defined a `do` package.json script that takes an `action` parameter:
```shell
npm run do $ACTION
npm run action $ACTION
```
This command will define a `do_action()` function and call `${ACTION}_action.sh`, which must exist.
The called action script can use `do_action` to call its dependencies. The $ACTION parameter is
This command will define a `run_action()` function and call `${ACTION}_action.sh`, which must exist.
The called action script can use `run_action` to call its dependencies. The $ACTION parameter is
always resolved from the project root, regardless of the caller location.
The idea of `do_action` is to keep the build logic next to where the relevant code is.
The idea of `run_action` is to keep the build logic next to where the relevant code is.
It also defines two environmental variables:
- ROOT_DIR: the root directory of the project, as an absolute path.
- BUILD_DIR: where the build output should go, as an absolute path.
> ⚠️ To find all the actions in this project, run `npm run actions`
> ⚠️ To find all the actions in this project, run `npm run action:list`
### Build output

View file

@ -17,9 +17,9 @@
"npm": ">=8.1.0"
},
"scripts": {
"actions": "find . -name '*_action.sh' | sed -E 's:./src/(.*)_action.sh:\\1:' | grep -v 'scripts/do_action'",
"action": "bash ./scripts/run_action.sh",
"action:list": "find . -name '*.action.sh' | sed -E 's:./src/(.*).action.sh:\\1:' | grep -v 'scripts/run_action'",
"clean": "rm -rf src/*/node_modules/ build/ node_modules/ src/server_manager/install_scripts/do_install_script.ts src/server_manager/install_scripts/gcp_install_script.ts third_party/shellcheck/download/",
"do": "bash ./scripts/do_action.sh",
"lint": "npm run lint:sh && npm run lint:ts",
"lint:sh": "bash ./scripts/shellcheck.sh",
"lint:ts": "npx tslint 'src/**/*.ts' -e '**/node_modules/**'"

View file

@ -24,7 +24,7 @@ export ROOT_DIR=${ROOT_DIR:-$(pwd)/$(git rev-parse --show-cdup)}
export BUILD_DIR=${BUILD_DIR:-${ROOT_DIR}/build}
export _DO_ACTION_INDENT=''
function do_action() {
function run_action() {
local -r OLD_INDENT="${_DO_ACTION_INDENT}"
_DO_ACTION_INDENT="..${_DO_ACTION_INDENT}"
local -r STYLE_BOLD_WHITE='\033[1;37m'
@ -33,7 +33,7 @@ function do_action() {
local -r action="$1"
echo -e "${OLD_INDENT}${STYLE_BOLD_WHITE}[Running ${action}]${STYLE_RESET}"
shift
"${ROOT_DIR}/src/${action}_action.sh" "$@"
"${ROOT_DIR}/src/${action}.action.sh" "$@"
local -ir status=$?
if ((status == 0)); then
echo -e "${OLD_INDENT}${STYLE_BOLD_WHITE}[Done ${action}]${STYLE_RESET}"
@ -43,6 +43,6 @@ function do_action() {
_DO_ACTION_INDENT=${OLD_INDENT}
return "${status}"
}
export -f do_action
export -f run_action
do_action "$@"
run_action "$@"

View file

@ -47,7 +47,7 @@ The metrics server supports two URL paths:
## Build
```sh
npm run do metrics_server/build
npm run action metrics_server/build
```
## Run
@ -55,7 +55,7 @@ npm run do metrics_server/build
Run a local development metrics server:
```sh
npm run do metrics_server/run
npm run action metrics_server/start
```
## Deploy
@ -66,20 +66,20 @@ npm run do metrics_server/run
```
* To deploy to dev:
```sh
npm run do metrics_server/deploy_dev
npm run action metrics_server/deploy_dev
```
* To deploy to prod:
```sh
npm run do metrics_server/deploy_prod
npm run action metrics_server/deploy_prod
```
## Test
* Unit test
```sh
npm run do metrics_server/test
npm run action metrics_server/test
```
* Integration test
```sh
npm run do metrics_server/test_integration
npm run action metrics_server/test_integration
```

View file

@ -10,7 +10,7 @@ The Outline Sentry webhook is a [Google Cloud Function](https://cloud.google.com
## Build
```sh
npm run do sentry_webhook/build
npm run action sentry_webhook/build
```
## Deploy
@ -21,7 +21,7 @@ Authenticate with `gcloud`:
```
To deploy:
```sh
npm run do sentry_webhook/deploy
npm run action sentry_webhook/deploy
```
## Configure Sentry Webhooks

View file

@ -4,12 +4,12 @@
To run the Outline Manager Electron app:
```
npm run do server_manager/electron_app/run
npm run action server_manager/electron_app/start
```
To run the Outline Manager Electron app with a development build (code not minified):
```
BUILD_ENV=development npm run do server_manager/electron_app/run
BUILD_ENV=development npm run action server_manager/electron_app/start
```
## Development Server
@ -17,7 +17,7 @@ BUILD_ENV=development npm run do server_manager/electron_app/run
To run the Outline Manager as a web app on the browser and listen for changes:
```
npm run do server_manager/web_app/run
npm run action server_manager/web_app/start
```
## Gallery Server for UI Development
@ -25,7 +25,7 @@ npm run do server_manager/web_app/run
We have a server app to for quickly iterating on UI components. To spin it up, run
```
npm run do server_manager/web_app/run_gallery
npm run action server_manager/web_app/start_gallery
```
Changes to UI components will be hot reloaded into the gallery.
@ -39,7 +39,7 @@ This will enable the Developer menu on the application window.
To build the app binary:
```
npm run do server_manager/electron_app/package_${PLATFORM}
npm run action server_manager/electron_app/package_${PLATFORM}
```
Where `${PLATFORM}` is one of `linux`, `macos`, `only_windows`.
@ -54,7 +54,7 @@ The per-platform standalone apps will be at `build/electron_app/static/dist`.
To perform a release, use
```
npm run do server_manager/electron_app/release
npm run action server_manager/electron_app/release
```
This will perform a clean and reinstall all dependencies to make sure the build is not tainted.
@ -64,7 +64,7 @@ This will perform a clean and reinstall all dependencies to make sure the build
To enable error reporting through [Sentry](https://sentry.io/) for local builds, run:
``` bash
export SENTRY_DSN=[Sentry development API key]
npm run do server_manager/electron_app/run
npm run action server_manager/electron_app/start
```
Release builds on CI are configured with a production Sentry API key.

View file

@ -20,7 +20,7 @@ readonly OUT_DIR="${BUILD_DIR}/server_manager/electron_app"
rm -rf "${OUT_DIR}"
# Build the Web App.
do_action server_manager/web_app/build
run_action server_manager/web_app/build
# Compile the Electron app source.
# Since Node.js on Cygwin doesn't like absolute Unix-style paths,

View file

@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
do_action server_manager/electron_app/build
run_action server_manager/electron_app/build
readonly NODE_MODULES_BIN_DIR="${ROOT_DIR}/src/server_manager/node_modules/.bin"

View file

@ -23,10 +23,10 @@
# script, allowing fill_packaging_opts.sh to fill variables for the caller.
# Input: "/absolute/path/src/server_manager/electron_app/something_action.sh"
# Output: "npm run do server_manager/electron_app/something"
# Output: "npm run action server_manager/electron_app/something"
readonly ELECTRON_PATH='server_manager/electron_app/'
readonly RELATIVE="${1#*/src/${ELECTRON_PATH}}"
readonly NPM_COMMAND="npm run do ${ELECTRON_PATH}${RELATIVE%_action.sh}"
readonly NPM_COMMAND="npm run action ${ELECTRON_PATH}${RELATIVE%_action.sh}"
shift
function usage () {

View file

@ -19,7 +19,7 @@ set -eu
readonly OUT_DIR="${BUILD_DIR}/server_manager/web_app"
rm -rf "${OUT_DIR}"
do_action server_manager/web_app/build_install_script
run_action server_manager/web_app/build_install_script
# Node.js on Cygwin doesn't like absolute Unix-style paths.
# So, we use a relative path as input to webpack.

View file

@ -18,6 +18,6 @@ set -eu
rm -rf "${BUILD_DIR}/server_manager/web_app"
do_action server_manager/web_app/build_install_script
run_action server_manager/web_app/build_install_script
webpack-dev-server --config=src/server_manager/browser.webpack.js --open

View file

@ -3,7 +3,7 @@
## Steps
* `cd` to the root of your clone of this repo
* Ensure `node_modules` is up to date and only include dependencies of the Electron app by running `npm ci && npm run do server_manager/web_app/build`
* Ensure `node_modules` is up to date and only include dependencies of the Electron app by running `npm ci && npm run action server_manager/web_app/build`
* `cd src/server_manager`
* `npx generate-license-file --input package.json --output web_app/ui_components/licenses/licenses.txt`
* `cd web_app/ui_components/licenses`

View file

@ -10,12 +10,12 @@ This package contains the following license and notice below:
To run the Outline Manager Electron app:
```
npm run do server_manager/electron_app/run
npm run action server_manager/electron_app/start
```
To run the Outline Manager Electron app with a development build (code not minified):
```
BUILD_ENV=development npm run do server_manager/electron_app/run
BUILD_ENV=development npm run action server_manager/electron_app/start
```
## Development Server
@ -23,7 +23,7 @@ BUILD_ENV=development npm run do server_manager/electron_app/run
To run the Outline Manager as a web app on the browser and listen for changes:
```
npm run do server_manager/web_app/run
npm run action server_manager/web_app/start
```
## Gallery Server for UI Development
@ -31,7 +31,7 @@ npm run do server_manager/web_app/run
We have a server app to for quickly iterating on UI components. To spin it up, run
```
npm run do server_manager/web_app/run_gallery
npm run action server_manager/web_app/start_gallery
```
Changes to UI components will be hot reloaded into the gallery.
@ -45,7 +45,7 @@ This will enable the Developer menu on the application window.
To build the app binary:
```
npm run do server_manager/electron_app/package_${PLATFORM}
npm run action server_manager/electron_app/package_${PLATFORM}
```
Where `${PLATFORM}` is one of `linux`, `macos`, `only_windows`.
@ -60,7 +60,7 @@ The per-platform standalone apps will be at `build/electron_app/static/dist`.
To perform a release, use
```
npm run do server_manager/electron_app/release
npm run action server_manager/electron_app/release
```
This will perform a clean and reinstall all dependencies to make sure the build is not tainted.
@ -70,7 +70,7 @@ This will perform a clean and reinstall all dependencies to make sure the build
To enable error reporting through [Sentry](https://sentry.io/) for local builds, run:
``` bash
export SENTRY_DSN=[Sentry development API key]
npm run do server_manager/electron_app/run
npm run action server_manager/electron_app/start
```
Release builds on CI are configured with a production Sentry API key.

View file

@ -36,7 +36,7 @@ Besides [Node](https://nodejs.org/en/download/) you will also need:
Build and run the server as a Node.js app:
```
npm run do shadowbox/server/run
npm run action shadowbox/server/start
```
The output will be at `build/shadowbox/app`.
@ -46,7 +46,7 @@ The output will be at `build/shadowbox/app`.
Build the image and run server:
```
npm run do shadowbox/docker/run
npm run action shadowbox/docker/start
```
You should be able to successfully query the management API:
@ -56,7 +56,7 @@ curl --insecure https://[::]:8081/TestApiPrefix/server
To build the image only:
```
npm run do shadowbox/docker/build
npm run action shadowbox/docker/build
```
Debug image:
@ -136,14 +136,14 @@ upload it to your favorite registry
Then set your `SB_IMAGE` environment variable to point to the image you just
uploaded (e.g. `export SB_IMAGE=yourdockerhubusername/shadowbox`) and
run `npm run do server_manager/electron_app/run` and your droplet should be created with your
run `npm run action server_manager/electron_app/start` and your droplet should be created with your
modified image.
### Automated
To run the integration test:
```
npm run do shadowbox/integration_test/run
npm run action shadowbox/integration_test/start
```
This will set up three containers and two networks:
@ -156,12 +156,12 @@ client <-> shadowbox <-> target
To test clients that rely on fetching a docker image from Dockerhub, you can push an image to your account and modify the
client to use your image. To push your own image:
```
npm run do shadowbox/docker/build && docker tag quay.io/outline/shadowbox $USER/shadowbox && docker push $USER/shadowbox
npm run action shadowbox/docker/build && docker tag quay.io/outline/shadowbox $USER/shadowbox && docker push $USER/shadowbox
```
If you need to test an unsigned image (e.g. your dev one):
```
DOCKER_CONTENT_TRUST=0 SB_IMAGE=$USER/shadowbox npm run do shadowbox/integration_test/run
DOCKER_CONTENT_TRUST=0 SB_IMAGE=$USER/shadowbox npm run action shadowbox/integration_test/start
```
You can add tags if you need different versions in different clients.
@ -175,4 +175,4 @@ start-up time, then you mey need to remove the pre-existing test config:
rm /tmp/outline/persisted-state/shadowbox_server_config.json
```
This will warn about deleting a write-protected file, which is okay to ignore. You will then need to hand-edit the JSON string in src/shadowbox/docker/run_action.sh.
This will warn about deleting a write-protected file, which is okay to ignore. You will then need to hand-edit the JSON string in src/shadowbox/docker/start_action.sh.

View file

@ -31,7 +31,7 @@ COPY scripts scripts/
COPY src src/
COPY tsconfig.json ./
COPY third_party third_party
RUN ROOT_DIR=/ npm run do shadowbox/server/build
RUN ROOT_DIR=/ npm run action shadowbox/server/build
# shadowbox image
FROM ${NODE_IMAGE}

View file

@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
do_action shadowbox/docker/build
run_action shadowbox/docker/build
RUN_ID="${RUN_ID:-$(date +%Y-%m-%d-%H%M%S)}"
readonly RUN_ID

View file

@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
do_action shadowbox/docker/build
run_action shadowbox/docker/build
LOGFILE="$(mktemp)"
readonly LOGFILE

View file

@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
do_action shadowbox/server/build
run_action shadowbox/server/build
RUN_ID="${RUN_ID:-$(date +%Y-%m-%d-%H%M%S)}"
readonly RUN_DIR="/tmp/outline/${RUN_ID}"