-
Notifications
You must be signed in to change notification settings - Fork 2
refactor(scripts): add comments, remove duplicates, augment jest #263
base: main
Are you sure you want to change the base?
Conversation
- removed scripts directory - why do we need it? - added comments to circleci/config.yml & related sh scripts - added extra jest config
echo "Adding service hosts records" | ||
|
||
# These should match the services you are creating in your docker-compose file | ||
# This is required for containers to talk to each other |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# This is required for containers to talk to each other | |
# This is required for CircleCI to talk to containers if you export environment variables to the shell that change the host of running containers from localhost to something else like `mysql` and `localstack` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you explain this a bit more? in this instance does "CircleCI" mean a server (not a container) within circle's infrastructure that talks to our specified containers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jpetto From my understanding, when a job is triggered on Circle CI, it provisions a VM (think your local machine) and runs the containers, exposing them on localhost
.
Before we run integration tests we export the environment variables that our application depends on to the shell. This means that when tests are running and using configurations from our config/index.ts
file (which pulls from these env vars), what it reads are the env var definitions for the docker container. CircleCI does not know what mysql
means, so we tell CircleCI that when you see mysql
, please look at it as localhost
or 127.0.0.1
.
Now you may be asking, just as I'm asking myself now, that with projects like prospect-api that are set up to run outside the container without needing any of these env vars, why do we export anything to the shell? I think the answer is that we don't need to and CIrcleCI should just work. I will confirm this after these short messages :)
Let me know if a live chat might help a bit more here.
@@ -3,4 +3,6 @@ module.exports = { | |||
testEnvironment: 'node', | |||
testMatch: ['**/?(*.)+(spec|integration).ts'], | |||
testPathIgnorePatterns: ['/dist/'], | |||
// TODO: remove the following if you don't have any localstack integration tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// TODO: remove the following if you don't have any localstack integration tests | |
// TODO: remove the following if you don't have any setup you would like to do before your tests run. Ex. setting a different endpoint for localstack services for integration tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i was under the impression that if localstack was in use, an endpoint had to be defined - e.g. http://localstack:4566
. is that not the case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My comment is more to the point that this config allows including a setup file that is not just for setting up env vars for localstack, you can pretty much do anything in the setup file like, for example, create a tmp directory for all tests to output something to.
@@ -0,0 +1,4 @@ | |||
// your AWS_ENDPOINT values should be set in .docker/local.env | |||
// this file is to provide a value when running tests locally outside of the container | |||
// TODO: if you don't have any localstack integration tests, you can delete this file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// TODO: if you don't have any localstack integration tests, you can delete this file | |
// TODO: if you don't have any localstack integration tests, you can delete this file | |
// Generally, if you don't have any setup you would like to do before tests, you can delete this entire file |
// TODO: if you aren't using localstack, you can get rid of the `aws` section | ||
aws: { | ||
localEndpoint: process.env.AWS_ENDPOINT, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we also copy the content of scripts
to scripts.example
?
this diff is weird - all the files in |
@jpetto confirmed that scripts.example files have content that is not showing up in this PR. |
Goal
add comments and clean up some scripts. also add extra jest config options.
I'd love feedback/perspectives on:
scripts
andscripts.example
directories in.circleci
. these were kind of doing the same thing, though with small inconsistencies. seems confusing to me to keep both.Implementation Decisions
jest.setup.js
file to help with (potential) local (outside of container) integration tests.