This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 472
Re-implemented from scratch integration testing #1716
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 |
---|---|---|
|
@@ -4,3 +4,4 @@ vagrant | |
packaging | ||
log/* | ||
.DS_Store | ||
.bundle/config |
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
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
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
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,83 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
## | ||
# Auxiliar functions | ||
|
||
PORTUS_DB_ADAPTER=${PORTUS_DB_ADAPTER:-mysql2} | ||
|
||
# Interacts with a daemon by taking two arguments: | ||
# 1. The action (e.g. "start"). | ||
# 2. The service (e.g. "mysql"). | ||
# We do this to abstract the fact that Travis CI does not use systemd and we do. | ||
function __daemon() { | ||
if [[ -z "$CI" ]]; then | ||
sudo systemctl $1 $2 | ||
else | ||
sudo service $2 $1 | ||
fi | ||
} | ||
|
||
# Performs systemctl calls to the current database adapter when used outside of | ||
# a container. | ||
function __database() { | ||
if [[ -f /.dockerenv ]]; then | ||
return | ||
fi | ||
|
||
if [[ "$PORTUS_DB_ADAPTER" == "mysql2" ]]; then | ||
__daemon $1 mysql | ||
else | ||
__daemon $1 postgresql | ||
fi | ||
} | ||
|
||
# Setup an insecure registry for the local docker. | ||
function __docker_insecure() { | ||
if [[ ! -z "$CI" ]]; then | ||
sudo tee /etc/docker/daemon.json > /dev/null <<EOF | ||
{ | ||
"insecure-registries" : ["172.17.0.1:5000"] | ||
} | ||
EOF | ||
fi | ||
__daemon restart docker | ||
|
||
# Show version info | ||
docker --version | ||
docker-compose --version | ||
} | ||
|
||
## | ||
# The actual run | ||
|
||
# Test commit messages | ||
bundle exec rake test:git | ||
|
||
# Style and security checks | ||
bundle exec rubocop -V | ||
bundle exec rubocop -F | ||
|
||
# Compile assets | ||
bundle exec rake portus:assets:compile | ||
|
||
# Ruby tests | ||
__database restart | ||
bundle exec rspec spec | ||
__database stop | ||
if [[ ! -f /.dockerenv ]]; then | ||
__docker_insecure | ||
bundle exec rake test:integration | ||
fi | ||
|
||
# Note: it ignores a couple of files which use ruby 2.5 syntax which brakeman | ||
# does not know how to handle... | ||
bundle exec brakeman --skip-files lib/portus/background/sync.rb,lib/portus/registry_client.rb | ||
|
||
# Make sure that there are no annotations needed. | ||
bundle exec rake portus:annotate_and_exit | ||
|
||
# JavaScript tests and style. | ||
yarn test | ||
yarn eslint |
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.
Any specific reason to restart and then stop the database?
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 because unit tests require the DB to be up, and integration tests raise their own database, so we should stop the main DB so there are no clashes.