Skip to content

Commit

Permalink
feat(gha): add end-to-end testing framework
Browse files Browse the repository at this point in the history
This change integrates Playwright Automation tool into the CI process.

It also, as part of this change, introduce a small GitHub Actions
workflows refactoring that does the following:

- Rename workflow files & job names to better capture their intention
- Merge PR push-triggered & comment-triggered deployment workflows
  • Loading branch information
arikkfir committed Sep 3, 2023
1 parent c760e4b commit 3a8e41f
Show file tree
Hide file tree
Showing 12 changed files with 656 additions and 52 deletions.
File renamed without changes.
File renamed without changes.
25 changes: 0 additions & 25 deletions .github/workflows/deploy_pr_changes.yml

This file was deleted.

26 changes: 0 additions & 26 deletions .github/workflows/deploy_pr_comment.yml

This file was deleted.

54 changes: 54 additions & 0 deletions .github/workflows/pr_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Deploy

on:
issue_comment:
types:
- created
- edited
pull_request:
types:
- opened
- synchronize

concurrency:
group: deployment
cancel-in-progress: false

jobs:

deploy:
name: Deploy
uses: arikkfir/delivery/.github/workflows/deploy-to-environment.yml@main
if: github.event_name == 'pull_request' || (github.event.issue.pull_request && github.event.comment.body == '/deploy')
with:
branch: ${{ github.head_ref }}
images: |-
ghcr.io/${{ github.repository }}/backend: ${{ github.event.pull_request.head.sha }}
ghcr.io/${{ github.repository }}/frontend: ${{ github.event.pull_request.head.sha }}
ghcr.io/${{ github.repository }}/migrations: ${{ github.event.pull_request.head.sha }}
ghcr.io/${{ github.repository }}/neo4j: ${{ github.event.pull_request.head.sha }}
secrets: inherit

e2e-tests:
name: End-to-end Tests
needs: deploy
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20.x
cache: npm
cache-dependency-path: e2e/package-lock.json
- run: npm ci
working-directory: e2e
- run: npx playwright install --with-deps
working-directory: e2e
- run: npx playwright test
working-directory: e2e
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: e2e/playwright-report/
retention-days: 30
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ concurrency:

jobs:

undeploy-from-environment:
undeploy:
name: Undeploy from environment
uses: arikkfir/delivery/.github/workflows/undeploy-from-environment.yml@main
with:
Expand Down
4 changes: 4 additions & 0 deletions e2e/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
/test-results/
/playwright-report/
/playwright/.cache/
67 changes: 67 additions & 0 deletions e2e/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions e2e/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "greenstar-e2e",
"version": "0.0.0",
"description": "End-to-end tests for Greenstar",
"main": "index.js",
"scripts": {},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@playwright/test": "^1.37.1"
}
}
62 changes: 62 additions & 0 deletions e2e/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import {defineConfig, devices} from '@playwright/test';

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './tests',
timeout: 30 * 1000,
expect: {
timeout: 5000
},
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: 0,
workers: 1,
reporter: process.env.CI ? 'github' : [
['list', {printSteps: true}],
['html', {open: 'never'}],
],
use: {
actionTimeout: 0,
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',
trace: 'on',
},
projects: [
{
name: 'chromium',
use: {...devices['Desktop Chrome']},
},
// {
// name: 'firefox',
// use: { ...devices['Desktop Firefox'] },
// },
// {
// name: 'webkit',
// use: { ...devices['Desktop Safari'] },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 7'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 13'] },
// },
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
],
});
Loading

0 comments on commit 3a8e41f

Please sign in to comment.