-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy path.gitlab-ci.yml
89 lines (79 loc) · 2.59 KB
/
.gitlab-ci.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
image: docker/compose:latest
.before_script: &before_script
- apk add jq
- cd tests
- echo "$ENV" > .env
- echo "$CYPRESS_ENV_JSON" > cypress.env.json
before_script:
- *before_script
services:
- docker:dind
stages:
- test
.app_tests:
except:
- merge_requests
script:
# Start containers
- docker-compose up -d
# Fix permissions of custom apps folder
- docker exec $(docker ps -qf "name=app") sh -c 'chown www-data:root custom_apps'
# Disable first run wizard app when nextcloud is up
- sleep 30
- docker exec -u www-data $(docker ps -qf "name=app") sh -c 'php -f ./occ app:disable firstrunwizard'
# Get the IP of the web container
- export SERVER_IP=$(docker container inspect -f '{{ .NetworkSettings.Networks.tests_default.IPAddress }}' $(docker ps -qf "name=web"))
# Run tests in cypress container
- docker run --network tests_default -v $CI_BUILDS_DIR/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:$CI_BUILDS_DIR/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME -w $CI_BUILDS_DIR/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME cypress/browsers:node18.12.0-chrome107 sh -c "cd tests && npm ci && export CYPRESS_NC_VERSION=$NC_VERSION && npm test -- --config baseUrl=http://$SERVER_IP"
artifacts:
expire_in: 1 week
when: always
paths:
- tests/cypress/screenshots
- tests/cypress/videos
- tests/nextcloud.log
reports:
junit:
- tests/results/TEST-*.xml
after_script:
- cd tests
# Echo log file for debug purposes
- docker exec $(docker ps -qf "name=app") sh -c 'cat data/nextcloud.log' > nextcloud.log
- cat nextcloud.log | jq .message
# Shut down containers
- docker-compose down -v
app_test_nc_25:
extends: .app_tests
before_script:
- sed -i "s#nextcloud:27-fpm-alpine#nextcloud:25-fpm-alpine#g" tests/docker-compose.yml
- export NC_VERSION=25
- *before_script
app_test_nc_26:
extends: .app_tests
before_script:
- sed -i "s#nextcloud:27-fpm-alpine#nextcloud:26-fpm-alpine#g" tests/docker-compose.yml
- export NC_VERSION=26
- *before_script
app_test_nc_27:
extends: .app_tests
before_script:
- export NC_VERSION=27
- *before_script
app_test_nc_28:
extends: .app_tests
before_script:
- sed -i "s#nextcloud:27-fpm-alpine#nextcloud:28-fpm-alpine#g" tests/docker-compose.yml
- export NC_VERSION=28
- *before_script
unit_tests:
image: node:14
except:
- merge_requests
before_script:
# Navigate to main folder
- cd $CI_BUILDS_DIR/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME
# Install dependencies
- npm ci
script:
# Run jest tests
- npm run test