-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #712 from alphagov/validate-analytics-against-schemas
Validate analytics against schemas
- Loading branch information
Showing
6 changed files
with
87 additions
and
2 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
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 |
---|---|---|
|
@@ -4,11 +4,55 @@ set -e | |
|
||
git clean -fdx | ||
|
||
bundle install --path "${HOME}/bundles/${JOB_NAME}" --deployment | ||
|
||
export GOVUK_APP_DOMAIN=dev.gov.uk | ||
export GOVUK_WEBSITE_ROOT=http://www.dev.gov.uk | ||
|
||
REPO_NAME=${REPO_NAME:-"alphagov/static"} | ||
CONTEXT_MESSAGE=${CONTEXT_MESSAGE:-"default"} | ||
GH_STATUS_GIT_COMMIT=${SCHEMA_GIT_COMMIT:-${GIT_COMMIT}} | ||
|
||
env | ||
|
||
function github_status { | ||
REPO_NAME="$1" | ||
STATUS="$2" | ||
MESSAGE="$3" | ||
gh-status "$REPO_NAME" "$GH_STATUS_GIT_COMMIT" "$STATUS" -d "Build #${BUILD_NUMBER} ${MESSAGE}" -u "$BUILD_URL" -c "$CONTEXT_MESSAGE" >/dev/null | ||
} | ||
|
||
function error_handler { | ||
trap - ERR # disable error trap to avoid recursion | ||
local parent_lineno="$1" | ||
local message="$2" | ||
local code="${3:-1}" | ||
if [[ -n "$message" ]] ; then | ||
echo "Error on or near line ${parent_lineno}: ${message}; exiting with status ${code}" | ||
else | ||
echo "Error on or near line ${parent_lineno}; exiting with status ${code}" | ||
fi | ||
github_status "$REPO_NAME" error "errored on Jenkins" | ||
exit "${code}" | ||
} | ||
|
||
trap 'error_handler ${LINENO}' ERR | ||
github_status "$REPO_NAME" pending "is running on Jenkins" | ||
|
||
# Try to merge master into the current branch, and abort if it doesn't exit | ||
# cleanly (ie there are conflicts). This will be a noop if the current branch | ||
# is master. | ||
git merge --no-commit origin/master || git merge --abort | ||
|
||
# Clone govuk-content-schemas depedency for contract tests | ||
rm -rf tmp/govuk-content-schemas | ||
git clone [email protected]:alphagov/govuk-content-schemas.git tmp/govuk-content-schemas | ||
( | ||
cd tmp/govuk-content-schemas | ||
git checkout ${SCHEMA_GIT_COMMIT:-"master"} | ||
) | ||
export GOVUK_CONTENT_SCHEMAS_PATH=tmp/govuk-content-schemas | ||
|
||
bundle install --path "${HOME}/bundles/${JOB_NAME}" --deployment | ||
|
||
# Lint changes introduced in this branch, but not for master | ||
if [[ ${GIT_BRANCH} != "origin/master" ]]; then | ||
bundle exec govuk-lint-ruby \ | ||
|
@@ -25,3 +69,13 @@ fi | |
RAILS_ENV=test bundle exec rake test | ||
RAILS_ENV=test bundle exec rake spec:javascript | ||
RAILS_ENV=production bundle exec rake assets:precompile | ||
|
||
export EXIT_STATUS=$? | ||
|
||
if [ "$EXIT_STATUS" == "0" ]; then | ||
github_status "$REPO_NAME" success "succeeded on Jenkins" | ||
else | ||
github_status "$REPO_NAME" failure "failed on Jenkins" | ||
fi | ||
|
||
exit $EXIT_STATUS |
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 | ||
|
||
export REPO_NAME="alphagov/govuk-content-schemas" | ||
export CONTEXT_MESSAGE="Verify static components against schema examples" | ||
|
||
exec ./jenkins.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
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