File tree 5 files changed +114
-11
lines changed
5 files changed +114
-11
lines changed Original file line number Diff line number Diff line change 1
1
FROM node:14-slim as npm
2
2
3
- ARG SKIP_TESTS='false'
4
- ENV CI=true
5
-
6
3
ENV APP_HOME=/home/app/stack
7
4
RUN mkdir -p $APP_HOME
8
5
WORKDIR $APP_HOME
9
6
7
+ ARG SKIP_TESTS='false'
8
+ ENV CI=true
9
+
10
10
COPY . .
11
11
COPY ./.cspell.json .
12
12
13
13
RUN if [ "$SKIP_TESTS" = 'false' ]; then \
14
14
npm install cspell && npm run spellcheck; fi
15
15
16
16
# -----------------------------
17
- FROM otomi/tools:1.4.10 as prod
18
-
19
- ARG SKIP_TESTS='false'
20
- ENV CI=true
17
+ FROM otomi/tools:1.4.10 as test
21
18
22
19
ENV APP_HOME=/home/app/stack
23
20
RUN mkdir -p $APP_HOME
24
21
WORKDIR $APP_HOME
25
22
23
+ ARG SKIP_TESTS='false'
24
+ ENV CI=true
25
+
26
26
COPY . .
27
27
28
28
RUN if [ "$SKIP_TESTS" = 'false' ]; then \
29
29
cp -r .demo/ env/ && \
30
30
bin/validate-values.sh && \
31
31
bin/validate-templates.sh && \
32
- rm -rf env/*; fi
32
+ bats bin/tests; fi
33
+
34
+ # -----------------------------
35
+ FROM otomi/tools:1.4.10 as prod
36
+
37
+ ENV APP_HOME=/home/app/stack
38
+ RUN mkdir -p $APP_HOME
39
+ WORKDIR $APP_HOME
40
+
41
+ COPY . .
33
42
34
43
CMD ["bin/otomi" ]
Original file line number Diff line number Diff line change 11
11
fi
12
12
13
13
has_otomi=' false'
14
- skip_demo_files=${1-' false' }
15
14
[ -f $ENV_DIR /bin/otomi ] && has_otomi=' true'
16
15
17
16
function generate_loose_schema() {
44
43
for f in ' .gitignore' ' .prettierrc.yml' ' README.md' ; do
45
44
cp $PWD /.values/$f $ENV_DIR /
46
45
done
47
- if [ " $skip_demo_files " = " false " ]; then
48
- echo " Installing demo files"
46
+ if [ -z " $( ls -A $ENV_DIR /env ) " ]; then
47
+ echo " No files found in env, installing demo files"
49
48
cp -r $PWD /.demo/env $ENV_DIR /env
50
49
fi
51
50
cp -f $PWD /bin/hooks/pre-commit $ENV_DIR /.git/hooks/
Original file line number Diff line number Diff line change
1
+ #! /usr/local/bin/bats
2
+
3
+ lib_dir=" /usr/local/lib"
4
+
5
+ load " $lib_dir /bats-support/load.bash"
6
+ load " $lib_dir /bats-assert/load.bash"
7
+ load " $lib_dir /bats-file/load.bash"
8
+
9
+ setup () {
10
+ test_temp_dir=" $( temp_make --prefix " otomi-values-" ) "
11
+ export ENV_DIR=" $test_temp_dir "
12
+ }
13
+
14
+ teardown () {
15
+ temp_del " $test_temp_dir "
16
+ unset ENV_DIR
17
+ }
18
+
19
+ @test " executing bootstrap.sh should pass with new ENV_DIR (otomi-values) folder" {
20
+ git init " $ENV_DIR "
21
+ run bin/bootstrap.sh
22
+ assert_success
23
+ }
24
+
25
+ @test " executing bootstrap.sh should fail without new ENV_DIR (otomi-values) folder" {
26
+ unset ENV_DIR
27
+ run bin/bootstrap.sh
28
+ assert_failure
29
+ }
30
+
31
+ @test " executing bootstrap.sh multiple times should pass with new ENV_DIR (otomi-values)" {
32
+ git init " $test_temp_dir "
33
+ bin/bootstrap.sh
34
+ run bin/bootstrap.sh
35
+ assert_success
36
+ }
Original file line number Diff line number Diff line change
1
+ #! /usr/local/bin/bats
2
+
3
+ lib_dir=" /usr/local/lib"
4
+
5
+ load " $lib_dir /bats-support/load.bash"
6
+ load " $lib_dir /bats-assert/load.bash"
7
+ load " $lib_dir /bats-file/load.bash"
8
+
9
+ setup () {
10
+ test_temp_dir=" $( temp_make --prefix ' otomi-values-' ) "
11
+ export ENV_DIR=" $test_temp_dir "
12
+ env_path=" $ENV_DIR /env"
13
+ }
14
+
15
+ teardown () {
16
+ temp_del " $test_temp_dir "
17
+ unset ENV_DIR
18
+ unset env_path
19
+ }
20
+
21
+ @test " the env folder should not be overwritten" {
22
+ git init " $ENV_DIR "
23
+ cluster_path=" $env_path /clusters.yaml"
24
+ mkdir -p " $env_path " && touch $cluster_path && echo " clouds: please-do-not-remove" > $cluster_path
25
+ bin/bootstrap.sh
26
+
27
+ assert_file_not_exist " $env_path /charts"
28
+ assert_file_not_exist " $env_path /clouds"
29
+ assert_file_not_exist " $env_path /teams"
30
+ }
31
+
32
+ @test " the env folder should be created after bootstrap.sh" {
33
+ git init " $ENV_DIR "
34
+ bin/bootstrap.sh
35
+
36
+ assert_file_exist " $env_path /charts"
37
+ assert_file_exist " $env_path /clouds"
38
+ assert_file_exist " $env_path /teams"
39
+ }
Original file line number Diff line number Diff line change @@ -18,6 +18,12 @@ ARG KUBEVAL_VERSION=0.15.0
18
18
19
19
ARG HELM_FILE_NAME=helm-${HELM_VERSION}-linux-amd64.tar.gz
20
20
21
+ # https://github.com/ztombol/bats-assert/releases https://github.com/ztombol/bats-support
22
+ ARG BATS_VERSION=1.2.1
23
+ ARG BATS_ASSERT_VERSION=0.3.0
24
+ ARG BATS_SUPPORT_VERSION=0.3.0
25
+ ARG BATS_FILE_VERSION=0.2.0
26
+
21
27
WORKDIR /
22
28
23
29
RUN apt-get update -qq \
@@ -80,6 +86,20 @@ RUN curl -sL https://deb.nodesource.com/setup_lts.x | bash -
80
86
RUN apt-get install -y nodejs && \
81
87
npm install -g ajv-cli
82
88
89
+ # bats
90
+ ADD https://codeload.github.com/bats-core/bats-core/tar.gz/v${BATS_VERSION} /tmp
91
+ RUN tar -zxvf /tmp/v${BATS_VERSION} -C /tmp && /tmp/bats-core-${BATS_VERSION}/install.sh /usr/local
92
+
93
+ # bats libs
94
+ ADD https://codeload.github.com/ztombol/bats-assert/tar.gz/v${BATS_ASSERT_VERSION} /tmp
95
+ RUN tar -zxvf /tmp/v${BATS_ASSERT_VERSION} -C /tmp && mv /tmp/bats-assert-${BATS_ASSERT_VERSION} /usr/local/lib/bats-assert
96
+
97
+ ADD https://codeload.github.com/ztombol/bats-support/tar.gz/v${BATS_SUPPORT_VERSION} /tmp
98
+ RUN tar -zxvf /tmp/v${BATS_SUPPORT_VERSION} -C /tmp && mv /tmp/bats-support-${BATS_SUPPORT_VERSION} /usr/local/lib/bats-support
99
+
100
+ ADD https://codeload.github.com/ztombol/bats-file/tar.gz/v${BATS_FILE_VERSION} /tmp
101
+ RUN tar -zxvf /tmp/v${BATS_FILE_VERSION} -C /tmp && mv /tmp/bats-file-${BATS_FILE_VERSION} /usr/local/lib/bats-file
102
+
83
103
RUN chown -R app:app /home/app
84
104
USER app
85
105
You can’t perform that action at this time.
0 commit comments