-
Notifications
You must be signed in to change notification settings - Fork 0
/
grisp.yml
121 lines (118 loc) · 5.44 KB
/
grisp.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
version: 2.1
description: This orb is a collection of commands to setup Erlang and Rebar3 for use with GRiSP.
commands:
install-erlang:
description: Build and install Erlang with asdf from source
parameters:
version:
type: string
description: Erlang version to build (must be available in asdf)
default: "21.0"
steps:
- run: 'zypper install -y --type pattern devel_basis devel_C_C++'
- run: 'zypper install -y git tar gzip wget curl libopenssl-devel openssl'
- run: "echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.bashrc && \
echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc"
- restore_cache:
keys:
- v0.1-asdf-otp
- run: 'if cd ~/.asdf; then git pull origin master; else git clone https://github.com/asdf-vm/asdf.git ~/.asdf; fi'
- run:
command: 'git checkout "$(git describe --abbrev=0 --tags)"'
working_directory: ~/.asdf
- run: 'source ~/.bashrc &&
if [ $(asdf plugin-list | grep -c "erlang") -eq 0]; then asdf plugin-add erlang &&
asdf install erlang << parameters.version >>; fi'
- run: 'source ~/.bashrc && asdf global erlang << parameters.version >>'
- save_cache:
paths:
- /root/.asdf
key: v0.1-asdf-otp
install-rebar3:
description: Download and install rebar3 and configure the grisp plugin
parameters:
rebar3-grisp-revision:
type: string
description: Revision of rebar3-plugin to use, if not set use latest version from hex.pm
default: ""
steps:
- run:
command: "wget https://s3.amazonaws.com/rebar3/rebar3"
working_directory: /root/bin
- run: chmod +x /root/bin/rebar3
- run: echo 'export PATH=$HOME/bin/:$PATH' >> ~/.bashrc
- run: mkdir -p ~/.config/rebar3
- when:
condition: <<parameters.rebar3-grisp-revision>>
steps:
- run: "echo '{plugins, [rebar3_hex, {rebar3_grisp, {git, \"https://github.com/grisp/rebar3_grisp.git\", {ref, \"<< parameters.rebar3-grisp-revision >>\"}}}]}.' >> ~/.config/rebar3/rebar.config"
- unless:
condition: <<parameters.rebar3-grisp-revision>>
steps:
- run: "echo '{plugins, [rebar3_hex, rebar3_grisp]}.' >> ~/.config/rebar3/rebar.config"
install-toolchain:
description: Downloads and installs a prebuilt toolchain binary.
parameters:
toolchain-revision:
type: string
description: Toolchain revision to use, if not set use latest master
default: ""
steps:
- when:
condition: <<parameters.toolchain-revision>>
steps:
- run: echo 'export GRISP_TOOLCHAIN_REVISION="<< parameters.toolchain-revision >>"' >> $BASH_ENV
- unless:
condition: <<parameters.toolchain-revision>>
steps:
- run:
command: echo "export GRISP_TOOLCHAIN_REVISION=$(git ls-remote -h https://github.com/nextl00p/grisp-software master | awk '{print $1}')" >> $BASH_ENV
- run:
name: Download toolchain
command: "wget https://s3.amazonaws.com/grisp/platforms/grisp_base/toolchain/grisp_toolchain_arm-rtems5_Linux_${GRISP_TOOLCHAIN_REVISION}.tar.gz"
working_directory: /tmp
- run: "cd /opt && tar -xzf /tmp/grisp_toolchain*"
create-grisp-project:
description: Creates a new grisp project template
parameters:
build-otp:
type: boolean
description: If set adds a build section pointing to the provided toolchain path
default: false
grisp-repo:
type: string
description: Grisp repo url to use when grisp-revision is set
default: "https://github.com/grisp/grisp.git"
grisp-revision:
type: string
description: Revision of grisp to use, defaults to hex.pm
default: ""
deploy-destination:
type: string
description: Destination where the project should be deployed
steps:
- run: mkdir -p << parameters.deploy-destination >>
- run:
command: "source ~/.bashrc &&
rebar3 new grispapp ciproject dest=<< parameters.deploy-destination >>"
working_directory: /root
- when:
condition: <<parameters.grisp-revision>>
steps:
- run:
name: Change grisp dependency to specified revision
command: REPO=$(echo "<<parameters.grisp-repo>>" | sed s#[email protected]:#https://github.com/#) && sed -i "s#^{deps.*#{deps, [{grisp, {git, \"${REPO}\", {ref, \"<< parameters.grisp-revision >>\"}}}]}.#" rebar.config
working_directory: /root/ciproject
- when:
condition: <<parameters.build-otp>>
steps:
- run:
name: Add build section to rebar.config of our project
command: "source ~/.bashrc &&
TC_PATH=( /opt/grisp/grisp-software/grisp-base/*/rtems-install/rtems/5 ) &&
erl -noshell -eval '{ok, Config} = file:consult(\"rebar.config\"),
{value, {grisp, GrispConfig}} = lists:keysearch(grisp, 1, Config),
NewGrispConfig = GrispConfig ++ [{build, [{toolchain, [{directory, \"'${TC_PATH[@]}'\"}]}]}],
NewConfig = lists:keyreplace(grisp, 1, Config, {grisp, NewGrispConfig}),
file:write_file(\"rebar.config\", lists:map(fun (E) -> io_lib:format(\"~p.~n\", [E]) end, NewConfig)).' -s init stop"
working_directory: /root/ciproject