Skip to content

Commit 377493c

Browse files
author
Igor Komlew
authored
Run frontend tests only on change in webapp-admin directory (#317)
* Run frontend tests only on change in webapp-admin directory * added some documentaion
1 parent eee89f4 commit 377493c

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ dist: focal
33
jobs:
44
include:
55
- stage: test
6-
name: "Golang build and test"
6+
name: "Golang build and tests"
77
language: go
88
env:
99
- GO111MODULE=on
@@ -16,11 +16,11 @@ jobs:
1616
- make test
1717

1818
- stage: test
19-
name: "Node.js test"
19+
name: "Node.js tests"
2020
language: node_js
2121
node_js:
2222
- lts/*
2323
env:
2424
- NODE_ENV=test
2525
script:
26-
- make test-frontend
26+
- make test-frontend-ci

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,22 @@ build-frontend:
152152

153153
.PHONY: test-frontend
154154
test-frontend:
155+
NODE_ENV=test cd webapp-admin && \
156+
npm install && \
157+
npm install -g codecov && \
158+
npm run test
159+
160+
IS_WEB_BUILD=$(shell ./web-build.sh)
161+
.PHONY: test-frontend-ci
162+
test-frontend-ci:
163+
ifneq (, $(IS_WEB_BUILD))
164+
@echo "run frontend tests"
165+
@echo $(IS_WEB_BUILD)
155166
NODE_ENV=test cd webapp-admin && \
156167
npm install && \
157168
npm install -g codecov && \
158169
npm run test:ci
170+
endif
159171

160172
# run application/db in docker
161173
.PHONY: run-docker

web-build.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
#
3+
# This script is used from the Makefile/TravisCI in order to find out if
4+
# some changes where done in webapp-admin/ directory or not.
5+
# In the positive case Makefile will run frontend tests from webapp-admin/ directory.
6+
7+
set -e
8+
9+
CHANGED_FILES=`git diff --name-only master`
10+
IS_WEB_BUILD=False
11+
WEB_PATH="webapp-admin/*"
12+
13+
for CHANGED_FILE in $CHANGED_FILES; do
14+
if [[ $CHANGED_FILE =~ $WEB_PATH ]]; then
15+
IS_WEB_BUILD=True
16+
break
17+
fi
18+
done
19+
20+
if [[ $IS_WEB_BUILD == True ]]; then
21+
echo "yes"
22+
fi

0 commit comments

Comments
 (0)