-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Rename `tests` directory to `test` * Reorganize CI scripts
- Loading branch information
Showing
21 changed files
with
83 additions
and
43 deletions.
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
TASK_TYPE=$1 | ||
CI_DIR_NAME=".ci" | ||
|
||
echo "=== Task $TASK_TYPE ===" | ||
|
||
echo "Setting environmental variables..." | ||
export CI_BUILD_NUMBER=$TRAVIS_BUILD_NUMBER | ||
export CI_PULL_REQUEST=$TRAVIS_PULL_REQUEST | ||
export CI_PULL_REQUEST_BRANCH=$TRAVIS_PULL_REQUEST_BRANCH | ||
export CI_BRANCH=$TRAVIS_BRANCH | ||
|
||
echo "Scanning all directories on root..." | ||
for dir in */ ; do | ||
SCRIPT_PATH="$dir$CI_DIR_NAME/$TASK_TYPE.sh" | ||
if [ ! -f "$SCRIPT_PATH" ]; then | ||
continue | ||
fi | ||
|
||
echo ">> Running $TASK_TYPE in directory $dir..." | ||
source $SCRIPT_PATH | ||
done |
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,9 @@ | ||
#!/bin/bash | ||
|
||
IMAGE_NAME="core-test" | ||
|
||
echo "Building test image..." | ||
docker build -t $IMAGE_NAME:$CI_BUILD_NUMBER -f ./core/Dockerfile . | ||
|
||
echo "Running tests with coverage reporting..." | ||
docker run --rm --network="host" -e CODACY_PROJECT_TOKEN=$CODACY_PROJECT_TOKEN $IMAGE_NAME:$CI_BUILD_NUMBER |
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,4 +1,4 @@ | ||
/node_modules | ||
/dist | ||
/coverage | ||
/tests/**/.* | ||
/test/**/.* |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
}, | ||
"exclude": [ | ||
"node_modules", | ||
"tests" | ||
"test", | ||
"coverage" | ||
] | ||
} |
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,39 @@ | ||
#!/bin/bash | ||
|
||
echo "Tagging Docker image..." | ||
cd ./docker-image | ||
|
||
NPM_VERSION=$(node -p -e "require('./package.json').version"); | ||
echo "Package version: $NPM_VERSION"; | ||
|
||
TAG=$(if [[ $CI_PULL_REQUEST == "false" ]] && [[ $CI_BRANCH == "master" ]]; then | ||
echo "latest"; | ||
elif [[ $CI_PULL_REQUEST == "false" ]]; then | ||
echo "snapshot-branch-$CI_BRANCH"; | ||
else | ||
echo "snapshot-PR-$CI_PULL_REQUEST_BRANCH"; | ||
fi) | ||
|
||
if [[ $CI_PULL_REQUEST == "false" ]] && [[ $CI_BRANCH == "master" ]]; then | ||
ALREADY_EXISTS=$(curl https://hub.docker.com/v2/repositories/$DOCKER_IMAGE_REPOSITORY/tags/?page_size=10000 | jq -r "[.results | .[] | .name == \"$NPM_VERSION\"] | any") | ||
fi | ||
|
||
if [[ $ALREADY_EXISTS == "true" ]]; then | ||
echo "Skipping pushing image with the same NPM Version tag"; | ||
exit 0; | ||
fi | ||
|
||
echo "Tagging the Docker image with $TAG tag..."; | ||
docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"; | ||
docker tag $DOCKER_IMAGE_REPOSITORY:$CI_BUILD_NUMBER $DOCKER_IMAGE_REPOSITORY:$TAG; | ||
|
||
echo "Pushing the Docker image with $TAG tag..." | ||
docker push $DOCKER_IMAGE_REPOSITORY:$TAG; | ||
|
||
# Push additional tag with version if necessary | ||
if [[ $CI_PULL_REQUEST == "false" ]] && [[ $CI_BRANCH == "master" ]]; then | ||
echo "Tagging the Docker image with $NPM_VERSION tag..."; | ||
docker tag $DOCKER_IMAGE_REPOSITORY:$CI_BUILD_NUMBER $DOCKER_IMAGE_REPOSITORY:$NPM_VERSION; | ||
echo "Pushing the Docker image with $NPM_VERSION tag..."; | ||
docker push $DOCKER_IMAGE_REPOSITORY:$NPM_VERSION; | ||
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,6 @@ | ||
#!/bin/bash | ||
|
||
echo "Building image..." | ||
cd ./docker-image | ||
docker build -t $DOCKER_IMAGE_REPOSITORY:$CI_BUILD_NUMBER . | ||
cd .. |