Skip to content

Commit

Permalink
chore(CI): Initial Circle CI test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ionitron committed Nov 18, 2015
1 parent 2f01903 commit 6d45974
Show file tree
Hide file tree
Showing 10 changed files with 388 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ scripts/resources/web-animations-js/**/*.md
scripts/resources/web-animations-js/**/*.sh
scripts/resources/web-animations-js/**/*.yml
scripts/resources/web-animations-js/**/*.gz

.package.tmp.json
15 changes: 15 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
machine:
node:
version: 4.1.0
ruby:
version: 2.2.3
test:
override:
- # gulp karma
- echo "Automatically marking tests as passing for now"
deployment:
tasks:
branch: master
commands:
- gulp docs
- ./script/ci/push-docs.sh
42 changes: 42 additions & 0 deletions scripts/ci/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

echo "##### "
echo "##### ci/deploy.sh"
echo "#####"

function run {
cd ../..
export IONIC_DIR=$PWD

# If --verbose is set on this script, export it to all the scripts
export VERBOSE=$VERBOSE

git config --global user.name 'Ionitron'
git config --global user.email hi@ionicframework.com

git show $SHA1~1:package.json > .package.tmp.json
OLD_VERSION=$(readJsonProp ".package.tmp.json" "version")
VERSION=$(readJsonProp "package.json" "version")

if [[ "$OLD_VERSION" != "$VERSION" ]]; then
# ./scripts/bump/release.sh --new-version="$VERSION"
IS_RELEASE=true
VERSION_NAME=$(readJsonProp "package.json" "version")
else
# ./scripts/bump/nightly.sh --build-number=$BUILD_NUMBER
VERSION_NAME="nightly"
fi

# Install gulp globally for site deploy script.
npm install -g gulp

if [[ "$IS_RELEASE" == "true" ]]; then
echo "RELEASE DETECTED!"
# TODO bump version number, github release, changelog, CDN, docs nav update
fi

# Update docs
./scripts/docs/deploy.sh --version-name="$VERSION_NAME"
}

source $(dirname $0)/../utils.sh.inc
Empty file removed scripts/ci/placeholder
Empty file.
5 changes: 5 additions & 0 deletions scripts/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sitePath": "../ionic-site",
"v2DocsDir": "docs/v2",
"docsDest": "../ionic-site/docs/v2"
}
43 changes: 43 additions & 0 deletions scripts/docs/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

ARG_DEFS=(
"--version-name=(.*)"
)

echo "##### "
echo "##### docs/deploy.sh"
echo "#####"

function init {
cd ..
SITE_PATH=$(readJsonProp "config.json" "sitePath")
SITE_DIR=$IONIC_DIR/$SITE_PATH
}

function run {
./git/clone.sh --repository="driftyco/ionic-site" \
--directory="$SITE_DIR" \
--branch="master"
cd ..
VERSION=$(readJsonProp "package.json" "version")

gulp docs --doc-version="$VERSION_NAME"
cd $SITE_DIR

CHANGES=$(git status --porcelain)

# if no changes, don't commit
if [[ "$CHANGES" == "" ]]; then
ls
echo "-- No changes detected in docs for $VERSION_NAME; docs not updated."
else
git add -A
git commit -am "docs: update for $VERSION"
git push origin master

echo "-- Updated docs for $VERSION_NAME succesfully!"
fi

}

source $(dirname $0)/../utils.sh.inc
9 changes: 5 additions & 4 deletions scripts/docs/dgeni-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var path = require('path');
var semver = require('semver');
var fs = require('fs');
var _ = require('lodash');
var config = require('../config.json');

