cypress-io / cypress-example-kitchensink

This is an example app used to showcase Cypress.io testing.
https://example.cypress.io/
MIT License
1.2k stars 2.2k forks source link

Setup for Concourse CI #256

Open jennifer-shehane opened 5 years ago

jennifer-shehane commented 5 years ago

We've had a couple people inquire about running in Concourse CI, especially with parallel runs. Would be nice to get an example.

Also, collecting CI env vars in the test runner will likely be helpful https://github.com/cypress-io/cypress/issues/4376

eaustin commented 4 years ago

Are there any updates on this?

bahmutov commented 4 years ago

No @eaustin - if there is a commercial ConcourseCI hosting that we can turn on, we would be happy to

smccormack-kr commented 4 years ago

Would also be interested if there are any updates on this. When I try to run cypress with parallel runs for concourse, I get a response of it not being able to determine the ciBuildId. But I see concourse listed under the list for "The ciBuildId is automatically detected if you are running Cypress in any of the these CI providers"

An example to help implement would be very useful in this case to help me see what I am doing wrong.

pdibenedetto commented 4 years ago

A Concourse Example under the Kitchen Sink project would be extremely valuable for Parallel runs.

EnorMOZ commented 3 years ago

Has anyone got this working?

KadeejaBai commented 3 years ago

Any updates ?? I do get the same error as @smccormack-kr mentioned

opanitch commented 2 years ago

In our Monorepo, we had some additional authentication factors to pass through to Cypress, so to get it working in our Concourse pipeline, I used the following config:

resource_types:
    - name: pull-request
      type: docker-image
      source:
          repository: teliaoss/github-pr-resource

    - name: slack
      type: docker-image
      source:
          repository: cfcommunity/slack-notification-resource
          tag: latest

resources:
    - name: slack
      icon: slack
      type: slack
      source:
          url: ((project.slack_url))

    - name: ((project.resources.test_e2e.name))
      type: time
      source: ((project.resources.test_e2e.source))

    # Merge Resource
    - name: ((project.resources.merge.name))
      icon: github
      type: git
      source:
          uri: ((git-uri))
          branch: ((branch))
          paths: ((project.resources.merge.paths))

jobs:
    # Merge Tasks
    - name: ((project.jobs.test_e2e.name))
      plan:
          - get: ((project.resources.merge.name))
            version: latest
          - get: time-trigger
            trigger: true
          - in_parallel:
                fail_fast: true
                steps:
                    - task: install-repository
                      file: ((project.resources.merge.name))/.concourse/tasks/((project.id))/install-repository.task.yaml
                      input_mapping:
                          ci-src: ((project.resources.merge.name))
                    - task: install-project
                      file: ((project.resources.merge.name))/.concourse/tasks/((project.id))/install-project.task.yaml
                      input_mapping:
                          ci-src: ((project.resources.merge.name))
          - task: test-e2e
            file: ((project.resources.merge.name))/.concourse/tasks/((project.id))/test-e2e.task.yml
            input_mapping:
                ci-src: ((project.resources.merge.name))
            params:
                CYPRESS_BASE_URL: ((baseUrl))
                USERNAME: ((e2e-test-username-user))
                PASSWORD: ((e2e-test-password-user))
                CLIENT_SECRET: ((e2e-test-client-secret-my-apps))
      serial: true
      on_abort:
          do:
              - put: slack
                params:
                    channel: ((slack-channel))
                    text: |
                        <!channel> ((project.name)) e2e-testing aborted
                        ((concourse-url))/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME
      on_error:
          do:
              - put: slack
                params:
                    channel: ((slack-channel))
                    text: |
                        <!channel> Task error when running e2e testing for ((project.name))
                        ((concourse-url))/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME
      on_failure:
          do:
              - put: slack
                params:
                    channel: ((slack-channel))
                    text: |
                        <!channel> e2e tests Failed for ((project.name))
                        ((concourse-url))/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME
      on_success:
          do:
              - put: slack
                params:
                    channel: ((slack-channel))
                    text: |
                        ((project.name)) e2e tests have successfully passed
                        ((concourse-url))/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME

task:

---
platform: linux

image_resource:
    type: docker-image
    source:
        repository: cypress/base

inputs:
    - name: ci-src
    - name: ci-src/node_modules
    - name: ci-src/projects/my-apps-ui/node_modules

run:
    dir: ci-src
    path: .concourse/tasks/my-apps-ui/test-e2e.task.sh

script:

#!/bin/bash

if [ $? -ne 0 ]; then
    exit 1
fi

pushd projects/my-apps-ui \
    && npx cypress install \
    && npm run test-e2e -- --config baseUrl=$CYPRESS_BASE_URL  --env username=$USERNAME,password=$PASSWORD,clientSecret=$CLIENT_SECRET
trainoasis commented 2 years ago

@opanitch how's parallelization handled in your code? What have I missed?