From e109bf714d549113775df37ba04ca180ce40eb35 Mon Sep 17 00:00:00 2001 From: eduardo aleixo Date: Mon, 3 Jan 2022 16:56:23 -0300 Subject: [PATCH] ci: run cypress against an instance with baseURL --- .github/workflows/cypress-base-url.yml | 49 ++++++++++++++++++++ cypress/base-url/base-url-docker-compose.yml | 7 +++ cypress/base-url/cypress.json | 8 ++++ cypress/base-url/nginx.conf | 12 +++++ package.json | 3 ++ 5 files changed, 79 insertions(+) create mode 100644 .github/workflows/cypress-base-url.yml create mode 100644 cypress/base-url/base-url-docker-compose.yml create mode 100644 cypress/base-url/cypress.json create mode 100644 cypress/base-url/nginx.conf diff --git a/.github/workflows/cypress-base-url.yml b/.github/workflows/cypress-base-url.yml new file mode 100644 index 0000000000..b16a1700a4 --- /dev/null +++ b/.github/workflows/cypress-base-url.yml @@ -0,0 +1,49 @@ +name: Cypress BaseURL Tests + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + cypress-base-url-tests: + runs-on: ubuntu-latest + container: cypress/included:8.6.0 + steps: + - name: Checkout + uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: '^1.17.0' + - name: run nginx with /pyroscope + run: docker-compose -f cypress/base-url/base-url-docker-compose.yml up -d + - name: Cypress run + uses: cypress-io/github-action@v2 + with: + build: make e2e-build + wait-on: http://localhost:8080/pyroscope + start: make server + config-file: cypress/base-url/cypress.json + env: + # keep the server quiet + PYROSCOPE_BASE_URL: 'http://localhost:8080/pyroscope' + PYROSCOPE_LOG_LEVEL: error + ENABLED_SPIES: none + CYPRESS_VIDEO: true + CYPRESS_COMPARE_SNAPSHOTS: true + - uses: actions/upload-artifact@v2 + if: always() + with: + name: cypress-screenshots + path: cypress/screenshots + - uses: actions/upload-artifact@v2 + if: always() + with: + name: cypress-videos + path: cypress/videos + - uses: actions/upload-artifact@v2 + if: always() + with: + name: cypress-snapshots + path: cypress/snapshots diff --git a/cypress/base-url/base-url-docker-compose.yml b/cypress/base-url/base-url-docker-compose.yml new file mode 100644 index 0000000000..23d4c102ac --- /dev/null +++ b/cypress/base-url/base-url-docker-compose.yml @@ -0,0 +1,7 @@ +version: '3' +services: + nginx: + image: nginx + network_mode: host + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf diff --git a/cypress/base-url/cypress.json b/cypress/base-url/cypress.json new file mode 100644 index 0000000000..51a5e63192 --- /dev/null +++ b/cypress/base-url/cypress.json @@ -0,0 +1,8 @@ +{ + "video": false, + "baseUrl": "http://localhost:8080/pyroscope/", + "integrationFolder": "cypress/integration/webapp", + "retries": { + "runMode": 5 + } +} diff --git a/cypress/base-url/nginx.conf b/cypress/base-url/nginx.conf new file mode 100644 index 0000000000..c3de8aac81 --- /dev/null +++ b/cypress/base-url/nginx.conf @@ -0,0 +1,12 @@ +events {} +http { + server { + listen 8080; + + location /pyroscope/ { + rewrite /pyroscope(.*) $1 break; + proxy_pass http://localhost:4040; + } + } +} + diff --git a/package.json b/package.json index 0294317579..4d4fce6a36 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,9 @@ "cy:webapp:ci": "cypress run --config-file webapp/cypress.json", "cy:webapp:ss": "./scripts/cypress-screenshots.sh --config-file webapp/cypress.json", "cy:webapp:ss-check": "CYPRESS_updateSnapshots=false ./scripts/cypress-screenshots.sh --config-file webapp/cypress.json", + "cy:webapp-base-url:open": "cypress open --config-file cypress/base-url/cypress.json", + "cy:webapp-base-url:ci": "cypress run --config-file cypress/base-url/cypress.json", + "cy:webapp-base-url:ss-check": "CYPRESS_updateSnapshots=false ./scripts/cypress-screenshots.sh --config-file cypress/base-url/cypress.json", "cy:panel:open": "cypress open --config-file grafana-plugin/panel/cypress.json", "cy:panel:ci": "cypress run --config-file grafana-plugin/panel/cypress.json", "cy:panel:ss": "./scripts/cypress-screenshots.sh --config-file grafana-plugin/panel/cypress.json",