feat: add choice based matching #466
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: MCDA-test | pull request | end-to-end tests | |
on: | |
pull_request: | |
branches: develop | |
jobs: | |
test: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
node-version: ['18'] | |
os: [ubuntu-22.04] | |
services: | |
postgres: | |
image: postgres:12.2-alpine | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: develop | |
POSTGRES_DB: postgres | |
POSTGRES_HOST_AUTH_METHOD: trust | |
ports: | |
- 5432:5432 | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: fetch schema | |
run: curl https://raw.githubusercontent.com/drugis/patavi/master/server/schema.sql -o patavi.schema.sql | |
- name: setup patavi database | |
run: | | |
docker exec ${{ job.services.postgres.id }} psql -U postgres -c "CREATE USER patavi WITH PASSWORD 'develop'" | |
docker exec ${{ job.services.postgres.id }} psql -U postgres -c "CREATE DATABASE patavi ENCODING 'utf-8' OWNER patavi" | |
- name: initialize patavi database | |
run: | | |
docker cp patavi.schema.sql ${{ job.services.postgres.id }}:/patavi.schema.sql | |
docker exec ${{ job.services.postgres.id }} psql -v ON_ERROR_STOP=1 -U patavi -f patavi.schema.sql | |
- name: run rabbit | |
run: docker run -d --hostname my-rabbit --name my-rabbit -p 5672:5672 -p 15672:15672 rabbitmq:3-management | |
- name: run patavi server | |
run: >- | |
docker run -d --name patavi-server | |
--network host | |
-e PATAVI_BROKER_HOST=guest:guest@localhost | |
-p 3000:3000 | |
-e PATAVI_HOST=localhost | |
-e PATAVI_PORT=3000 | |
-e PATAVI_DB_HOST=localhost | |
-e PATAVI_DB_NAME=patavi | |
-e PATAVI_DB_USER=patavi | |
-e PATAVI_DB_PASSWORD=develop | |
-e SECURE_TRAFFIC=false | |
-e PATAVI_API_KEY=${{ secrets.pataviApiKeyTest }} | |
addis/patavi-server:test | |
- name: build and run patavi worker | |
run: | | |
cd R | |
docker build --tag addis/patavi-smaa-worker . | |
docker run -d --link my-rabbit:rabbit -e PATAVI_BROKER_HOST=rabbit --name patavi-mcda-worker addis/patavi-smaa-worker | |
cd .. | |
- name: setup mcda database | |
run: | | |
docker exec ${{ job.services.postgres.id }} psql -U postgres -c "CREATE USER mcdaweb WITH PASSWORD 'develop'" | |
docker exec ${{ job.services.postgres.id }} psql -U postgres -c "CREATE DATABASE mcdaweb ENCODING 'utf-8' OWNER mcdaweb" | |
- name: initialize mcda database | |
run: | | |
docker cp database.pg.sql ${{ job.services.postgres.id }}:/database.pg.sql | |
docker exec ${{ job.services.postgres.id }} psql -v ON_ERROR_STOP=1 -U mcdaweb -f database.pg.sql | |
- name: add local users | |
run: | | |
docker exec ${{ job.services.postgres.id }} psql -U mcdaweb -c "INSERT INTO Account (username, firstName, lastName, password) VALUES ('user', 'user', 'user', '\$2a\$10\$HOkkgYW2IqzPc6ryCbi/9OWUpJPxh2mu7IzDpLvxShBcZRtwb/1F.')" | |
docker exec ${{ job.services.postgres.id }} psql -U mcdaweb -c "INSERT INTO Account (username, firstName, lastName, password) VALUES ('user2', 'user2', 'user2', '\$2a\$10\$HOkkgYW2IqzPc6ryCbi/9OWUpJPxh2mu7IzDpLvxShBcZRtwb/1F.')" | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Cache node modules | |
uses: actions/cache@v1 | |
with: | |
path: node_modules | |
key: ${{ runner.OS }}-build-${{ hashFiles('package.json') }} | |
- name: run yarn | |
run: yarn | |
- name: build backend | |
run: yarn build-backend | |
- name: run webpack | |
run: yarn build-local-login | |
- name: run mcda | |
run: yarn start & | |
env: | |
MCDAWEB_AUTHENTICATION_METHOD: LOCAL | |
MCDAWEB_DB_USER: mcdaweb | |
MCDAWEB_DB_PASSWORD: develop | |
MCDAWEB_DB_HOST: localhost | |
MCDAWEB_DB_NAME: mcdaweb | |
MCDAWEB_COOKIE_SECRET: abc | |
MCDA_HOST: localhost | |
PATAVI_HOST: localhost | |
PATAVI_PORT: 3000 | |
SECURE_TRAFFIC: false | |
PATAVI_API_KEY: ${{ secrets.pataviApiKeyTest }} | |
- name: run nightwatch tests | |
id: nightwatch | |
run: yarn tsc -p ts-end-to-end-config.json && yarn nightwatch -c nightwatch.github.conf.js | |
- name: notify on slack channel on nightwatch failure | |
if: failure() | |
uses: rtCamp/action-slack-notify@master | |
env: | |
SLACK_WEBHOOK: ${{ secrets.slackWebhook }} | |
SLACK_USERNAME: gitbot | |
SLACK_TITLE: 'Develop pull request:' | |
SLACK_MESSAGE: 'End-to-end tests failed' | |
- name: notify on slack channel on success | |
if: success() | |
uses: rtCamp/action-slack-notify@master | |
env: | |
SLACK_WEBHOOK: ${{ secrets.slackWebhook }} | |
SLACK_USERNAME: gitbot | |
SLACK_TITLE: 'Develop pull request:' | |
SLACK_MESSAGE: 'End-to-end tests passed' | |
- name: stop mcda | |
run: sudo pkill -9 node |