You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

配置GitHub Action实现Playwright测试与Neo4j服务的问题求助

GitHub Actions工作流配置问题求助

我花了数小时尝试解决以下CI/CD配置问题,本人对CI/CD并不熟悉,AI也未能提供有效帮助。我需要GitHub Action工作流满足以下需求:

  • 运行Playwright测试
  • 使用Playwright的分片测试功能
  • 部署Neo4j服务
  • 向Neo4j数据库加载初始数据
  • 使用容器mcr.microsoft.com/playwright:v1.44.0-jammy

遇到的问题

  • 为向Neo4j加载数据,我给服务设置了自定义名称,后续通过docker exec执行cypher-shell工具导入数据集,但测试工具无法连接到该数据库,尝试过neo4j和neo4j_service作为DB_HOSTNAME均无效
  • 尝试单独下载cypher-shell,但无法获取最新版本,每次都要手动更新工作流文件
  • 使用工作流策略矩阵实现分片时,数据加载步骤会重复执行,添加的条件判断未生效
  • 使用推荐的Playwright容器运行测试时,容器内没有Docker环境,无法执行服务中的cypher-shell
  • 考虑通过Dockerfile创建预加载数据的Neo4j实例,但不确定能否在工作流中作为服务使用

当前的YAML配置文件

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

内容的提问来源于stack exchange,提问作者oLDo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.24 02:45:01