Skip to content

Commit

Permalink
Merge pull request #4 from Jordan-Mesches/feature/tetris-game
Browse files Browse the repository at this point in the history
Create a tetris game to drive site engagement
  • Loading branch information
Jordan-Mesches authored Nov 9, 2023
2 parents 9f427f3 + 8ef01b0 commit 22557ba
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 1 deletion.
56 changes: 56 additions & 0 deletions .github/workflows/continuous.integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Run Checks on PR

on:
pull_request:
branches:
- main

permissions:
actions: write
checks: write
contents: read
security-events: write
pull-requests: write

env:
CI: true
SITE_DIR: site
TETRIS_APP_HOST: "127.0.0.1"
TETRIS_APP_PORT: "8080"
TETRIS_APP_PATH: "github-devsecops-fundamentals"

jobs:
quality-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: 3.12
- uses: actions/setup-node@v3
with:
node-version: 20

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.ci.txt
npm ci
# Install browsers for running functional tests
npx playwright install --with-deps chromium
- name: Build
run: |
python -m mkdocs build --clean --strict --verbose --site-dir '${{ env.SITE_DIR }}'
- name: Functional Test
run: npx playwright test

- name: Upload Functional Test Report
uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,4 @@ nav:
- exercises/03.automate.release/02.md
- ✨ Recap:
- exercises/recap/index.md
- Tetris Game: tetris.game/index.html
- Tetris Game: tetris.game/index.html
26 changes: 26 additions & 0 deletions tests/tetris.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { test, expect } from "@playwright/test";

test("Tetris Game", async ({ page }) => {
const { TETRIS_APP_HOST, TETRIS_APP_PORT, TETRIS_APP_PATH } = process.env;

// should be similar to http://127.0.0.1:8080/github-devsecops-fundamentals/
console.log(
`http://${TETRIS_APP_HOST}:${TETRIS_APP_PORT}/${TETRIS_APP_PATH}`
);
await page.goto(
`http://${TETRIS_APP_HOST}:${TETRIS_APP_PORT}/${TETRIS_APP_PATH}`
);

await page.getByRole("link", { name: "Tetris Game" }).click();
await expect(page.getByText("score 00000")).toBeVisible();
await expect(page.getByText("rows 0")).toBeVisible();
await expect(page.locator("#upcoming")).toBeVisible();
await expect(
page.getByRole("link", { name: "Press Space to Play." })
).toBeVisible();

await page.getByRole("link", { name: "Press Space to Play." }).click();
await expect(page.getByText("score 00000")).not.toBeVisible({
timeout: 0.5 * 60 * 1000,
});
});

0 comments on commit 22557ba

Please sign in to comment.