-
Notifications
You must be signed in to change notification settings - Fork 2
/
justfile
187 lines (136 loc) · 4.19 KB
/
justfile
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# github.com/MadBomber/justprep/**/justfile
#
# gem install semver2
# Provides for semantic version tracking
#
# brew install just
# Handy way to save and run project-specific commands
# https://github.com/casey/just
#
# brew install direnv
# Load/unload environment variables based on $PWD
# https://direnv.net/
#
# SMELL: Assumes that $RR is defined; well it is if the user
# has direnv installed and its been allowed in this repo
set positional-arguments := true
set allow-duplicate-recipes := true
version_tag := "VERSION"
# relative to the repository root $RR
version_file := "ruby/lib/justprep/common/constants.crb"
# Displays this list of available recipes
help:
#!/usr/bin/env bash
echo
echo "Available Recipes at"
echo `pwd`
echo "are:"
echo
just -l --list-prefix 'just ' --list-heading ''
echo
if [ "" = "$RR" ] ; then
echo "================================================================="
echo "== Set system environment variable 'RR' to the repository root =="
echo "export RR=`pwd`"
echo "================================================================="
fi
# Build both Ruby Gem and Crystal versions
@build: _build_rb _build_cr
# Install both Ruby Gem and Crystal versions
@install: _install_rb _install_cr
###################################################
# Test both the Ruby Gem and the Crystal Executable using JUST
test: _prep build unit_tests test_just
# Testomg the JUST pre-processor
test_just:
#!/usr/bin/env bash
export JUSTPREP_FOR=just
export JUSTPREP_FILENAME_OUT=${JUSTPREP_FOR}file
export RESULT=$RR/test/result_for_${JUSTPREP_FOR}.txt
echo "Integration Tests for JUST ..." > $RESULT
cd $RR/test
source test.s >> $RESULT 2>&1
diff=`diff $RESULT expected_for_${JUSTPREP_FOR}.txt`
if [ "" = "$diff" ] ; then
echo "Tests PASSED"
else
echo "tests FAILED"
echo $diff
fi
# Ruby unit tests on common Crystal/Ruby code
ruby_unit_test:
#!/usr/bin/env bash
original_name=$JUSTPREP_FILENAME_IN
export JUSTPREP_FILENAME_IN=main.just
cd $RR/ruby
echo "Ruby ..."
# redirecting stderr to stdout because of deprecation warnings
rake test 2>&1 |\
fgrep runs |\
fgrep assertions |\
fgrep failures |\
fgrep errors |\
fgrep skips
export JUSTPREP_FILENAME_IN=$original_name
# Crystal unit tests on common Crystal/Ruby code
@crystal_unit_test:
echo "disabled"
#### #!/usr/bin/env bash
#### original_name=$JUSTPREP_FILENAME_IN
#### export JUSTPREP_FILENAME_IN=main.just
####
#### cd $RR/crystal
####
#### echo "Crystal ..."
####
#### crystal run \
#### ../ruby/lib/justprep/common/*.crb \
#### ../ruby/test/common_test.rb |\
#### fgrep tests |\
#### fgrep failures |\
#### fgrep errors |\
#### fgrep skips
####
#### export JUSTPREP_FILENAME_IN=$original_name
# Run the unit tests on the common methods in both implementations
unit_tests: ruby_unit_test crystal_unit_test
#################################################
## Recipes that deal with the source code version
## Version manager is handled by the "semver" gem
# Set the value of VERSION in the constants.crb file
# DO NOT give it a value otherwise semver will freak
_version_set version="`semver format %M.%m.%p`":
#!/usr/bin/env bash
echo "Setting VERSION to {{version}}"
old_version=`grep '^[ \t]*{{version_tag}}' $RR/{{version_file}}`
sed -i -r "s/${old_version}/{{version_tag}} = \"{{version}}\"/" \
$RR/{{version_file}}
# Show current version
@version:
semver format %M.%m.%p %s
# Bump the version. Levels: major, minor, patch
@version_bump level="patch":
semver inc {{level}}
just _version_set
# Release Using Github Workflow/Actions
release:
git tag -f `semver tag`
git push --tags
###########################################
## Hidden Recipes
# Compile the Crystal implementation
@_build_cr:
cd $RR/crystal && just compile
# Build the Ruby Gem
@_build_rb:
cd $RR/ruby && just build
# Install the crystal version to its default directory
@_install_cr:
cd $RR/crystal && just install
# Install the gem version locally
@_install_rb:
cd $RR/ruby && just install
# Oreoare to test the latest build
@_prep: build
rm -f $RR/test/justfile
rm -f $RR/test/result.txt