Skip to content

SS-1980 Pooling stats logging for celery workers (#560) #953

SS-1980 Pooling stats logging for celery workers (#560)

SS-1980 Pooling stats logging for celery workers (#560) #953

Workflow file for this run

name: E2E-tests
on:
push:
branches:
- develop
paths-ignore:
- '**.md'
# Adds ability to run this workflow manually
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
options:
- info
- warning
- debug
tags:
description: 'Manual run'
required: false
type: boolean
jobs:
e2e:
if: github.repository == 'scilifelabdatacentre/serve'
runs-on: ubuntu-22.04
env:
working-directory: .
strategy:
fail-fast: false
matrix:
shard:
- "cypress/e2e/ui-tests/test-superuser-functionality.cy.js"
- "cypress/e2e/ui-tests/test-project-as-contributor.cy.js,cypress/e2e/ui-tests/test-storage-settings.cy.js,cypress/e2e/ui-tests/test-login-account-handling.cy.js"
- "cypress/e2e/ui-tests/test-user-manage-app-settings.cy.js,cypress/e2e/ui-tests/test-user-manage-apps.cy.js"
- "cypress/e2e/ui-tests/test-user-manage-app-types.cy.js,cypress/e2e/ui-tests/test-public-webpages.cy.js,cypress/e2e/ui-tests/test-collections.cy.js,cypress/e2e/ui-tests/test-signup.cy.js,cypress/e2e/ui-tests/test-brute-force-login-attempts.cy.js,cypress/e2e/ui-tests/test-views-as-reader.cy.js,cypress/e2e/ui-tests/test-app-details-pages.cy.js,cypress/e2e/ui-tests/test-invenio-funding.cy.js"
steps:
- name: Workflow Telemetry
uses: runforesight/workflow-telemetry-action@v1.8.0
- name: Branch or tag that triggered the workflow run
run: |
echo "Running on branch ${GITHUB_REF##*/}"
echo "Running as UID: $UID, GID: $GID"
whoami
- name: Checkout code
uses: actions/checkout@v4
- name: Prepare repository
run: |
echo "Running as UID: $UID, GID: $GID"
export GID=127
echo "Now running as UID: $UID, GID: $GID"
whoami
pwd
mv .env.template .env
sudo chgrp -R 127 media
sudo chmod -R g+rwx media
ls -al
sed -i 's/UID=1000/UID=1001/g' .env
sed -i 's/GID=1000/GID=127/g' .env
- name: Free up disk space
run: |
df -h /
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL /usr/local/share/powershell /usr/local/share/chromium
df -h /
- name: A job to install MicroK8s
uses: balchua/microk8s-actions@v0.4.3
with:
channel: '1.32/stable'
addons: '["dns", "rbac", "helm"]'
- name: Test and config MicroK8s
run: |
echo "Running usermod to add ${USER} to microk8s group"
sudo usermod -a -G microk8s $USER
sudo chown -f -R $USER ~/.kube
sudo microk8s config >> ~/.kube/config
- name: Pre-pull app images into MicroK8s (background)
run: |
images=(
ghcr.io/scilifelabdatacentre/serve-jupyterlab-minimal:250213-1113
ghcr.io/scilifelabdatacentre/serve-rstudio:250304-1611
ghcr.io/scilifelabdatacentre/example-dash:latest
ghcr.io/scilifelabdatacentre/example-streamlit:latest
ghcr.io/scilifelabdatacentre/shiny-adhd-medication-sweden:20240117-062031
ghcr.io/scilifelabdatacentre/gradio-flower-classification:20241118-174426
ghcr.io/scilifelabdatacentre/dash-covid-in-sweden:20240117-063059
ghcr.io/scilifelabdatacentre/streamlit-image-to-smiles:20241112-183549
)
for img in "${images[@]}"; do
nohup sudo microk8s ctr image pull "$img" >/dev/null 2>&1 &
done
disown -a
echo "Started background pre-pull of ${#images[@]} app images"
- name: Dump config
working-directory: ${{env.working-directory}}
run: |
sudo microk8s config > cluster.conf
ls -la
cat cluster.conf
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build app image with cache
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
target: runtime
tags: stackn:base
load: true
cache-from: type=gha,scope=stackn-base
cache-to: type=gha,mode=max,scope=stackn-base
- name: Start serve
working-directory: ${{env.working-directory}}
id: setup
run: |
set -ex
echo "Deploying serve"
docker compose up -d --no-build db redis rabbit studio celery-worker celery-beat event-listener
- name: Set Serve URL
working-directory: ${{env.working-directory}}
run: |
curl --version | head -n 1
STUDIO_URL=http://studio.127.0.0.1.nip.io:8080
echo "STUDIO_URL=$STUDIO_URL" >> $GITHUB_ENV
echo "The Serve URL is $STUDIO_URL"
- name: Check URL is up
uses: gerdemann/http-status-code@1.0.0
with:
url: ${{ env.STUDIO_URL }}
code: 200 # http status code
timeout: 120 # seconds
interval: 5 # seconds
continue-on-error: true
- name: Check if Serve is ready
working-directory: ${{env.working-directory}}
id: check_serve_up
run: |
echo "Checking response from STUDIO_URL: ${{ env.STUDIO_URL }}"
for attempt in {1..24}; do
response=$(curl --write-out '%{http_code}' --silent --output /dev/null ${{ env.STUDIO_URL }})
if [[ "$response" -eq 200 ]] ; then
echo "serve is ready"
exit 0
fi
echo "status $response on attempt $attempt; retrying"
sleep 5
done
echo "Serve did not become ready in time"
docker compose logs --no-color --timestamps studio
exit 1
- name: Check if celery worker can access kubectl and helm
run: |
docker exec celery-worker kubectl version
docker exec celery-worker helm version
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: npm
cache-dependency-path: package-lock.json
- name: Cache Cypress binary
uses: actions/cache@v4
with:
path: ~/.cache/Cypress
key: cypress-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
restore-keys: |
cypress-${{ runner.os }}-
- name: Install Node.js dependencies
working-directory: ${{env.working-directory}}
run: npm ci
- name: Cypress run e2e tests (shard ${{ strategy.job-index }})
working-directory: ${{env.working-directory}}
run: npx cypress run --spec "${{ matrix.shard }}" --config pageLoadTimeout=100000,baseUrl=${{ env.STUDIO_URL }} --quiet
env:
ELECTRON_DISABLE_GPU: true
- name: Save cypress screenshot artifacts on failure
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots-${{ strategy.job-index }}
path: cypress/screenshots
if-no-files-found: ignore
- name: Save cypress video artifacts on failure
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-videos-${{ strategy.job-index }}
path: cypress/videos
if-no-files-found: ignore
- name: Dump container logs
if: always()
working-directory: ${{env.working-directory}}
run: |
mkdir -p container-logs
docker compose logs --no-color --timestamps > container-logs/all-services.log 2>&1 || true
docker compose logs --no-color --timestamps celery-worker > container-logs/celery-worker.log 2>&1 || true
docker compose logs --no-color --timestamps studio > container-logs/studio.log 2>&1 || true
docker compose logs --no-color --timestamps celery-beat > container-logs/celery-beat.log 2>&1 || true
- name: Upload container logs
if: always()
uses: actions/upload-artifact@v4
with:
name: container-logs-${{ strategy.job-index }}
path: container-logs
if-no-files-found: ignore