Skip to content

Use local Magic Wormhole backend for e2e testing #572

Use local Magic Wormhole backend for e2e testing

Use local Magic Wormhole backend for e2e testing #572

Workflow file for this run

---
name: Integration
on:
push:
pull_request:
workflow_dispatch:
jobs:
pre:
# Verification to be done before the real check
name: Pre-check
runs-on: ubuntu-22.04
outputs:
should_skip: ${{ steps.skip_flag.outputs.should_skip }}
steps:
- name: Skip flag
id: skip_flag
uses: fkirc/skip-duplicate-actions@v5
with:
concurrent_skipping: "same_content_newer"
paths: '["docker-compose*.yml", "client/**", "client-e2e/**", ".github/workflows/integrate.yml"]'
build:
name: Build/Test
needs: pre
if: ${{ github.event_name == 'workflow_dispatch' || needs.pre.outputs.should_skip != 'true' }}
runs-on: ${{ matrix.os }}
timeout-minutes: 60
strategy:
matrix:
os: [ubuntu-22.04]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' }}
timeout-minutes: 30
with:
detached: true
limit-access-to-actor: true
- name: Cache images
uses: ScribeMD/docker-cache@0.3.7
with:
key: |
docker-${{ runner.os }}-${{ hashFiles(
'docker-compose*.yml',
'client/Dockerfile',
'client-e2e/Dockerfile',
'client-e2e/images/Dockerfile.*'
) }}
- name: Prepare environment
run: |
IP=$(ip address show eth0 | grep inet | cut -d ' ' -f 6 | cut -d '/' -f1 | head -n1)
printf "HOST_IP address is: %s\n" "$IP"
cat <<EOF >> ./.env
HOST_IP="$IP"
EOF
cat <<EOF >> ./client/.env
NODE_ENV=development
MAILBOX_URL="ws://mailbox:4000/v1"
RELAY_URL="wss://relay.stage.winden.app"
EOF
printf "Client .env:\n"
cat ./client/.env
printf "Client-e2e .env:\n"
cat ./.env
- name: Fix group membership
id: fix_group
run: |
# Add the existing `runner` group to avoid the `docker` one
sudo adduser runner runner
echo "_GID=$(grep -E "^runner:" /etc/group | cut -d: -f3)" >> $GITHUB_ENV
- name: Build images
run: |
repository=${{ github.repository }}
# Verify the cache
docker images --quiet ${repository##*/}-client:latest | grep -v "^$" && \
CLIENT=0 || CLIENT=1
docker images --quiet ${repository##*/}-client-e2e:latest | grep -v "^$" && \
CLIENT_E2E=0 || CLIENT_E2E=1
# Build images if any client is missing
test $CLIENT -eq 0 -a $CLIENT_E2E -eq 0 || \
docker compose --progress plain -f docker-compose.yml -f docker-compose.e2e.yml --profile e2e \
build --build-arg uid=$(id -u) --build-arg gid=${_GID}
- name: Prepare containers
run: |
docker compose run --rm --no-deps -e CI=true client npm clean-install
docker compose run --rm --no-deps client ./scripts/setup.sh
docker compose -f docker-compose.yml -f docker-compose.e2e.yml --profile e2e \
run --rm --no-deps -e CI=true client-e2e npm clean-install
- name: Start containers
run: |
docker compose --progress plain up -d client
docker compose exec client ./scripts/wait-for-webpack.sh
docker compose ps
docker compose logs client
- name: Run UNIT and INTEGRATION tests
run: docker compose run --rm client npm run test -- --coverage
- name: Run END-2-END tests
run: |
docker compose --progress plain -f docker-compose.yml -f docker-compose.e2e.yml --profile e2e \
run --rm client-e2e npm run wdio
- name: Stop containers
run: docker compose --profile e2e down
- uses: sonarsource/sonarqube-scan-action@v2
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}