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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented from scratch integration tests
I've also fixed a couple of small nitpicks in the current testing setup. Fixes #1667 Signed-off-by: Miquel Sabaté Solà <[email protected]>
- Loading branch information
Showing
29 changed files
with
1,185 additions
and
34 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 |
---|---|---|
|
@@ -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.