data61 / mirza-archived

Archived Mirza repository before large files were removed. Don't use.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mirza

Setting up

If you do not have the latest version of stack, please remove whatever version of stack you have:

sudo apt remove haskell-stack

Then get the latest version of stack by running:

wget -qO- https://get.haskellstack.org/ | sh

Building the server

To build the server, run:

stack build

Installing PostgreSQL

PostgreSQL is used as the database backend. Before you run the server, make sure you have PostgreSQL 9 or higher installed.

To install, you can follow the instructions here.

Note that you may need to run the commands as a super user.

Create a Postgres account. There are good instructions here

Type in psql and see that you can open up a psql shell.

Initalising the database

When first run you will need to inialise the database.

After that, to create the database, run: createdb 'devsupplychainserver'

To initalise the database run: stack exec supplyChainServer -- --brhost localhost --brport 8200 --init-db -c "dbname=<database name>"

The -c option takes a database connection string in libpq format.

Some examples are:

  • "dbname=devsupplychainserver"`
  • "postgresql://localhost/devsupplychainserver"

The default connection string is dbname=devsupplychainserver.

Running the server

Finally, to run the server, do:

stack exec supplyChainServer -- --brhost localhost --brport 8200

Then you can check out the API at:

http://localhost:8000/swagger-ui/

To use ghci interactively, run

stack ghci

If you find yourself deleting and recreating the database frequently, run ./restart.sh. It will build your code, drop the database devsupplychainserver, create it anew and run the migration script to create all the relevant tables.

To do a clean build instead, do ./restart.sh --clean.

Running the tests

The run_tests.sh script will run the tests (and makes sure they run single threaded because the tests depend on previous tests), it should usually be run as:

./run_tests.sh

# If you want a coverage report
./coverage.sh

# If you want to launch the report in the browser
./coverage.sh --launch

To initialise the BR test DB, run the following:

stack build --fast && dropdb testbusinessregistry && createdb testbusinessregistry && stack exec businessRegistry -- -c 'dbname=testbusinessregistry' --env Dev --log-level DebugS initdb

You'll need to run the above each time the BR db schema changes.

Acronyms

Some common acronyms used in the project.

SCS: Supply Chain Service

BR: Business Registry

Useful Tools

About

Archived Mirza repository before large files were removed. Don't use.

License:Apache License 2.0


Languages

Language:Haskell 97.9%Language:Shell 1.1%Language:Dockerfile 0.6%Language:Python 0.4%