I want to run my cypress.io tests in CI (Teamcity) by scheduled timers. Tests will be run very frequently that is why I am interesting to execute them as quick as possible This is my current implementation. I run teamcity-server with 3 teamcity-agents with the following docker-compose.yml
version: "3"
services:
server:
image: jetbrains/teamcity-server:2020.1.2
ports:
- "8112:8111"
volumes:
- ./data_dir:/data/teamcity_server/datadir
- ./log_dir:/opt/teamcity/logs
teamcity-agent-1:
image: jetbrains/teamcity-agent:2020.1.2-linux-sudo
environment:
- SERVER_URL=http://server:8111
- AGENT_NAME=docker-agent-1
- DOCKER_IN_DOCKER=start
privileged: true
container_name: docker_agent_1
teamcity-agent-2:
image: jetbrains/teamcity-agent:2020.1.2-linux-sudo
environment:
- SERVER_URL=http://server:8111
- AGENT_NAME=docker-agent-2
- DOCKER_IN_DOCKER=start
privileged: true
container_name: docker_agent_2
teamcity-agent-3:
image: jetbrains/teamcity-agent:2020.1.2-linux-sudo
environment:
- SERVER_URL=http://server:8111
- AGENT_NAME=docker-agent-3
- DOCKER_IN_DOCKER=start
privileged: true
container_name: docker_agent_3
And in building steps I am using node:10.18.1 in settings as per screen below: enter image description here
My buildings steps are following now:
1.
npm install yarn --no-save
yarn install --no-lockfile
#!/bin/bash
set -e -x
export CYPRESS_CACHE_FOLDER="%env.cypress_cache_path%"
export CYPRESS_VAR1=%env.var1%
export CYPRESS_VAR2=%env.var2%
apt-get update && apt-get -y install libgtk2.0-0 libgtk-3-0 libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb
yarn silent --spec "%env.cypress_path_to_landing_pages%"
- yarn generate:html:report
This is I need to run for every time I execute tests and it takes around 10 mins to execute each test set taking 60-70% time on installation of all dependencies which are
{
"@types/mocha": "^8.0.0",
"cypress": "4.11.0",
"cross-env": "^7.0.2",
"mocha": "^7.2.0",
"mochawesome": "^6.1.1",
"mochawesome-merge": "^4.1.0",
"mochawesome-report-generator": "^5.1.0",
"typescript": "^3.9.6"
}
- apt-get install xvfb libgtk-3-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 (which I need to install extra for linux) I do belieave that main heavy dependency are cypress and xvfb packages.
I see 3 ways how to avoid this huge execution time:
- to have a docker image compatible with teamcity containing all cypress ENV: node, cypress, xvfb etc. In that case I do not need to install it every time I run tests. I was following cypress documentation and aware that special docker images are designed for that https://github.com/cypress-io/cypress-docker-images
cypress/base
cypress/browsers
cypress/included
But they are not compatible with Teamcity server (Teamcity agents need to have a java wrapper) or I dont know how to run them from docker-compose.yml I tried this but TeamCity server was not able to find this agent and agents tab was empty
version: "3"
services:
server:
image: jetbrains/teamcity-server:2020.1.2
ports:
- "8112:8111"
volumes:
- ./data_dir:/data/teamcity_server/datadir
- ./log_dir:/opt/teamcity/logs
teamcity-agent-2:
image: cypress/included:3.4.0
environment:
- SERVER_URL=http://server:8111
- AGENT_NAME=docker-agent-2
- DOCKER_IN_DOCKER=start
privileged: true
container_name: docker_agent_2
To cache node_modules and xvfb somehow. I see https://cypress.slides.com/cypress-io/cypress-on-ci#/5/2/0 but can not understand how to put it in my building steps
Setup building dependencies in TeamCity and install all dependencies once in one build and move artifacts (node_modules, xvfb etc) somehow to next build which will run tests by timers.
How I understood cypress documentation myself they are suggesting to follow point 1 from my list but how to run their images as teamcity agents I did not understand
any suggestions are welcome