Skip to content

Commit

Permalink
Merge pull request fangci221#1 from sShaAanGg/origin
Browse files Browse the repository at this point in the history
CI: automated building&testing with playwright
  • Loading branch information
sShaAanGg authored Oct 19, 2023
2 parents a005fc8 + a52ce11 commit 16a8a9e
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 26 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/mySQL.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Set up mySQL service container
on:
workflow_dispatch:
schedule:
# Test 3 times a day
- cron: '0 */8 * * *'
jobs:
runner-job:
# You must use a Linux environment when using service containers or container jobs
runs-on: ubuntu-latest

# Service containers to run with `runner-job`
services:
# Label used to access the service container
mysql:
# Docker Hub image
image: mysql:latest
env:
DB_NAME: 'library'
DB_USER: 'root'
DB_PASS: ${{ secrets.DB_PASS }}
#
ports:
# Opens tcp port 3800 on the host and service container
- 3800:3800

steps:
# Downloads a copy of the code in your repository before running CI tests
- name: Check out repository code
uses: actions/checkout@v4

# Performs a clean installation of all dependencies in the `package.json` file
# For more information, see https://docs.npmjs.com/cli/ci.html
# - name: Install dependencies
# run: npm ci

- name: Connect to mySQL
# Runs a script that creates a mySQL table, populates
# the table with data, and then retrieves the data
run: mysql -u
# Environment variables used by the script to create
# a new mySQL table.
env:
DB_NAME: 'library'
DB_USER: 'root'
DB_PASS: ${{ secrets.DB_PASS }}
# The hostname used to communicate with the mySQL service container
DB_HOST: localhost
# The default mySQL port
DB_PORT: 3800

70 changes: 70 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Node.js CI and Playwright Tests
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

on:
workflow_dispatch:
schedule:
# Test 3 times a day
- cron: '0 */8 * * *'

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['14.21.3']
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: mirromutth/mysql-action@v1.1
with:
host port: 3800 # Optional, default value is 3306. The port of host
container port: 3307 # Optional, default value is 3306. The port of container
character set server: 'utf8' # Optional, default value is 'utf8mb4'. The '--character-set-server' option for mysqld
collation server: 'utf8_general_ci' # Optional, default value is 'utf8mb4_general_ci'. The '--collation-server' option for mysqld
mysql version: '8.0' # Optional, default value is "latest". The version of the MySQL
mysql database: 'library' # Optional, default value is "test". The specified database which will be create
mysql root password: ${{ secrets.DB_PASS }} # Required if "mysql user" is empty, default is empty. The root superuser password
# mysql user: 'developer' # Required if "mysql root password" is empty, default is empty. The superuser for the specified database. Can use secrets, too
# mysql password: ${{ secrets.DatabasePassword }} # Required if "mysql user" exists. The password for the "mysql user"
- uses: actions/checkout@v3
- name: Import .sql file
run: |
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies of back-end and start building and running
working-directory: source/back-end
run: |
npm install
npm run start &
- name: Install dependencies of front-end and start building and running
working-directory: source/front-end
run: |
npm install
npm run serve &
# - run: npm ci
# - run: npm run build --if-present
# - run: npm test
# steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pytest
python -m pip install pytest-playwright
# pip install -r requirements.txt
- name: Ensure browsers are installed
run: python -m playwright install --with-deps
- name: Run your tests
run: python -m pytest

25 changes: 0 additions & 25 deletions .github/workflows/playwright.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/stage/

.DS_Store
node_modules
./source/back-end/node_modules/*
/dist
/coverage

Expand Down
17 changes: 17 additions & 0 deletions source/back-end/test/test_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import re
from playwright.sync_api import Page, expect

def test_has_title(page: Page):
page.goto("https://playwright.dev/")

# Expect a title "to contain" a substring.
expect(page).to_have_title(re.compile("Playwright"))

def test_get_started_link(page: Page):
page.goto("https://playwright.dev/")

# Click the get started link.
page.get_by_role("link", name="Get started").click()

# Expects page to have a heading with the name of Installation.
expect(page.get_by_role("heading", name="Installation")).to_be_visible()

0 comments on commit 16a8a9e

Please sign in to comment.