|
| 1 | +name: E2E Tests |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: read |
| 5 | + issues: write |
| 6 | + pull-requests: write |
| 7 | + |
| 8 | +on: |
| 9 | + push: |
| 10 | + branches: [main] |
| 11 | + issue_comment: |
| 12 | + types: [created] |
| 13 | + |
| 14 | +jobs: |
| 15 | + e2e: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + # Run on push/PR or when a maintainer comments "/test e2e" or "/run e2e" |
| 18 | + if: | |
| 19 | + github.event_name != 'issue_comment' || ( |
| 20 | + github.event.issue.pull_request && |
| 21 | + (contains(github.event.comment.body, '/test e2e') || contains(github.event.comment.body, '/run e2e')) && |
| 22 | + (github.event.comment.author_association == 'OWNER' || |
| 23 | + github.event.comment.author_association == 'MEMBER' || |
| 24 | + github.event.comment.author_association == 'COLLABORATOR') |
| 25 | + ) |
| 26 | +
|
| 27 | + steps: |
| 28 | + - name: Checkout code |
| 29 | + uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4 |
| 30 | + with: |
| 31 | + # When triggered by comment, checkout the PR branch |
| 32 | + ref: ${{ github.event_name == 'issue_comment' && format('refs/pull/{0}/head', github.event.issue.number) || github.ref }} |
| 33 | + |
| 34 | + - name: Set up Docker Buildx |
| 35 | + uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 |
| 36 | + |
| 37 | + - name: Set up Docker Compose |
| 38 | + uses: docker/setup-compose-action@364cc21a5de5b1ee4a7f5f9d3fa374ce0ccde746 |
| 39 | + |
| 40 | + - name: Set up Node.js |
| 41 | + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 |
| 42 | + with: |
| 43 | + node-version: '20' |
| 44 | + cache: 'npm' |
| 45 | + |
| 46 | + - name: Install dependencies |
| 47 | + run: npm ci |
| 48 | + |
| 49 | + - name: Configure Git for CI |
| 50 | + run: | |
| 51 | + git config --global user.name "CI Runner" |
| 52 | + git config --global user.email "ci@example.com" |
| 53 | + git config --global init.defaultBranch main |
| 54 | +
|
| 55 | + - name: Build and start services with Docker Compose |
| 56 | + run: docker compose up -d --build |
| 57 | + |
| 58 | + - name: Wait for services to be ready |
| 59 | + run: | |
| 60 | + timeout 60 bash -c 'until docker compose ps | grep -q "Up"; do sleep 2; done' |
| 61 | + sleep 10 |
| 62 | +
|
| 63 | + - name: Run E2E tests |
| 64 | + run: npm run test:e2e |
| 65 | + |
| 66 | + - name: Stop services |
| 67 | + if: always() |
| 68 | + run: docker compose down -v |
0 commit comments