Skip to content

fix(cypress): fixing AllowButton detachment from DOM (#3125) #4359

fix(cypress): fixing AllowButton detachment from DOM (#3125)

fix(cypress): fixing AllowButton detachment from DOM (#3125) #4359

Workflow file for this run

name: Code build and checks
on:
push:
branches: [main]
pull_request:
env:
VERSION: ${{ github.sha }}
TAG: latest
TRACETEST_ENV: ci
TRACETEST_DEV: true
CYPRESS_BASE_URL: http://localhost:11633
POKEMON_HTTP_ENDPOINT: http://demo-api:8081
# We need to remove the need for these secrets so anyone can run the pipeline
GORELEASER_KEY: ${{ secrets.GORELEASER_LICENSE }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
jobs:
backend-arch-graph:
name: Generate backend architecture graph
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup go
uses: actions/setup-go@v3
with:
go-version-file: "go.work"
cache: true
cache-dependency-path: go.work
- name: install graph tool
run: |
mkdir /tmp/go-arch
cd /tmp/go-arch
curl -SLO https://github.com/mathnogueira/golang-arch-viewer/archive/refs/heads/master.zip
unzip master.zip
cd golang-arch-viewer-master
make
mv dist/go-arch /tmp/go-arch/go-arch
- name: generate graph
run: |
cd server
mkdir -p ../dist/
/tmp/go-arch/go-arch -o ../dist/architecture.png
- name: Upload assets
uses: actions/upload-artifact@v3
with:
name: architecture-graph
path: dist/architecture.png
unit-test-cli:
name: CLI unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup go
uses: actions/setup-go@v3
with:
go-version-file: "go.work"
cache: true
cache-dependency-path: go.work
- name: Run unit tests
run: cd cli; make test
unit-test-server:
name: API Server unit tests
runs-on: ubuntu-latest
# git log --pretty=tformat:"%H" -n1 web
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup go
uses: actions/setup-go@v3
with:
go-version-file: "go.work"
cache: true
cache-dependency-path: go.work
- name: Run unit tests
run: cd server; make test -B
unit-test-agent:
name: Agent unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup go
uses: actions/setup-go@v3
with:
go-version-file: "go.work"
cache: true
cache-dependency-path: go.work
- name: Run unit tests
run: cd agent; make test -B
unit-test-web:
name: WebUI unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
cache-dependency-path: web/package-lock.json
- name: Cache dependencies
id: cache-nodemodules
uses: actions/cache@v3
with:
path: |
web/node_modules
/home/runner/.cache/Cypress
key: npm--${{ hashFiles('web/package-lock.json') }}
restore-keys: npm-
- run: cd web; npm ci
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
- run: cd web; npm run lint && npm test
build-docker:
name: Build docker image
runs-on: ubuntu-latest
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: set cache keys
shell: bash
run: |
echo "WEB_CACHE_KEY=$(git log --pretty=tformat:"%H" -n1 web)" >> $GITHUB_ENV
echo "SERVER_CACHE_KEY=$(git log --pretty=tformat:"%H" -n1 server)" >> $GITHUB_ENV
echo "CLI_CACHE_KEY=$(git log --pretty=tformat:"%H" -n1 cli)" >> $GITHUB_ENV
# web
- name: Cache Web Build
id: cache-web-build
uses: actions/cache@v3
with:
path: web/build/
key: web-build-${{ env.WEB_CACHE_KEY }}
- name: Setup node
# if cache miss
if: steps.cache-web-build.outputs.cache-hit != 'true'
uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
cache-dependency-path: web/package-lock.json
- name: Cache dependencies
id: cache-nodemodules
# if cache miss
if: steps.cache-web-build.outputs.cache-hit != 'true'
uses: actions/cache@v3
with:
path: |
web/node_modules
/home/runner/.cache/Cypress
key: npm--${{ hashFiles('web/package-lock.json') }}
restore-keys: npm-
- name: Install dependencies
run: cd web/; npm ci
# if cache miss for build and deps
if: steps.cache-web-build.outputs.cache-hit != 'true' && steps.cache-nodemodules.outputs.cache-hit != 'true'
- run: cd web; CI= npm run build
if: steps.cache-web-build.outputs.cache-hit != 'true'
# go+docker
- name: Cache Build
id: cache-docker-build
uses: actions/cache@v3
with:
path: dist/
key: dist-${{env.SERVER_CACHE_KEY }}-${{env.CLI_CACHE_KEY }}-${{ hashFiles('.goreleaser.dev.yaml', 'Dockerfile') }}
- name: Setup go
if: steps.cache-docker-build.outputs.cache-hit != 'true'
uses: actions/setup-go@v3
with:
go-version-file: "go.work"
cache: true
cache-dependency-path: go.work
- uses: goreleaser/goreleaser-action@v4
if: steps.cache-docker-build.outputs.cache-hit != 'true'
with:
distribution: goreleaser-pro
version: v1.19.2
args: release --skip-announce --snapshot -f .goreleaser.dev.yaml
- name: Move binaries to known location
if: steps.cache-docker-build.outputs.cache-hit != 'true'
run: |
find ./dist -name 'tracetest' -exec cp {} ./dist \;
find ./dist -name 'tracetest-server' -exec cp {} ./dist \;
chmod +x ./dist/tracetest ./dist/tracetest-server
- name: Export docker image
if: steps.cache-docker-build.outputs.cache-hit != 'true'
run: |
docker save --output dist/image.tar "kubeshop/tracetest:$TAG"
- name: Upload assets
uses: actions/upload-artifact@v3
with:
name: tracetest-dist
path: dist/
test-examples:
name: Test examples
needs: [build-docker]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
example_dir:
- collector
- tracetest-jaeger
- tracetest-opensearch
- tracetest-tempo
- tracetest-no-tracing
- tracetest-provisioning-env
- tracetest-signoz
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: tracetest-dist
path: dist/
- name: Import image
run: |
docker load --input dist/image.tar
- name: Build example
run: |
cd examples/${{ matrix.example_dir }}
docker-compose up -d
docker compose logs -f > /tmp/docker-log &
- name: Run example test
run: |
chmod +x ./dist/tracetest
./scripts/wait-for-port.sh 11633
./dist/tracetest configure -g --endpoint http://localhost:11633
./dist/tracetest run test -f examples/${{ matrix.example_dir }}/tests/list-tests.yaml || (cat /tmp/docker-log; exit 1)
smoke-test-cli:
name: CLI smoke tests
needs: [build-docker]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test_env:
- local
- docker
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: tracetest-dist
path: dist/
- name: Import image
run: |
docker load --input dist/image.tar
- name: Start server
run: |
cd examples/collector
docker-compose up -d
docker compose logs -f > /tmp/docker-log &
- name: Run tests
run: |
chmod +x ./dist/tracetest ./testing/cli-smoketest/run.bash
./scripts/wait-for-port.sh 11633
cd ./testing/cli-smoketest
TRACETEST_CLI="../../dist/tracetest" \
TEST_ENV="${{ matrix.test_env }}" \
./run.bash || (cat /tmp/docker-log; exit 1)
trace-testing:
needs: [build-docker]
name: Tracetesting API Server
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: tracetest-dist
path: dist/
- name: Import image
run: |
docker load --input dist/image.tar
- name: Start services
run: |
./run.sh down up
./run.sh tracetest-logs > /tmp/docker-log &
- name: Run tests
run: |
chmod +x ./dist/tracetest ./dist/tracetest-server
./scripts/wait-for-port.sh 11633
./run.sh tracetests || (cat /tmp/docker-log; exit 1)
e2e-cli:
name: CLI e2e tests
needs: [build-docker]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: tracetest-dist
path: dist/
- name: Import image
run: |
docker load --input dist/image.tar
- name: Run tests
run: |
find ./dist -name 'tracetest' -exec cp {} ./dist \;
chmod +x ./dist/tracetest
export TRACETEST_CLI=$PWD/dist/tracetest
export TEST_ENVIRONMENT=jaeger
cd ./testing/cli-e2etest
make test
# TODO: this would be a great idea but it doesn't work on GHA with docker
# it can probablly be implemented with k8s in a separated job
# I'm leaving this as a reference and as a reminder to do it
# k6-test:
# name: k6 Load Test
# needs: [build-docker]
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: Setup go
# uses: actions/setup-go@v3
# with:
# go-version-file: "go.work"
# cache: true
# cache-dependency-path: go.work
# - uses: actions/download-artifact@v3
# with:
# name: tracetest-dist
# path: dist/
# - name: Import image
# run: |
# docker load --input dist/image.tar
# - name: Run tests
# run: |
# chmod +x ./dist/tracetest ./testing/load/run.bash
# cd ./testing/load
# export TRACETEST_CLI="../../dist/tracetest"
# ./run.bash || (cat /tmp/docker-log; exit 1)
config-e2e:
runs-on: ubuntu-latest
outputs:
CYPRESS_CONTAINERS: ${{ steps.configure-cypress-containers.outputs.CYPRESS_CONTAINERS }}
steps:
- name: Configure Cypress containers
id: configure-cypress-containers
run: |
# env.CYPRESS_RECORD_KEY is required for parallelization, so if it's empty run a single container
if [ "${{env.CYPRESS_RECORD_KEY}}" = "" ]; then
echo "CYPRESS_CONTAINERS=[1]" >> $GITHUB_OUTPUT
else
echo "CYPRESS_CONTAINERS=[1,2,3,4,5,6,7,8]" >> $GITHUB_OUTPUT
fi
e2e:
needs: [build-docker, config-e2e]
name: WebUI End-to-end tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# run copies of the current job in parallel
containers: ${{fromJson(needs.config-e2e.outputs.CYPRESS_CONTAINERS)}}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
cache-dependency-path: web/package-lock.json
- name: Cache dependencies
id: cache-nodemodules
uses: actions/cache@v3
with:
path: |
web/node_modules
/home/runner/.cache/Cypress
key: npm--${{ hashFiles('web/package-lock.json') }}
restore-keys: npm-
- name: Install dependencies
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
run: cd web/; npm ci
- uses: actions/download-artifact@v3
with:
name: tracetest-dist
path: dist/
- name: Import image
run: |
docker load --input dist/image.tar
- name: Run integration tests
run: |
./run.sh down up
./run.sh tracetest-logs > /tmp/docker-log &
./scripts/wait-for-port.sh 11633
if [ "${{env.CYPRESS_RECORD_KEY}}" = "" ]; then
# if this is not container #1, the script won't get here, so don't need for additional checks
./run.sh cypress
else
./run.sh cypress-ci
fi