This repository has been archived by the owner on Dec 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
feat: dockerize test suite #28
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3468a6f
Test suite cli runner
54282ff
feat: implement Dockerfile
jawid-h 531ae86
chore: implement Travis deploy script
jawid-h 5001889
fix: remove unused dependencies, change description
jawid-h aad7ce9
fix: Travis config
jawid-h cf32179
Merge branch 'master' into add-dockerfile
jawid-h d554fb8
fix: remove duplicate file
jawid-h File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
DASHJS_SEED= | ||
DAPI_CLIENT_SEEDS=ip1,ip2 | ||
DAPI_CLIENT_PORT=3000 | ||
FAUCET_PRIVATE_KEY= | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
FROM node:12-alpine | ||
|
||
RUN apk update && \ | ||
apk --no-cache upgrade && \ | ||
apk add --no-cache git \ | ||
alpine-sdk | ||
|
||
# Install dependencies first, in a different location | ||
# for easier app bind mounting for local development | ||
WORKDIR / | ||
|
||
COPY package.json package-lock.json ./ | ||
RUN npm ci --production | ||
|
||
FROM node:12-alpine | ||
|
||
LABEL maintainer="Dash Developers <[email protected]>" | ||
LABEL description="Test suite for Dash Platform" | ||
|
||
# Copy NPM modules | ||
COPY package.json package-lock.json ./ | ||
COPY --from=0 /node_modules/ /node_modules | ||
|
||
ENV PATH /node_modules/.bin:$PATH | ||
|
||
# Copy project files | ||
WORKDIR /usr/src/app | ||
COPY . ./ | ||
|
||
ARG NODE_ENV=production | ||
ENV NODE_ENV ${NODE_ENV} | ||
|
||
ENTRYPOINT ["./bin/test.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env bash | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it duplicate? |
||
|
||
set -ea | ||
|
||
cmd_usage="Run test suite | ||
|
||
Usage: run-test <seed> [options] | ||
|
||
<seed> can be IP or IP:port | ||
|
||
Options: | ||
-ni --npm-install - run npm install before running the suite | ||
-s=a,b,c --scope=a,b,c - run only scope | ||
-h --help - Show help | ||
|
||
Possible scopes: | ||
e2e | ||
functional | ||
core | ||
platform | ||
e2e:dpns | ||
e2e:contacts | ||
functional:core | ||
functional:platform" | ||
|
||
|
||
DASHJS_SEED="$1" | ||
|
||
if [ -z "$DASHJS_SEED" ] || [[ $DASHJS_SEED == -* ]] | ||
then | ||
echo "Seed is not specified" | ||
exit 0 | ||
fi | ||
|
||
for i in "$@" | ||
do | ||
case ${i} in | ||
-h|--help) | ||
echo "$cmd_usage" | ||
exit 0 | ||
;; | ||
-ni|--npm-install) | ||
npm_install=1 | ||
;; | ||
-s=*|--scope=*) | ||
scope="${i#*=}" | ||
;; | ||
esac | ||
done | ||
|
||
if [ -n "$npm_install" ] | ||
then | ||
cd .. && npm install | ||
fi | ||
|
||
if [ -n "$scope" ] | ||
then | ||
cd .. && DASHJS_SEED="$DASHJS_SEED" npm run test:"$scope" | ||
else | ||
cd .. && DASHJS_SEED="$DASHJS_SEED" npm run test | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Show script in output, and error if anything fails | ||
set -xe | ||
|
||
# Update this whenever the latest Node.js LTS version changes (~ every year). | ||
# Do not forget to add this version to .travis.yml config also. | ||
LATEST_LTS_VERSION="12" | ||
|
||
# We want this command to succeed whether or not the Node.js version is the | ||
# latest (so that the build does not show as failed), but _only_ the latest | ||
# should be used to publish the module. | ||
if [[ "$TRAVIS_NODE_VERSION" != "$LATEST_LTS_VERSION" ]]; then | ||
echo "Node.js v$TRAVIS_NODE_VERSION is not latest LTS version -- will not deploy with this version." | ||
exit 0 | ||
fi | ||
|
||
# Parse version and it's segments | ||
VERSION="$(jq -r .version package.json)" | ||
PACKAGE_TAG=v"$VERSION" | ||
|
||
VERSION_NO_PRERELEASE=$(awk -F- '{print $1}' <<< $VERSION) | ||
PRERELEASE=$(awk -F- '{print $2}' <<< $VERSION) | ||
|
||
MAJOR=$(awk -F. '{print $1}' <<< $VERSION_NO_PRERELEASE) | ||
MINOR=$(awk -F. '{print $2}' <<< $VERSION_NO_PRERELEASE) | ||
PATCH=$(awk -F. '{print $3}' <<< $VERSION_NO_PRERELEASE) | ||
|
||
# Ensure the tag matches the one in package.json, otherwise abort. | ||
if [[ "$PACKAGE_TAG" != "$TRAVIS_TAG" ]]; then | ||
echo "Travis tag (\"$TRAVIS_TAG\") is not equal to package.json tag (\"$PACKAGE_TAG\"). Please push a correct tag and try again." | ||
exit 1 | ||
fi | ||
|
||
IMAGE_NAME="dashpay/platform-test-suite" | ||
|
||
# If prerelease is empty it is a stable release | ||
# so we add latest tag, otherwise a full version tag | ||
LAST_TAG="${MAJOR}.${MINOR}.${PATCH}-${PRERELEASE}" | ||
TAG_POSTFIX="-dev" | ||
if [[ -z "$PRERELEASE" ]]; then | ||
LAST_TAG="latest" | ||
TAG_POSTFIX="" | ||
fi | ||
|
||
# Build an image with multiple tags | ||
docker build --build-arg NODE_ENV=development \ | ||
-t "${IMAGE_NAME}:${MAJOR}${TAG_POSTFIX}" \ | ||
-t "${IMAGE_NAME}:${MAJOR}.${MINOR}${TAG_POSTFIX}" \ | ||
-t "${IMAGE_NAME}:${MAJOR}.${MINOR}.${PATCH}${TAG_POSTFIX}" \ | ||
-t "${IMAGE_NAME}:${LAST_TAG}" \ | ||
. | ||
|
||
# Login to Docker Hub | ||
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin | ||
|
||
# Push an image and all the tags | ||
docker push "${IMAGE_NAME}:${MAJOR}${TAG_POSTFIX}" | ||
docker push "${IMAGE_NAME}:${MAJOR}.${MINOR}${TAG_POSTFIX}" | ||
docker push "${IMAGE_NAME}:${MAJOR}.${MINOR}.${PATCH}${TAG_POSTFIX}" | ||
docker push "${IMAGE_NAME}:${LAST_TAG}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
dashevo/platform-test-suite