- Create a simple CRUD application with the necessary endpoints/middlewares/ORM.
- Connext to PostgreSQL database using docker on the local machine.
- Write test cases for the endpoints using chai and mocha
- Configure a github action workflow to test the end-points every time there is a push to a specific branch or a pull request.
- Configure the branch protection rules in the repository similar to this:
- Now whenever the action is triggered and all checks pass, it will look something like this:
DB_HOST=<db_host> (localhost)
DATABASE=<db_name>
DB_HMAC=<db_password>
DB_PORT=5432 (according to docker command above)
DB_DIALECT="postgres"
DB_POOL_CONNECTION_LIMIT=10 (say)
DB_POOL_IDLE_TIMEOUT=30000 (say)
APP_PORT=3000
- There was an intermittent error saying "could not find relation 'tasks'" in some of the failing test cases.
- Added a script in the project root to create the table while spinning up a docker container in the local setup and modified the github action script to include a create table query so that the table is created before the tests are run as part of the github actions workflow.
- The script to spin a docker container on local is modified as follows:
docker run -d -p 5432:5432 --name node-postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=node_postgres_cicd -e POSTGRES_USER=postgres -v /Users/elkay/Documents/workspace/node_postgres_cicd/scripts:/docker-entrypoint-initdb.d postgres