diff --git a/.circleci/config.yml b/.circleci/config.yml index b5fa3bb8..91df65fc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -149,7 +149,8 @@ jobs: # paths: # - ./node_modules # - run: - # # TODO: Update + # # TODO: Update below - you may be able to remove one or all of the --hosts/--db/--aws options + # # depending on what scripts you have in .circleci/scripts # name: run setup.sh # command: | # export $(egrep -v '^#' .docker/local.env | xargs -0) && ./.circleci/scripts/setup.sh --hosts --db --aws diff --git a/.circleci/scripts.example/setup.sh b/.circleci/scripts.example/setup.sh old mode 100644 new mode 100755 diff --git a/.circleci/scripts.example/setup_aws.sh b/.circleci/scripts.example/setup_aws.sh old mode 100644 new mode 100755 diff --git a/.circleci/scripts.example/setup_db.sh b/.circleci/scripts.example/setup_db.sh old mode 100644 new mode 100755 diff --git a/.circleci/scripts.example/setup_hosts.sh b/.circleci/scripts.example/setup_hosts.sh old mode 100644 new mode 100755 index c7844253..ae025c2a --- a/.circleci/scripts.example/setup_hosts.sh +++ b/.circleci/scripts.example/setup_hosts.sh @@ -1,9 +1,11 @@ #!/bin/bash set -e +# Add host entries to match local docker development names. 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 declare -a arr=("mysql" "localstack" "snowplow") for i in "${arr[@]}"; do diff --git a/.circleci/scripts/setup.sh b/.circleci/scripts/setup.sh deleted file mode 100755 index 8ac2c720..00000000 --- a/.circleci/scripts/setup.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -set -e - -dir=$(dirname "$0") -while [[ "$1" ]]; do - case "$1" in - --hosts) - "${dir}"/setup_hosts.sh - ;; - --db) - "${dir}"/setup_db.sh - ;; - esac - shift -done diff --git a/.circleci/scripts/setup_db.sh b/.circleci/scripts/setup_db.sh deleted file mode 100755 index 1a8e6f65..00000000 --- a/.circleci/scripts/setup_db.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -# shellcheck disable=SC1090 - -echo "Setting up database" - -sudo apt-get update && sudo apt-get install -y mysql-client - -set -e -mysql=( mysql -uroot -h127.0.0.1 ) - -# Wait for mysql to respond -for _ in {30..0}; do - if echo 'SELECT 1' | "${mysql[@]}" &> /dev/null; then - break - fi - echo 'MySQL init process in progress...' - sleep 1 -done - -for f in .docker/mysql/schema/*; do - echo "$f" - case "$f" in - *.sh) echo "$0: running $f"; . "$f" ;; - *.sql) echo "$0: running $f"; "${mysql[@]}" < "$f"; echo ;; - *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${mysql[@]}"; echo ;; - *) echo "$0: ignoring $f" ;; - esac - echo -done diff --git a/.circleci/scripts/setup_hosts.sh b/.circleci/scripts/setup_hosts.sh deleted file mode 100755 index f31ae469..00000000 --- a/.circleci/scripts/setup_hosts.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -set -e - -# Add host entries to match local docker development names. - -echo "Adding service hosts records" - - -declare -a arr=("mysql") - -for i in "${arr[@]}"; do - echo 127.0.0.1 "$i" | sudo tee -a /etc/hosts -done - - - diff --git a/jest.config.js b/jest.config.js index 0db0fc75..f77c5d28 100644 --- a/jest.config.js +++ b/jest.config.js @@ -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 + setupFiles: ['./jest.setup.js'], }; diff --git a/jest.setup.js b/jest.setup.js new file mode 100644 index 00000000..e2134c2d --- /dev/null +++ b/jest.setup.js @@ -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 +process.env.AWS_ENDPOINT = process.env.AWS_ENDPOINT || 'http://localhost:4566'; diff --git a/src/config/index.ts b/src/config/index.ts index aaf0a9f0..db4eb668 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -4,6 +4,10 @@ export default { environment: process.env.NODE_ENV || 'development', defaultMaxAge: 86400, }, + // TODO: if you aren't using localstack, you can get rid of the `aws` section + aws: { + localEndpoint: process.env.AWS_ENDPOINT, + } // TODO: Update example cache configuration below if necessary. redis: { primaryEndpoint: process.env.REDIS_PRIMARY_ENDPOINT || 'redis',