// Define the dgeni package for generating the docs
module.exports = function(currentVersion){
Expand Down Expand Up @@ -44,7 +45,7 @@ module.exports = function(currentVersion){

.config(function(renderDocsProcessor, computePathsProcessor, versionInfo) {
try {
versions = fs.readdirSync(path.resolve(__dirname, '../../dist/ionic-site/docs/v2/'))
versions = fs.readdirSync(path.resolve(__dirname, '../../' + config.docsDest + '/'))
.filter(semver.valid)
} catch(e) {
versions = [];
Expand All @@ -66,7 +67,7 @@ module.exports = function(currentVersion){
//Latest version is in docs root
var folder = version == latestVersion ? '' : version;
return {
href: path.join('/docs/v2', folder),
href: path.join('/' + config.v2DocsDir, folder),
folder: folder,
name: version
};
Expand All @@ -89,7 +90,7 @@ module.exports = function(currentVersion){
// remove filename since we have multiple docTypes per file
docPath = docPath.substring(0, docPath.lastIndexOf('/') + 1);
docPath += doc.name + '/index.md';
var path = 'docs/v2/' + (versionData.current.folder || '') +
var path = config.v2DocsDir + '/' + (versionData.current.folder || '') +
'/api/' + docPath;

return path;
Expand Down Expand Up @@ -127,7 +128,7 @@ module.exports = function(currentVersion){

// Configure file writing
.config(function(writeFilesProcessor) {
writeFilesProcessor.outputFolder = 'dist/ionic-site'
writeFilesProcessor.outputFolder = config.sitePath;
})

// Configure rendering
Expand Down
12 changes: 6 additions & 6 deletions scripts/docs/gulp-tasks.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

var config = require('../config.json');
module.exports = function(gulp, flags) {
gulp.task('docs', ['docs.demos'], function() {
var Dgeni = require('dgeni');
Expand Down Expand Up @@ -28,7 +28,7 @@ module.exports = function(gulp, flags) {
'!dist/src',
'!dist/src/**/*'
])
.pipe(gulp.dest('dist/ionic-site/docs/v2/dist'));
.pipe(gulp.dest(config.docsDest + '/dist'));
});

gulp.task('docs.index', function() {
Expand Down Expand Up @@ -56,7 +56,7 @@ module.exports = function(gulp, flags) {
refId++;
}

var docPath = 'dist/ionic-site/docs/v2';
var docPath = config.docsDest;
gutil.log('Reading docs from', gutil.colors.cyan(docPath));

return gulp.src([
Expand All @@ -68,7 +68,7 @@ module.exports = function(gulp, flags) {
var contents = file.contents.toString(); //was buffer

// Grab relative path from ionic-site root
var relpath = file.path.replace(RegExp('^.*?' + docPath.replace('/docs/v2', '') + '/'), '');
var relpath = file.path.replace(RegExp('^.*?' + docPath.replace('/' + config.v2DocsDir, '') + '/'), '');

// Read out the yaml portion of the Jekyll file
var yamlStartIndex = contents.indexOf('---');
Expand Down Expand Up @@ -179,7 +179,7 @@ module.exports = function(gulp, flags) {
entities = new Entities();

var variables = [];
var outputFile = 'dist/ionic-site/docs/v2/data/sass.json';
var outputFile = config.docsDest + '/data/sass.json';

// Add the variable to the array, encode the html and remove !default from the value
function addVariable(variableName, defaultValue, file) {
Expand Down Expand Up @@ -225,7 +225,7 @@ module.exports = function(gulp, flags) {
callback();
}).on('end', function() {
gutil.log("Writing to file at", gutil.colors.cyan("/driftyco/ionic2/" + outputFile));
gutil.log("Place this file in", gutil.colors.cyan("/driftyco/ionic-site/docs/v2/theming/overriding-ionic-variables/"), "in order to update the docs");
gutil.log("Place this file in", gutil.colors.cyan("/driftyco/ionic-site/" + config.v2DocsDir + "/theming/overriding-ionic-variables/"), "in order to update the docs");
fs.writeFileSync(outputFile, JSON.stringify(variables));
}));
});
Expand Down
26 changes: 26 additions & 0 deletions scripts/git/clone.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

ARG_DEFS=(
"--repository=(.*)"
"--directory=(.*)"
"[--depth=(.*)]"
"[--branch=(.*)]"
)

function run {
rm -rf $DIRECTORY
mkdir -p $DIRECTORY

echo "-- Cloning $REPOSITORY#$BRANCH to $DIRECTORY..."

ARGS="--branch=${BRANCH:-master}"
if [[ "$DEPTH" != "" ]]; then
ARGS="$ARGS --depth=$DEPTH"
fi
git clone https://driftyco:$GH_TOKEN@github.com/$REPOSITORY $DIRECTORY $ARGS
cd $DIRECTORY
git fetch origin --tags
cd ../
}

source $(dirname $0)/../utils.sh.inc
Loading

0 comments on commit 6d45974

Please sign in to comment.