Bad Output in AWS CodeBuild running Cypress with docker-compose
See original GitHub issueCurrent behavior:
Running CI in CodePipeline, the CodeBuild step runs on our PRs. Just trying to get a dummy e2e cypress test running. The output looks terrible. I’ve tried NO_COLOR=1
and find that no matter how/where I introduce it my cypress run
containerized output ALWAYS has color in it. I can’t even figure out exactly the right way to do it because I can’t test it locally, it never works.
Desired behavior:
I want this output to be legible, to appear exactly as it does when I run this docker-compose command on my Mac locally:
Test code to reproduce
Command: docker-compose -f docker-compose.poc-e2e.yml up --abort-on-container-exit -exit-code-from e2e
docker-compose.poc-e2e.yml
contents:
version: '3.7'
networks:
test:
ipam:
config:
- subnet: 10.0.0.0/24
services:
webtestapp:
image: nginx:1.17.9-alpine
restart: always
networks:
test:
ipv4_address: 10.0.0.20
e2e:
image: cypress/included:4.5.0
container_name: cypress_e2e
networks:
test:
depends_on:
- webtestapp
command: NO_COLOR=1 cypress run
environment:
- CI=True
- CYPRESS_BASE_URL=http://cy.exampleapp.com
working_dir: /tests
volumes:
- ./e2e:/tests
extra_hosts:
- "cy.exampleapp.com:10.0.0.20"
Single spec Cypress test, in integration folder on host:
describe('Visit example containerized HTTP site', () => {
it('Visits http://cy.exampleapp.com as proof of concept for dockerized cypress', () => {
cy.visit('').contains('Welcome to nginx!')
})
})
This all runs on CodeBuild, here is a sanitized version of the buildspec.yml
file to protect our project’s code, but everything needed for this proof-of-concept is here.
Note having to pre-pull the cypress/included:4.5.0
, reference with another “pull” in the build before running the test was all found to be needed- this works around an issue where the pull or container builds would just hang indefinitely. In reality we have to pull the Cypress image from a local private registry, we could not get it to pull from your Docker Hub without hanging, so you might have to replace references to “cypress/included:4.5.0” with refs to the same image stored locally in your AWS image registry.
We are willing to try to work around the container pull issues and use caching or our private registry, but there is no point with this output like this. We absolutely need the output from Cypress to be legible here. Here is the buildspec.yml
for you to try in your own CodeBuild on AWS:
version: 0.2
# Buildspec reference
# https ://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html#build-spec-ref-example
env:
NO_COLOR=1
phases:
install:
runtime-versions:
nodejs: 12 # cannot specify finer grained than this TODO run tests in docker
pre_build:
commands:
- ./pipeline/ecr_login.sh
- "docker pull cypress/include:4.5.0"
- ./pipeline/npm_install.sh
build:
commands:
- "docker-compose -f docker-compose.poc-e2e.yml pull"
- "docker-compose -f docker-compose.poc-e2e.yml up --abort-on-container-exit --exit-code-from e2e"
Setting NO_COLOR=1
as an environment variable doesn’t work, setting it on the command in the docker-compose
file doesn’t work - doesn’t resolve the bad output on AWS but more tellingly does not even remove the color from my local output when I run the docker-compose command on my Mac. Seems broken to me.
I feel like the setting in the docker-compose “command” line should work, because if I run:
command: NO_COLOR=1 cypress run --browser=chrome
then the test runs in chrome locally. The colors on the output still appear, so it really seems like “NO_COLOR=1” is just being ignored. I am not even sure that it is the colors messing with the CodeBuild output, but that’s the closest example to my output that I’ve seen in your repo’s issues.
Versions
cypress/include:4.5.0, electron browser internal to that image; chrome browser internal to that image.
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (2 by maintainers)
Top GitHub Comments
Can you try passing
Got this working with cypress/base:14.0.0, and it seems also works with cypress/included:4.6.0. Closing as resolved.