Skip to content

Commit

Permalink
Add automatic deploy (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
faustinoaq authored May 15, 2018
1 parent ff2c587 commit f156180
Show file tree
Hide file tree
Showing 18 changed files with 145 additions and 102 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
/app/
/lib/
/bin/
/dist/
/.shards/
shard.lock
41 changes: 41 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,44 @@ language: crystal
cache:
directories:
- amber
- dist

env:
- FILENAME=basic_crecto
- FILENAME=basic_granite
- FILENAME=default
- FILENAME=misc_modular

script:
- crystal spec "spec/${FILENAME}_spec.cr"

after_success:
- bash "scripts/build_zips.sh"

notifications:
webhooks:
urls:
- https://webhooks.gitter.im/e/8b26d3879e3a6ff4a75c
on_success: change
on_failure: always
on_start: never

before_deploy:
- git tag -f dist
- git remote add gh https://${TRAVIS_REPO_SLUG%/*}:${API_KEY}@github.com/${TRAVIS_REPO_SLUG}.git
- git push -f gh dist
- git remote remove gh

deploy:
provider: releases
api_key: $API_KEY
file: "dist/${FILENAME}.zip"
skip_cleanup: true
name: Amber Framework Recipes
body: Automatic build of $TRAVIS_BRANCH at commit $TRAVIS_COMMIT built on $(date +'%F %T %Z').
prerelease: false
overwrite: true
target_commitish: $TRAVIS_COMMIT
on:
branch: master
repo: amberframework/recipes
32 changes: 20 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ or provides additional features. For example you might want an API application
that only renders JSON or use React or AngularJS for views.

To create an amberframework application from a recipe type;

```sh
amber new <appname> -r <recipe>
```

to create a new amber app from the given named recipe in a folder with the given appname.

The given recipe can be either
Expand All @@ -23,26 +25,31 @@ for more information.
## Available recipes

Recipes in this repository are divided into themes based on the kind of application and scaffolding
generated by the recipe. For example the **basic/granite** recipe mimics the
amber built-in application template using the granite ORM.
generated by the recipe. For example the **basic_granite** recipe mimics the
Amber built-in application template using the Granite ORM.

To create a new amber app from this recipe at the command line type

```sh
amber new newapp -r basic/granite
amber new newapp -r basic_granite
```
to create a new amber app from the recipe at basic/granite in the

to create a new amber app from the recipe at basic_granite in the
folder newapp.

```sh
amber new newapp -r default
```

Uses a copy of the standard built-in template and is the same as typing

```sh
amber new newapp
```

## Using a template in a local folder
You can use a local folder as the source template for a new amber application e.g.

```sh
mkdir default_recipe
wget https://raw.githubusercontent.com/amberframework/recipes/master/dist/default.zip
Expand Down Expand Up @@ -71,14 +78,15 @@ the recipe.

Recipes use the [Liquid template language](https://github.com/TechMagister/liquid.cr).
The file extension should be **.liquid** but if you prefer shorter 3 letter file extensions
you can also use **.lqd** which is an unknown or unnassigned file extension. To create a
new recipe fork https://github.com/amberframework/recipes, clone your fork, create a new
sub folder in the appropriate theme folder (or create a new theme if it doesn't already exist),
extract an existing recipe, make your modifications. To build a zip file for distribution type
```
bash scripts/build_zips.sh
```
Then submit a PR.
you can also use **.lqd** which is an unknown or unnassigned file extension.

### To create a new recipe

1. Fork https://github.com/amberframework/recipes
2. Clone your fork using `git clone`
3. Create a new sub folder in the appropriate theme folder (or create a new theme if it doesn't already exist).
4. Copy an existing recipe and make your modifications.
5. Submit a PR.

Recipes should contain the following templates:

Expand Down
11 changes: 7 additions & 4 deletions basic/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
# Basic recipes

## granite
Recipes with common shards used by Amber Framework

## Granite

The standard built-in recipe but only with support for the Granite ORM
Create a new amber app with this template with the command;

```
amber new mynewapp -r basic/granite
amber new mynewapp -r basic_granite
```

## crecto
## Crecto

The standard built-in recipe but only with support for the Crecto ORM
Create a new amber app with this template with the command;

```
amber new mynewapp -r basic/crecto
amber new mynewapp -r basic_crecto
```
29 changes: 0 additions & 29 deletions damianham/README.md

This file was deleted.

Binary file removed damianham/default.zip
Binary file not shown.
Binary file removed damianham/modular.zip
Binary file not shown.
Binary file removed dist/basic/crecto.zip
Binary file not shown.
Binary file removed dist/basic/granite.zip
Binary file not shown.
Binary file removed dist/default.zip
Binary file not shown.
Binary file removed dist/misc/modular.zip
Binary file not shown.
26 changes: 15 additions & 11 deletions misc/README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
# Misc recipes

These recipes contain shards with new exiting features and structure.

## modular
## Modular

Created by [Damian Hamill](https://github.com/damianham).

A recipe that organises controller, model and views into modules e.g.

- src/modules
- src/modules/post
- src/modules/post/edit.slang
- src/modules/post/_form.slang
- src/modules/post/post_controller.cr
- src/modules/post/show.slang
- src/modules/post/post.cr
- src/modules/post/index.slang
- src/modules/post/new.slang
- `src/modules`
- `src/modules/post`
- `src/modules/post/edit.slang`
- `src/modules/post/_form.slang`
- `src/modules/post/post_controller.cr`
- `src/modules/post/show.slang`
- `src/modules/post/post.cr`
- `src/modules/post/index.slang`
- `src/modules/post/new.slang`

Create a new amber app with this template with the command;

```
amber new mynewapp -r misc/modular
amber new mynewapp -r misc_modular
```
26 changes: 16 additions & 10 deletions scripts/build_zips.sh
Original file line number Diff line number Diff line change
@@ -1,36 +1,42 @@
#!/bin/bash

# for any recipe that has been updated
# rebuild the zip file in dist
# This script is automatically triggered by Travis CI
# for any recipe that has been updated on master.

build_zip() {

echo build_zip $1, $2, $3
mkdir -p $2
dest=`realpath $2`/$3
echo build_zip $1, $2
dest=`pwd`/$2
(cd $1 && zip -r $dest *)
}

check_zip() {
dist=dist/`dirname $1`
zip=`basename $1`
dest=${dist}/${zip}
if [[ `dirname $1` == '.' ]]; then
zip=`basename $1`
else
zip=`dirname $1`_`basename $1`
fi

mkdir -p dist

dest=dist/${zip}

#echo "check_zip" $1, $dist, $zip, $dest
if [ ! -f ${dest}.zip ]; then
build_zip $1 $dist $zip $dest
build_zip $1 $dest
else
result=`find $1 -newer ${dest}.zip`
#echo $result
if [ ! -z "$result" ]; then
build_zip $1 $dist $zip $dest
build_zip $1 $dest
fi
fi
}

find_recipes() {
for f in `find . -path ./lib -prune -o -name 'app' -print`
do
# echo `dirname $f | sed -e 's#./##'`
check_zip `dirname $f | sed -e 's#./##'`
done
}
Expand Down
12 changes: 12 additions & 0 deletions spec/basic_crecto_spec.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require "./recipes_spec"

describe "Basic Crecto" do
# TODO: crecto scaffolding is broken
# the crecto builtin template is also broken
# it "compiles and tests basic/crecto recipe" do
# generate_app recipe: "basic/crecto"
# build_app.should be_true
# ensure
# cleanup
# end
end
11 changes: 11 additions & 0 deletions spec/basic_granite_spec.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require "./recipes_spec"

describe "Basic Granite" do
it "compiles and tests basic/granite recipe" do
generate_app recipe: "basic/granite"
build_app.should be_true
test_app.should be_true
ensure
cleanup
end
end
11 changes: 11 additions & 0 deletions spec/default_spec.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require "./recipes_spec"

describe "Default" do
it "compiles and tests default recipe" do
generate_app recipe: "default"
build_app.should be_true
test_app.should be_true
ensure
cleanup
end
end
11 changes: 11 additions & 0 deletions spec/misc_modular_spec.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require "./recipes_spec"

describe "Misc Modular" do
it "compiles and tests misc/modular recipe" do
generate_app recipe: "misc/modular"
build_app.should be_true
test_app.should be_true
ensure
cleanup
end
end
36 changes: 0 additions & 36 deletions spec/recipes_spec.cr
Original file line number Diff line number Diff line change
@@ -1,39 +1,3 @@
require "./spec_helper"

build_amber

describe "Compile available recipes" do
it "compiles and tests default recipe" do
generate_app recipe: "default"
build_app.should be_true
test_app.should be_true
ensure
cleanup
end

it "compiles and tests basic/granite recipe" do
generate_app recipe: "basic/granite"
build_app.should be_true
test_app.should be_true
ensure
cleanup
end

# TODO: crecto scaffolding is broken
# the crecto builtin template is also broken
# it "compiles and tests basic/crecto recipe" do
# generate_app recipe: "basic/crecto"
# build_app.should be_true
# ensure
# cleanup
# end

it "compiles and tests misc/modular recipe" do
generate_app recipe: "misc/modular"
build_app.should be_true
test_app.should be_true
ensure
cleanup
end

end

0 comments on commit f156180

Please sign in to comment.