Skip to content

Commit

Permalink
ci(cypress): improve cypress tests speed (grafana#1270)
Browse files Browse the repository at this point in the history
  • Loading branch information
eh-am authored Jul 15, 2022
1 parent 0db2bca commit c62eda2
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 155 deletions.
69 changes: 0 additions & 69 deletions .github/workflows/cypress-base-url.yml

This file was deleted.

66 changes: 0 additions & 66 deletions .github/workflows/cypress-tests-auth.yml

This file was deleted.

113 changes: 94 additions & 19 deletions .github/workflows/cypress-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ on:
jobs:
cypress-tests:
runs-on: ubuntu-latest
container: cypress/included:8.6.0
env:
ENABLED_SPIES: none
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.17.0'
go-version: '^1.18.0'
- name: Cache go mod directories
uses: actions/cache@v2
with:
Expand All @@ -26,39 +27,113 @@ jobs:
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn
- run: yarn install --frozen-lockfile
- run: make --version
- run: make -j e2e-build
- uses: actions/cache@v3
with:
path: bin/pyroscope
key: ${{ runner.os }}-pyroscope
- name: Cypress run
uses: cypress-io/github-action@v2
uses: cypress-io/github-action@v4
with:
build: make e2e-build
wait-on: http://localhost:4040
start: make server
config-file: cypress/cypress.json
env:
# keep the server quiet
PYROSCOPE_LOG_LEVEL: error
ENABLED_SPIES: none
CYPRESS_VIDEO: true
CYPRESS_COMPARE_SNAPSHOTS: true
- uses: actions/upload-artifact@v2
if: always()

cypress-tests-auth:
runs-on: ubuntu-latest
env:
ENABLED_SPIES: none
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.18.0'
- name: Cache go mod directories
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn
- run: yarn install --frozen-lockfile
- run: make -j e2e-build
- name: Cypress run
uses: cypress-io/github-action@v4
with:
wait-on: http://localhost:4040
start: |
node ./scripts/oauth-mock/oauth-mock.js
make server SERVERPARAMS=--config=scripts/oauth-mock/pyroscope-config.yml
config-file: cypress/integration/auth/cypress.json
env:
# keep the server quiet
PYROSCOPE_LOG_LEVEL: error
ENABLED_SPIES: none

cypress-tests-base-url:
runs-on: ubuntu-latest
env:
ENABLED_SPIES: none
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.18.0'
- name: Cache go mod directories
uses: actions/cache@v2
with:
name: cypress-screenshots
path: cypress/screenshots
- uses: actions/upload-artifact@v2
if: always()
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
name: cypress-videos
path: cypress/videos
- uses: actions/upload-artifact@v2
if: always()
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn
- run: yarn install --frozen-lockfile
- run: make -j e2e-build
- 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:
name: cypress-snapshots
path: cypress/snapshots
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ print-deps-error-message:
@echo ""
exit 1

e2e-build: assets-release build
e2e-build: build assets-release

help: ## Show this help
@egrep '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | sed 's/Makefile://' | awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-z0-9A-Z_-]+:.*?##/ { printf " \033[36m%-30s\033[0m %s\n", $$1, $$2 }'

0 comments on commit c62eda2

Please sign in to comment.