Skip to content

Commit 45ed70b

Browse files
committed
Add our standard CI scripts
This drops bundler-audit as this is a gem and we don't want test failures due to outdated Rails builds.
1 parent ebf2eeb commit 45ed70b

File tree

3 files changed

+66
-1
lines changed

3 files changed

+66
-1
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ sudo: false
55
before_install:
66
- gem update --system
77
- gem install bundler
8-
script: bin/rake
8+
before_script:
9+
- "bin/ci-code-review"
10+
script: bin/ci
911
rvm:
1012
- 2.5.0
1113
env:

bin/ci

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
# script/ci: Setup environment for CI to run tests. This is primarily
4+
# designed to run on the continuous integration server.
5+
6+
set -e
7+
cd "$(dirname "$0")/.."
8+
9+
# setup environment
10+
export DEFAULT_HOST="https://account.radiusnetworks.com"
11+
export RAILS_ROOT="$(cd "$(dirname "$0")"/.. && pwd)"
12+
export RAILS_ENV="test"
13+
export RACK_ENV="test"
14+
export RACK_ROOT="$RAILS_ROOT"
15+
16+
# Run the specs for the rails app
17+
echo " ---> Running tests"
18+
./bin/rspec --require rails_helper
19+
20+
# Script for running Rubocop
21+
# A Ruby static code analyzer, based on the community Ruby style guide.
22+
# http://rubocop.readthedocs.io
23+
echo " ---> Running rubocop"
24+
./bin/rubocop --config .rubocop.yml --lint
25+
26+
# Script for running Brakeman tests
27+
# Brakeman is a security scanner
28+
# https://github.com/presidentbeef/brakeman.
29+
echo " ---> Running breakman"
30+
gem install --no-rdoc --no-ri brakeman slim coffee-rails
31+
brakeman --run-all-checks --exit-on-warn --ignore-config config/brakeman.ignore .

bin/ci-code-review

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
# Requires REVIEWDOG_GITHUB_API_TOKEN to be set in the envionment. We use a
4+
# token from the admin account so that the comments look as if they come from
5+
# Radbot.
6+
7+
# See:
8+
# - https://docs.travis-ci.com/user/environment-variables/#Convenience-Variables
9+
# - https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables
10+
# - https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions
11+
if [[ "$TRAVIS_PULL_REQUEST" = "false" ]] || [[ "$TRAVIS_BRANCH" = "production" ]]; then
12+
exit
13+
fi
14+
15+
set -e
16+
cd "$(dirname "$0")/.."
17+
18+
REVIEWDOG_VERSION="0.9.9"
19+
20+
if ! [ "$(./bin/reviewdog -version)" = "$REVIEWDOG_VERSION" ]; then
21+
echo "Installing reviewdog version ${REVIEWDOG_VERSION}..."
22+
curl -fsSL https://github.com/haya14busa/reviewdog/releases/download/$REVIEWDOG_VERSION/reviewdog_linux_amd64 \
23+
-o ./bin/reviewdog
24+
chmod +x ./bin/reviewdog
25+
fi
26+
27+
echo Rubocop Version: $(./bin/rubocop --version)
28+
echo Review Dog Version: $(./bin/reviewdog -version)
29+
30+
# Add `-diff="git diff master"` to reviewdog args when running locally
31+
./bin/rubocop --config .rubocop.yml --extra-details --display-style-guide --rails | \
32+
./bin/reviewdog -f=rubocop -reporter=github-pr-check

0 commit comments

Comments
 (0)