I spent many hours trying to solve this issue. I’m not that skilled with CI/CD so I’m looking for some help. AI was also not helpful.
What I need from the workflow:
- Run playwright test
- Use sharding ( https://playwright.dev/docs/test-sharding )
- Have Neo4j service
- Load initial data into Neo4j database
- Use container mcr.microsoft.com/playwright:v1.44.0-jammy
What are the problems I hit on the road:
- To load data into Neo4j I’ve set custom name for service with options. Afterwards I can have step which runs
docker exec
and load required dataset and import it with cypher-shell tool. But with custom name of service I can’t connect to this database from my tool I’m testing. I don’t know why. I triedneo4j
and alsoneo4j_service
. You can see that with env variable DB_HOSTNAME. - Other option was to download cypher-shell separately and don’t use the one from service. I couldn’t deal with getting the latest version. So it would require to update workflow file everytime there is a new version.
- When I used workflow strategy matrix to use sharding I have problem with loading dataset into Neo4j, because it does it multiple times. Because it is a step. I tried to condition that step but somehow it didn’t work. Maybe it was just related to problem with custom service name.
- When I used workflow container for playwright, for running my playwright tests, which is suggested, I have problem because it doesn’t contain docker to run cypher-shell from the service.
- I was thinking, maybe dockerfile to create neo4j instance with data will be the way. But I’m not sure if I have dockerfile in repository, if I can use it as service in workflow.
This is currently state of my yaml file:
name: Playwright e2e tests
on:
pull_request:
branches: [master]
workflow_run:
workflows: ['Prettier and linter']
types:
- completed
concurrency:
group: ${{ github.head_ref }}
cancel-in-progress: true
jobs:
neo4j-read:
timeout-minutes: 60
runs-on: ubuntu-latest
# container:
# image: mcr.microsoft.com/playwright:v1.44.0-jammy
services:
neo4j:
image: neo4j:latest
env:
NEO4J_AUTH: neo4j/nothing123
ports:
- 7687:7687
- 7474:7474
options: >-
--name "neo4j_service"
--health-cmd "wget http://localhost:7474 || exit 1"
# strategy:
# fail-fast: false
# matrix:
# shardIndex: [1, 2, 3, 4, 5, 6, 7, 8]
# shardTotal: [8]
steps:
- name: Load movies dataset
# if: ${{ matrix.shardIndex == 1 }}
run: |
docker exec neo4j_service wget -O /tmp/movies.cypher https://raw.githubusercontent.com/neo4j-graph-examples/movies/main/scripts/movies.cypher
docker exec neo4j_service cypher-shell -a bolt://localhost:7687 -u "neo4j" -p "nothing123" "MATCH (n) DETACH DELETE n"
docker exec neo4j_service cypher-shell -a bolt://localhost:7687 -u "neo4j" -p "nothing123" -f /tmp/movies.cypher
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: latest
- name: Install dependencies
run: npm ci
# - name: Playwright
# run: |
# npx playwright install --with-deps chromium
# npx playwright test --grep @neo4j-read --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} --reporter=blob
- name: Install Playwright Browsers
run: npx playwright install --with-deps chromium
- name: Run Playwright tests (neo4j-read)
run: npx playwright test --grep @neo4j-read --reporter=html #--reporter=blob --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
env:
DB_HOSTNAME: 'bolt://neo4j:7687'
DB_USERNAME: 'neo4j'
DB_PASSWORD: 'nothing123'
- uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 1
# - name: Upload blob report to GitHub Actions Artifacts
# if: ${{ failure() }}
# uses: actions/upload-artifact@v4
# with:
# name: blob-report-${{ matrix.shardIndex }}
# path: blob-report
# retention-days: 1
You can check more here: https://github.com/stefanak-michal/cyphergui/pull/88