Skip to content

Commit

Permalink
Merge pull request #815 from hpi-sam/release/v0.3.0
Browse files Browse the repository at this point in the history
Release v0.3.0
  • Loading branch information
Nils1729 authored Mar 27, 2023
2 parents 1006e8b + 9fcfcab commit 3c5a1bc
Show file tree
Hide file tree
Showing 128 changed files with 3,313 additions and 302 deletions.
96 changes: 55 additions & 41 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,7 @@ concurrency:
jobs:
build:
timeout-minutes: 5
runs-on: ${{ matrix.os }}

strategy:
matrix:
# As the CI seems to have high run times, limit it to ubuntu-latest
# os: [ubuntu-latest, windows-latest, macos-latest]
os: [ubuntu-latest]
fail-fast: false
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
Expand All @@ -38,15 +31,10 @@ jobs:

lint:
timeout-minutes: 3
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest

needs: build

strategy:
matrix:
os: [ubuntu-latest]
fail-fast: false

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand All @@ -62,17 +50,12 @@ jobs:

dependencies:
timeout-minutes: 10
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest

needs: build

continue-on-error: true

strategy:
matrix:
os: [ubuntu-latest]
fail-fast: false

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand All @@ -95,7 +78,7 @@ jobs:

test:
timeout-minutes: 4
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest

needs: build

Expand All @@ -115,13 +98,6 @@ jobs:
--health-timeout 5s
--health-retries 5
strategy:
matrix:
# As the CI seems to have high run times, limit it to ubuntu-latest
# os: [ubuntu-latest, windows-latest, macos-latest]
os: [ubuntu-latest]
fail-fast: false

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand All @@ -139,7 +115,7 @@ jobs:
- name: Run migrations
run: cd backend && npm run migration:run && cd ..
- name: Run Backend Tests
run: cd backend && npm run test:ci; cd ..
run: cd backend && npm run test:ci-no-migration; cd ..
if: always()
- name: Run Frontend Tests
run: cd frontend && npm run test:ci; cd ..
Expand All @@ -157,6 +133,51 @@ jobs:
name: coverage-output
path: coverage

migration-test:
timeout-minutes: 4
runs-on: ubuntu-latest

needs: build

