Skip to content

Commit

Permalink
Implement examples scripts
Browse files Browse the repository at this point in the history
* Add scripts to update and clean binaries
* Update readme to document scripts
* Update workflows to install beinary dependencies before running tests
  • Loading branch information
mattdean-digicatapult committed Sep 29, 2022
1 parent 9ebd7d3 commit cbefd92
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ jobs:
${{ runner.OS }}-
- name: Install Packages
run: npm ci
- name: Install morello-examples
run: npm run examples:update
- name: Build OpenAPI
run: npm run build:tsoa
- name: Setup dependencies
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ jobs:
${{ runner.OS }}-
- name: Install Packages
run: npm ci
- name: Install morello-examples
run: npm run examples:update
- name: Build OpenAPI
run: npm run build:tsoa
- name: Setup dependencies
Expand Down
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,30 @@ Alternatively create a `./config/local.json` file to override the values of `def

## Binaries

Binaries to be executed by the API are located in the [bin](./bin/) directory, however the API is primarily designed to be used as a docker image. [Dockerfile](./Dockerfile) replaces the contents of `bin` with the latest binaries from [`morello-examples`](https://github.com/digicatapult/morello-examples), a separately maintained list of examples designed to illustrate how certain common software defects can be protected against by running on a Cheri-enabled platform.
Binaries to be executed by the API should by default be located in the [bin](./bin/) directory. If using the Docker image built from this repository the latest binaries are included at image build time from the latest release of [https://github.com/digicatapult/morello-examples](https://github.com/digicatapult/morello-examples). When developing locally you can either download the latest binaries from that repository or there are a couple of helper npm scripts to help you manage them. To update to the latest release you can run:

Some simple binaries are included in this repository for local testing. Binaries can also be added manually to the `bin` directory. Each binary will need its filename added to the [`Executables`](./types/models/scenario.ts) type to appear as an option on the API route.
```sh
npm run examples:update
```

And to perform a purge of currently installed binaries do:

```sh
npm run examples:clean
```

## Getting started

```sh
# start dependencies
# start dependencies
docker compose up -d
# install packages
# install packages
npm i
# generate swagger and route files for Open API
# download latest binaries
npm run examples:update
# generate swagger and route files for Open API
npm run build
# start service in dev mode. In order to start in full - npm start"
# start service in dev mode. In order to start in full - npm start"
npm run dev
```

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"name": "@digicatapult/morello-api",
"version": "0.6.8",
"version": "0.6.9",
"description": "An interface for executing binaries on it's self and morello host.",
"main": "src/index.ts",
"scripts": {
"lint": "eslint .",
"build:tsoa": "tsoa spec-and-routes",
"build": "tsoa spec-and-routes && tsc",
"examples:update": "cd bin && wget https://github.com/digicatapult/morello-examples/releases/download/latest/morello-examples.tar.gz && tar -xvf morello-examples.tar.gz && rm morello-examples.tar.gz",
"examples:clean": "rm -rf bin/* bin/.version",
"start": "node build/index.js",
"depcheck": "depcheck",
"dev": "concurrently \"npx tsc --watch\" \"nodemon -q build/index.js | pino-colada\"",
Expand Down

0 comments on commit cbefd92

Please sign in to comment.