question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bad Output in AWS CodeBuild running Cypress with docker-compose

See original GitHub issue

Current 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.

image

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:

image

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:closed
  • Created 3 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jennifer-shehanecommented, May 7, 2020

Can you try passing

env:
  variables:
    NO_COLOR: 1
    TERM: "xterm-mono"
0reactions
stuarth-inovacommented, May 21, 2020

Got this working with cypress/base:14.0.0, and it seems also works with cypress/included:4.6.0. Closing as resolved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Run Docker-Compose On Aws Codebuild? - ADocLib
The example below is basic CI setup and job using the AWS CodeBuild to run Cypress tests within Testing in Chrome and Firefox...
Read more >
cypress-io/cypress - Gitter
Hello, I'm using "cypress run " and my utility.js files are treated as if they would be .spec files so cypress is trying...
Read more >
AWS CodeBuild vs Docker Compose | What are the differences?
AWS CodeBuild belongs to "Continuous Integration" category of the tech stack, while Docker Compose can be primarily classified under "Container Tools".
Read more >
Changelog - Cypress Documentation
Before this change, a spec was scaffolded with either the wrong spec name or the incorrect component import which led to invalid JS...
Read more >
Recently Active 'aws-codebuild' Questions - Page 4
I have a CodeBuild project that pulls an image from a public Docker repository. I'm running into the known issue of too many...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found