services:
postgres:
image: postgres:14
env:
POSTGRES_DB: ${{ secrets.POSTGRES_DB }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- name: Cache node modules and shared/dist
uses: ./.github/actions/cache-build
- name: Create .env
run: >
cat ./.env.example
| sed -e "s/^DFM_DB_USER=.*$/DFM_DB_USER=${{ secrets.POSTGRES_USER }}/"
| sed -e "s/^#DFM_DB_PASSWORD=.*$/DFM_DB_PASSWORD=${{ secrets.POSTGRES_PASSWORD }}/"
| sed -e "s/^DFM_DB_NAME=.*$/DFM_DB_NAME=${{ secrets.POSTGRES_DB }}/"
| sed -e "s/^DFM_DB_HOST=.*$/DFM_DB_HOST=127.0.0.1/" > ./.env
- name: Run migrations
run: cd backend && npm run migration:run && cd ..
- name: Fetch Test Scenarios
run: git submodule update --init --recursive
if: always()
- name: Run Migration Tests
run: cd backend && npm run test:ci-migration; cd ..
if: always()

cypress:
timeout-minutes: 20
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -233,14 +254,17 @@ jobs:

# Dummy step to gate until all test are complete
tests-done:
if: always()
needs:
- test
- cypress
- lint
- dependencies
- migration-test
runs-on: ubuntu-latest
steps:
- run: 'true'
- uses: matrix-org/done-action@v2
with:
needs: ${{ toJSON (needs) }}

deploy-dev:
timeout-minutes: 10
Expand All @@ -250,11 +274,6 @@ jobs:

if: github.ref == 'refs/heads/dev'

strategy:
matrix:
os: [ubuntu-latest]
fail-fast: false

steps:
- uses: actions/checkout@v3
# Source: https://docs.docker.com/ci-cd/github-actions/
Expand All @@ -279,11 +298,6 @@ jobs:

if: github.ref == 'refs/heads/main'

strategy:
matrix:
os: [ubuntu-latest]
fail-fast: false

steps:
- uses: actions/checkout@v3
- name: Extract version
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "test-scenarios"]
path = test-scenarios
url = https://github.com/hpi-sam/digital-fuesim-manv-public-test-scenarios.git
25 changes: 24 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,28 @@ and this project does **not** adhere to [Semantic Versioning](https://semver.org

## [Unreleased]

## [0.3.0] - 2023-03-27

### Added

- There are now radiograms, which can be used by the simulation to send messages to the trainees. These are generated automatically by an activity.
- There is a radiogram for displaying the material count in a simulated region.
- There is a radiogram for displaying the patient count in a simulated region.
- There is a radiogram for displaying the personnel count in a simulated region.
- There is a radiogram for displaying the vehicle count in a simulated region.
- There is a radiogram for displaying the current treatment status in a simulated region
- There is a behavior responsible for creating and managing the activities which create radiograms
- In the large simulation overview modal, a column has been added to interact with radiograms.
- It displays all radiograms, optionally filtered to those that are not done.
- Radiograms can be accepted and marked as done.
- Behaviors can clean up the state when they are removed from a simulated region.
- There are now tests, that ensure that migrations do not fail

### Fixed

- "Leitstelle" was misspelled in the title of the EOC modal
- Transfer points do not change their connection upon arrival of a vehicle

## [0.2.1] - 2023-03-11

### Changed
Expand Down Expand Up @@ -86,7 +108,8 @@ and this project does **not** adhere to [Semantic Versioning](https://semver.org

### Initial unstable release of Digitale FüSim MANV

[Unreleased]: https://github.com/hpi-sam/digital-fuesim-manv/compare/v0.2.1...HEAD
[Unreleased]: https://github.com/hpi-sam/digital-fuesim-manv/compare/v0.3.0...HEAD
[0.3.0]: https://github.com/hpi-sam/digital-fuesim-manv/compare/v0.2.1...v0.3.0
[0.2.1]: https://github.com/hpi-sam/digital-fuesim-manv/compare/v0.2.0...v0.2.1
[0.2.0]: https://github.com/hpi-sam/digital-fuesim-manv/compare/v0.1.0...v0.2.0
[0.1.0]: https://github.com/hpi-sam/digital-fuesim-manv/compare/v0.0.0...v0.1.0
Expand Down
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@ This project is currently developed as a [bachelor project](https://hpi.de/en/st

## Links for collaborators

- [(internal) Test scenarios](https://github.com/hpi-sam/digital-fuesim-manv_test-scenarios)
- [Internal test scenarios](https://github.com/hpi-sam/digital-fuesim-manv_test-scenarios)
- Used only for private testing
- [Public test scenarios](https://github.com/hpi-sam/digital-fuesim-manv-public-test-scenarios)
- Used for test scenarios in pipelines, Can also be used for private testing
- For usage see the README.md in that repo
- This repo is also a submodule of this repo. Use `--recurse-submodules` when cloning the repo or `run git submodule update --init --recursive` if you have cloned the repo already to get its contents.

## Installation

1. Install [NodeJs](https://nodejs.org/) (at least version 18.x) (if you need different node versions on your machine we recommend [nvm](https://github.com/nvm-sh/nvm) or [nvm for windows](https://github.com/coreybutler/nvm-windows))
2. [npm](https://www.npmjs.com/) should already come with NodeJs - if not install it
3. Clone this repository
3. Clone the repo by running `git clone https://github.com/hpi-sam/digital-fuesim-manv`. To be able to run migration tests, you also have to clone the submodules: use `git clone --recurse-submodules https://github.com/hpi-sam/digital-fuesim-manv` or run `git submodule update --init --recursive` if you have cloned the repo already.
4. Run `npm run setup` from the root folder
5. Copy the [`.env.example`](./.env.example) file to `./.env` and adjust the settings as you need them. Note that some of the variables are explained under the next point.
6. Choose whether you want to use a database:
Expand Down Expand Up @@ -111,6 +116,14 @@ In addition, you can make use of the following browser extensions:

## Testing

### Migration tests

Whenever adding a new action or new state altering ui components (things that a user can use to alter the state in new ways) one should add exports of exercises in which the new features where tested to the [Public test scenarios](https://github.com/hpi-sam/digital-fuesim-manv-public-test-scenarios)

The test scenarios are stored in a submodule. Use `--recurse-submodules` when cloning the repo or run `git submodule update --init --recursive` if you have cloned the repo already.

If you wish to run the migration tests use `npm run test:migration`

### Unit tests

We are using [Jest](https://jestjs.io/) for our unit tests.
Expand Down
6 changes: 3 additions & 3 deletions backend/package-lock.json

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

6 changes: 4 additions & 2 deletions backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "digital-fuesim-manv-backend",
"version": "0.2.1",
"version": "0.3.0",
"type": "module",
"scripts": {
"start:once:linux-macos": "NODE_ENV=production node --experimental-specifier-resolution=node dist/src/index.js",
Expand All @@ -13,7 +13,9 @@
"lint": "eslint --max-warnings 0 --ignore-path .gitignore \"./**/*.{ts,js,yml,html}\"",
"lint:fix": "eslint --ignore-path .gitignore --fix \"./**/*.{ts,js,yml,html}\"",
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand --coverage --verbose",
"test:ci": "node --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand --coverage --verbose --ci",
"test:migration": "node --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand --coverage --verbose ./test/http-migration.spec.ts",
"test:ci-no-migration": "node --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand --coverage --verbose --ci --testPathIgnorePatterns ./test/http-migration.spec.ts",
"test:ci-migration": "node --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand --coverage --verbose --ci ./test/http-migration.spec.ts",
"test:watch": "node --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand --verbose --watch",
"typeorm:cli": "NODE_ENV=migration node --experimental-specifier-resolution=node --loader ts-node/esm ./node_modules/typeorm/cli -d src/database/migration-datasource.ts",
"typeorm:cli:prod": "NODE_ENV=migration node --experimental-specifier-resolution=node ./node_modules/typeorm/cli -d dist/src/database/migration-datasource.js",
Expand Down
6 changes: 3 additions & 3 deletions backend/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,21 +101,21 @@ export class Config {
DFM_USE_DB_TESTING: bool({ default: undefined }),
DFM_DB_USER: str(
// Require this variable only when the database should be used.
this.isTrue(process.env.DFM_USE_DB)
this.isTrue(process.env['DFM_USE_DB'])
? {}
: { default: undefined }
),
DFM_DB_USER_TESTING: str({ default: undefined }),
DFM_DB_PASSWORD: str(
// Require this variable only when the database should be used.
this.isTrue(process.env.DFM_USE_DB)
this.isTrue(process.env['DFM_USE_DB'])
? {}
: { default: undefined }
),
DFM_DB_PASSWORD_TESTING: str({ default: undefined }),
DFM_DB_NAME: str(
// Require this variable only when the database should be used.
this.isTrue(process.env.DFM_USE_DB)
this.isTrue(process.env['DFM_USE_DB'])
? {}
: { default: undefined }
),
Expand Down
2 changes: 1 addition & 1 deletion backend/src/exercise/http-handler/secure-http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function secureHttp<Result extends object | undefined>(
});
} catch (innerError: unknown) {
// Nothing works. Log if in production mode, otherwise re-throw inner error
if (process.env.NODE_ENV !== 'production') {
if (process.env['NODE_ENV'] !== 'production') {
throw innerError;
}
console.warn(
Expand Down
6 changes: 3 additions & 3 deletions backend/src/exercise/websocket-handler/secure-on.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { createTestEnvironment } from '../../../test/utils';
describe('secure on', () => {
const environment = createTestEnvironment();
it('does not crash in production environment when fed with invalid data', async () => {
const originalEnv = process.env.NODE_ENV;
const originalEnv = process.env['NODE_ENV'];
// Errors are only catched in production mode
process.env.NODE_ENV = 'production';
process.env['NODE_ENV'] = 'production';
await environment
.withWebsocket(async (socket) => {
socket.insecureEmit('getState', 'any');
Expand All @@ -16,7 +16,7 @@ describe('secure on', () => {
await environment.httpRequest('get', '/api/health').expect(200);
})
.finally(() => {
process.env.NODE_ENV = originalEnv;
process.env['NODE_ENV'] = originalEnv;
});
});
// TODO: test that it does crash in development environment when fed with invalid data
Expand Down
2 changes: 1 addition & 1 deletion backend/src/exercise/websocket-handler/secure-on.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type {
import type { ExerciseSocket } from '../../exercise-server';

function isDevelopment() {
return process.env.NODE_ENV !== 'production';
return process.env['NODE_ENV'] !== 'production';
}

export function secureOn<
Expand Down
Loading

0 comments on commit 3c5a1bc

Please sign in to comment.