Receipt Processor Challenge

Solution to the test receipt-processor-challenge

Requirements

  1. make

  2. docker >= 18

  3. docker-compose >= 1.25

Use

  1. create the .env file with the environment variables in the root directory, take .template.env as an example

  2. start project dependencies, this will raise a couple of docker images, one for postgresql and another for flyway, ./cicd/docker-compose.deps.yml file is used:

    make start_dependencies
  3. compile the project:

    make compile
  4. run test

    1. start project dependencies:
      make start_dependencies
    2. run all tests:
      make test
    3. run only one class of tests:
      make test-only TEST_CLASS="CLASS-NAME"
      example:
      make test-only TEST_CLASS="com.dgg.receiptprocessorchallenge.ValidationsSpec"
    4. finally stop dependencies:
      make stop_dependencies
  5. run sbt console inside docker, sbt is the tool used to build a scala application, ./cicd/docker-compose.dev.yml file is used

    1. run sbt:
      make sbt
    2. from the console you can also compile and run tests
      sbt:receipt-processor-challenge> compile
      sbt:receipt-processor-challenge> test
      sbt:receipt-processor-challenge> testOnly com.dgg.receiptprocessorchallenge.persistance.postgres.QueriesSpec
    3. exit with ctrl + c
    4. finally stop dependencies:
      make stop_dependencies
  6. run project:

    1. start run start dependencies and build the project using the file ./cicd/docker-compose.run.yml:
      make start_run
    2. logs can be viewed using, exit with ctrl + c:
      docker logs -f main-sbt-1
      logs
    3. requests can be made to `http://localhost:8080/receipts/process request request
    4. finally stop run:
      make stop_all

Important.- stop and start the dependencies if a branch change is made for development, enable git hook to check format when committing

git config core.hooksPath .git-hooks

ff the format is wrong you can use:

make format

format can be checked at any time with:

make checkFormat