From e08fbfad01857f8b23b116aca578bf1ecab04ac1 Mon Sep 17 00:00:00 2001 From: Alex Hadley Date: Wed, 3 Jan 2024 12:09:54 -0800 Subject: [PATCH] #203 Update GitHub actions to use Playwright --- .github/workflows/ci.yml | 48 ++++++------------------------ .github/workflows/github-pages.yml | 15 ---------- tests/e2e/helpers.py | 10 ++----- 3 files changed, 12 insertions(+), 61 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2f7586d..45d7cb0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,7 +54,7 @@ jobs: run: poetry run mypy ${{ env.PACKAGE_NAME }} tests - name: Test (Pytest) - run: poetry run pytest + run: poetry run pytest tests/unit frontend: runs-on: ubuntu-latest @@ -71,29 +71,14 @@ jobs: - name: Enable Yarn run: corepack enable - - name: Get Cypress version - id: cypress-version - run: echo VERSION=$(yarn info cypress --json | jq ".children.Version" -r) >> $GITHUB_OUTPUT - - - name: Cypress cache - uses: actions/cache@v3 - with: - path: ~/.cache/Cypress - key: cypress-${{ runner.os }}-${{ steps.cypress-version.outputs.VERSION }} - restore-keys: | - cypress-${{ runner.os }}- - - name: Install Node.js dependencies run: yarn - - name: Prune Cypress cache - run: yarn cypress cache prune - - name: Lint run: yarn lint - name: Unit tests - run: yarn test:unit + run: yarn test e2e: runs-on: ubuntu-latest @@ -122,39 +107,24 @@ jobs: - name: Enable Yarn run: corepack enable - - name: Get Cypress version - id: cypress-version - run: echo VERSION=$(yarn info cypress --json | jq ".children.Version" -r) >> $GITHUB_OUTPUT - - - name: Cypress cache - uses: actions/cache@v3 - with: - path: ~/.cache/Cypress - key: cypress-${{ runner.os }}-${{ steps.cypress-version.outputs.VERSION }} - restore-keys: | - cypress-${{ runner.os }}- - - name: Install Node.js dependencies run: yarn - - name: Prune Cypress cache - run: yarn cypress cache prune + - name: Install Playwright browsers + run: poetry run playwright install --with-deps chromium - name: Build frontend run: yarn build - - name: Start backend server - run: yarn backend start & - - - name: Start frontend server - run: yarn preview & + - name: Start E2E server + run: poetry run python tests/e2e/start_server.py & - name: E2E tests - run: yarn test:e2e + run: poetry run pytest tests/e2e - name: Upload failure screenshots uses: actions/upload-artifact@v3 if: failure() with: - name: e2e-failure-screenshots - path: cypress/screenshots + name: e2e-failed-traces + path: test-results diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index 8332dcb..96fe52b 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -36,24 +36,9 @@ jobs: - name: Enable Yarn run: corepack enable - - name: Get Cypress version - id: cypress-version - run: echo VERSION=$(yarn info cypress --json | jq ".children.Version" -r) >> $GITHUB_OUTPUT - - - name: Cypress cache - uses: actions/cache@v3 - with: - path: ~/.cache/Cypress - key: cypress-${{ runner.os }}-${{ steps.cypress-version.outputs.VERSION }} - restore-keys: | - cypress-${{ runner.os }}- - - name: Install Node.js dependencies run: yarn - - name: Prune Cypress cache - run: yarn cypress cache prune - - name: Build frontend run: yarn build diff --git a/tests/e2e/helpers.py b/tests/e2e/helpers.py index 721ae95..ffe1c7b 100644 --- a/tests/e2e/helpers.py +++ b/tests/e2e/helpers.py @@ -86,14 +86,10 @@ def commit_to_db(data: Any | None = None, message: str | None = None) -> None: def reset_db(num_commits: int = 1) -> None: """Clear the database and make some initial commits.""" clear_db() - with freeze_time(get_datetime(1)): + with freeze_time(_START_DATETIME): param = CustomParam(int=123, str="test") - # Convert last updated from freezegun.api.FakeDatetime to a true datetime - setattr( - param, - "_Param__last_updated", - datetime.fromtimestamp(param.last_updated.timestamp()), - ) + # Use real datetime for last updated (rather than freezegun.api.FakeDatetime) + setattr(param, "_Param__last_updated", _START_DATETIME) initial_data = ParamDict( { "commit_id": 1,