-
Notifications
You must be signed in to change notification settings - Fork 8
35 lines (31 loc) · 1.59 KB
/
test.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
name: Unit tests and docker build
on: ["push", "pull_request"]
jobs:
build:
if: github.repository == 'genouest/genouestaccountmanager'
runs-on: self-hosted
steps:
- uses: actions/checkout@v1
- name: Run unit tests
run: |
echo "Path: ${GITHUB_WORKSPACE}"
cd $GITHUB_WORKSPACE && sudo rm -rf manager2/dist
cd $GITHUB_WORKSPACE && sudo rm -rf tests/home_dir tests/cron
mkdir -p manager2/dist
npm install
eslint routes
eslint core
sudo docker build -t osallou/my .
cd $GITHUB_WORKSPACE/cron && sudo docker build -f Dockerfile-cron -t osallou/mycron .
cd $GITHUB_WORKSPACE/tests && sudo docker-compose up -d
cd $GITHUB_WORKSPACE/tests && for i in {10..0}; do echo Try $i; sleep 30; sudo docker-compose logs my-app | grep "Server listening on port 3000"; if [ $? -eq 0 ] ; then echo Server is started; nb_done=$(sudo docker-compose exec -T my-app ls -l /opt/my/scripts/ | grep admin | grep 'update.done' | wc -l); if [ $nb_done -eq 2 ] ; then echo Admin user created; break; fi; fi; if [ $i -eq 0 ]; then echo Server does not start; exit 1; fi; done
cd $GITHUB_WORKSPACE && sudo docker ps && mocha -b -t 20000 --full-trace
cd $GITHUB_WORKSPACE/tests && sudo docker-compose logs my-app
- name: Cleanup
if: always()
run: |
cd $GITHUB_WORKSPACE/tests && sudo docker-compose down
cd $GITHUB_WORKSPACE && sudo rm -rf manager2/dist
cd $GITHUB_WORKSPACE && sudo rm -rf tests/home_dir tests/cron
sudo docker system prune -f
sudo docker volume prune -f