-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added CI scripts, and created a version checking file
Build, lint, and unit tests now running and reporting correctly to 8ac0n. - 8ac0n works now! - Wrote a version checker that outputs checkstyle (checked in lint) RELATED TO OKTA-68828 8ac0n: test OKTA-68828 <<<Jenkins Check-In of Tested SHA: 450e7b3 for rchild@okta.com>>> Artifact: okta-core.webapp
- Loading branch information
1 parent
862536f
commit 68f88ea
Showing
5 changed files
with
221 additions
and
6 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,2 @@ | ||
# 1.1.0 | ||
- Initial copy from okta-core |
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,77 @@ | ||
/*global module */ | ||
var semver = require('semver'), | ||
exec = require('child_process').exec; | ||
|
||
var failMessage = 'Package version must be > latest package version'; | ||
|
||
module.exports = function (grunt) { | ||
|
||
function writeCheckStyle(file, hasError) { | ||
var checkStyle = [ | ||
'<?xml version="1.0" encoding="utf-8"?>', | ||
'<checkstyle version="1.5.6">' | ||
]; | ||
if (hasError) { | ||
checkStyle.push( | ||
'<file name="package.json">', | ||
'<error severity="warning" message="' + failMessage + '" />', | ||
'</file>' | ||
); | ||
} | ||
checkStyle.push('</checkstyle>'); | ||
grunt.log.ok('Writing results to', file); | ||
grunt.file.write(file, checkStyle.join('')); | ||
} | ||
|
||
grunt.registerTask( | ||
|
||
'check-version', | ||
|
||
'Fails task if package version is <= latest published module', | ||
|
||
function () { | ||
var done = this.async(), | ||
options = this.options(), | ||
reporter = options.reporter, | ||
reporterOutput = options.reporterOutput, | ||
hasReporter = reporter && reporterOutput, | ||
force = options.force, | ||
currentPackage = grunt.config('pkg'), | ||
cmd = 'npm view ' + currentPackage.name + ' version'; | ||
|
||
grunt.log.ok('Running', cmd); | ||
|
||
exec(cmd, {}, function (err, latestPublishedVersion) { | ||
|
||
if (err) { | ||
grunt.fail.fatal(err); | ||
} | ||
|
||
grunt.log.ok('Package version: ', currentPackage.version); | ||
grunt.log.ok('Latest published version: ', latestPublishedVersion); | ||
|
||
var isOkay = semver.gt(currentPackage.version, latestPublishedVersion); | ||
|
||
if (hasReporter) { | ||
writeCheckStyle(reporterOutput, !isOkay); | ||
} | ||
|
||
if (isOkay) { | ||
grunt.log.ok('Package version is > latest package version'); | ||
done(); | ||
} | ||
else if (force) { | ||
grunt.log.error(failMessage); | ||
done(); | ||
} | ||
else { | ||
grunt.fail.fatal(failMessage); | ||
} | ||
|
||
}); | ||
|
||
} | ||
|
||
); | ||
|
||
}; |
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,96 @@ | ||
#!/bin/bash -vx | ||
JOB_NAME=`basename $0` | ||
LOGDIRECTORY=/tmp/ci-builder | ||
mkdir -p $LOGDIRECTORY | ||
LOGFILE=$LOGDIRECTORY/$JOB_NAME.log | ||
exec > >(tee $LOGFILE) | ||
exec 2>&1 | ||
set -e | ||
|
||
# Bacon does not pass a parameter, so default to the one we want (deploy) | ||
TASK="${1:-deploy}" | ||
PUBLISHED=0 | ||
|
||
BUILD_TEST_SUITE_ID=D33E21EE-E0D0-401D-8162-56B9A7BA0539 | ||
LINT_TEST_SUITE_ID=2D4D1259-92C2-45BA-A74D-E665B7EC17FB | ||
UNIT_TEST_SUITE_ID=12DFDE73-F3D5-4EEB-BF12-DDE72E66DE61 | ||
|
||
REGISTRY=https://artifacts.aue1d.saasure.com/artifactory/api/npm/npm-okta | ||
|
||
function usage() { | ||
OUTPUTCODE=$1 | ||
echo """ | ||
USAGE: | ||
./okta-signin-widget-build.sh {TASK} | ||
Example: | ||
./okta-signin-widget-build.sh build | ||
TASKS: | ||
help Prints this guide. | ||
deploy Publishes widget to NPM after successful build | ||
Requires valid Artifactory credentials. | ||
""" | ||
[ -z $OUTPUTCODE ] && OUTPUTCODE=0 | ||
exit $OUTPUTCODE | ||
} | ||
|
||
function publish() { | ||
if [ "$BRANCH" == "master" ]; then | ||
echo "Publishing master build" | ||
if npm publish --registry ${REGISTRY}; then | ||
PUBLISHED=1 | ||
echo "Publish Success" | ||
else | ||
echo "Publish Failed" | ||
fi | ||
fi | ||
} | ||
|
||
function build() { | ||
start_test_suite ${BUILD_TEST_SUITE_ID} | ||
if bundle install && npm install && npm run package && publish; then | ||
echo "Finishing up test suite $BUILD_TEST_SUITE_ID" | ||
finish_test_suite "build" | ||
else | ||
echo "Build failed" | ||
finish_failed_test_suite "build" | ||
exit 1 | ||
fi | ||
} | ||
|
||
function lint() { | ||
start_test_suite ${LINT_TEST_SUITE_ID} | ||
if npm run lint:report -- --published=${PUBLISHED}; then | ||
echo "Finishing up test suite $LINT_TEST_SUITE_ID" | ||
finish_test_suite "checkstyle" "okta-signin-widget/build2/" | ||
else | ||
echo "Lint failed" | ||
finish_failed_test_suite "checkstyle" "okta-signin-widget/build2/" | ||
fi | ||
} | ||
|
||
function unit() { | ||
start_test_suite ${UNIT_TEST_SUITE_ID} | ||
if npm test; then | ||
echo "Finishing up test suite $UNIT_TEST_SUITE_ID" | ||
finish_test_suite "jsunit" "okta-signin-widget/build2/reports/jasmine/" | ||
else | ||
echo "Unit failed" | ||
finish_failed_test_suite "jsunit" "okta-signin-widget/build2/reports/jasmine/" | ||
fi | ||
} | ||
|
||
case $TASK in | ||
help) | ||
usage | ||
;; | ||
deploy) | ||
build | ||
lint | ||
unit | ||
;; | ||
*) | ||
usage $TASK | ||
;; | ||
esac |
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