From 1dc6d179c23631e321d3cb9168b19fd941b981cf Mon Sep 17 00:00:00 2001 From: andrechalella Date: Thu, 4 Sep 2025 14:57:23 +0000 Subject: [PATCH 1/4] Criar um jogo de tetris para impulsionar o engajamento do site MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Implementar integração contínua - Resolve #5 --- .github/workflows/continuous.integration.yml | 56 ++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/continuous.integration.yml diff --git a/.github/workflows/continuous.integration.yml b/.github/workflows/continuous.integration.yml new file mode 100644 index 0000000..0c1491f --- /dev/null +++ b/.github/workflows/continuous.integration.yml @@ -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@v4 + 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@v4 + if: always() + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 \ No newline at end of file From d93c43e1e74278e319d881fc5c8bef9aa8b53b9c Mon Sep 17 00:00:00 2001 From: andrechalella Date: Thu, 4 Sep 2025 17:16:15 +0000 Subject: [PATCH 2/4] Fix dir name --- docs/{.tetris.game => tetris.game}/LICENSE | 0 docs/{.tetris.game => tetris.game}/README.txt | 0 docs/{.tetris.game => tetris.game}/app.js | 0 docs/{.tetris.game => tetris.game}/app.test.js | 0 docs/{.tetris.game => tetris.game}/index.html | 0 docs/{.tetris.game => tetris.game}/stats.js | 0 docs/{.tetris.game => tetris.game}/style.css | 0 docs/{.tetris.game => tetris.game}/texture.jpg | Bin 8 files changed, 0 insertions(+), 0 deletions(-) rename docs/{.tetris.game => tetris.game}/LICENSE (100%) rename docs/{.tetris.game => tetris.game}/README.txt (100%) rename docs/{.tetris.game => tetris.game}/app.js (100%) rename docs/{.tetris.game => tetris.game}/app.test.js (100%) rename docs/{.tetris.game => tetris.game}/index.html (100%) rename docs/{.tetris.game => tetris.game}/stats.js (100%) rename docs/{.tetris.game => tetris.game}/style.css (100%) rename docs/{.tetris.game => tetris.game}/texture.jpg (100%) diff --git a/docs/.tetris.game/LICENSE b/docs/tetris.game/LICENSE similarity index 100% rename from docs/.tetris.game/LICENSE rename to docs/tetris.game/LICENSE diff --git a/docs/.tetris.game/README.txt b/docs/tetris.game/README.txt similarity index 100% rename from docs/.tetris.game/README.txt rename to docs/tetris.game/README.txt diff --git a/docs/.tetris.game/app.js b/docs/tetris.game/app.js similarity index 100% rename from docs/.tetris.game/app.js rename to docs/tetris.game/app.js diff --git a/docs/.tetris.game/app.test.js b/docs/tetris.game/app.test.js similarity index 100% rename from docs/.tetris.game/app.test.js rename to docs/tetris.game/app.test.js diff --git a/docs/.tetris.game/index.html b/docs/tetris.game/index.html similarity index 100% rename from docs/.tetris.game/index.html rename to docs/tetris.game/index.html diff --git a/docs/.tetris.game/stats.js b/docs/tetris.game/stats.js similarity index 100% rename from docs/.tetris.game/stats.js rename to docs/tetris.game/stats.js diff --git a/docs/.tetris.game/style.css b/docs/tetris.game/style.css similarity index 100% rename from docs/.tetris.game/style.css rename to docs/tetris.game/style.css diff --git a/docs/.tetris.game/texture.jpg b/docs/tetris.game/texture.jpg similarity index 100% rename from docs/.tetris.game/texture.jpg rename to docs/tetris.game/texture.jpg From 346c0aac285510ea6ed66e05e3b4f8623381c861 Mon Sep 17 00:00:00 2001 From: andrechalella Date: Thu, 4 Sep 2025 17:33:15 +0000 Subject: [PATCH 3/4] Add initial test for Tetris game functionality --- .github/tests/tetris.spec.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/tests/tetris.spec.js diff --git a/.github/tests/tetris.spec.js b/.github/tests/tetris.spec.js new file mode 100644 index 0000000..0965060 --- /dev/null +++ b/.github/tests/tetris.spec.js @@ -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, + }); +}); \ No newline at end of file From 356b391679152583add542efa60794f6a0340a2c Mon Sep 17 00:00:00 2001 From: andrechalella Date: Thu, 4 Sep 2025 17:42:14 +0000 Subject: [PATCH 4/4] Fix test location --- {.github/tests => tests}/tetris.spec.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {.github/tests => tests}/tetris.spec.js (100%) diff --git a/.github/tests/tetris.spec.js b/tests/tetris.spec.js similarity index 100% rename from .github/tests/tetris.spec.js rename to tests/tetris.spec.js