From 4dd5283b3a80c9d7c2f3f91e496ab0ff777dee6a Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sun, 12 Nov 2023 19:14:15 +0400 Subject: [PATCH 01/35] Initial playwright integration --- .github/workflows/docker-image.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index e682e4b8..9fbb411a 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -33,6 +33,23 @@ jobs: dockerfile: "Dockerfile" config: "hadolint.yaml" + e2e: + timeout-minutes: 60 + runs-on: ubuntu-latest + container: + image: mcr.microsoft.com/playwright:v1.39.0-jammy + if: github.event_name == 'push' || github.event_name == 'pull_request' + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Install dependencies + run: npm ci + - name: Run your tests + run: npx playwright test + + # Push image to GitHub Packages. # The image tag pattern is: # for pull-requests: --, eg: 1.35.2-20210125-25 From e8a399904d12b2a68847c0facda0b6614c2a75f9 Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sun, 12 Nov 2023 19:19:52 +0400 Subject: [PATCH 02/35] Test --- .github/workflows/docker-image.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 9fbb411a..95b87312 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -38,12 +38,16 @@ jobs: runs-on: ubuntu-latest container: image: mcr.microsoft.com/playwright:v1.39.0-jammy +# volumes: +# - ./e2e:/ if: github.event_name == 'push' || github.event_name == 'pull_request' steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: 18 + - name: Test + run: echo pwd - name: Install dependencies run: npm ci - name: Run your tests From 0af71b8547fe65fa335934f1533c4a8eafd484e8 Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sun, 12 Nov 2023 19:20:54 +0400 Subject: [PATCH 03/35] Test --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 95b87312..4544ee87 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -47,7 +47,7 @@ jobs: with: node-version: 18 - name: Test - run: echo pwd + run: pwd - name: Install dependencies run: npm ci - name: Run your tests From 0112c46e72e4936fb426ae99a0f4172315990f0d Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sun, 12 Nov 2023 19:23:22 +0400 Subject: [PATCH 04/35] Test --- .github/workflows/docker-image.yml | 12 +++++------- e2e/tests/example.spec.ts | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 e2e/tests/example.spec.ts diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 4544ee87..1182f253 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -38,22 +38,20 @@ jobs: runs-on: ubuntu-latest container: image: mcr.microsoft.com/playwright:v1.39.0-jammy -# volumes: -# - ./e2e:/ + volumes: + - ./e2e:/usr/playwright if: github.event_name == 'push' || github.event_name == 'pull_request' steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: 18 - - name: Test - run: pwd - - name: Install dependencies - run: npm ci +# - name: Install dependencies +# run: npm ci - name: Run your tests + working-directory: /usr/playwright run: npx playwright test - # Push image to GitHub Packages. # The image tag pattern is: # for pull-requests: --, eg: 1.35.2-20210125-25 diff --git a/e2e/tests/example.spec.ts b/e2e/tests/example.spec.ts new file mode 100644 index 00000000..54a906a4 --- /dev/null +++ b/e2e/tests/example.spec.ts @@ -0,0 +1,18 @@ +import { test, expect } from '@playwright/test'; + +test('has title', async ({ page }) => { + await page.goto('https://playwright.dev/'); + + // Expect a title "to contain" a substring. + await expect(page).toHaveTitle(/Playwright/); +}); + +test('get started link', async ({ page }) => { + await page.goto('https://playwright.dev/'); + + // Click the get started link. + await page.getByRole('link', { name: 'Get started' }).click(); + + // Expects page to have a heading with the name of Installation. + await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); +}); From df8235fe37974219507687235260b131cc107e16 Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sun, 12 Nov 2023 19:26:53 +0400 Subject: [PATCH 05/35] Test --- .github/workflows/docker-image.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 1182f253..ee32820f 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -43,9 +43,9 @@ jobs: if: github.event_name == 'push' || github.event_name == 'pull_request' steps: - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 18 +# - uses: actions/setup-node@v3 +# with: +# node-version: 18 # - name: Install dependencies # run: npm ci - name: Run your tests From 9b4b17c5eaf615b995b39a0e3b4ea5b56446cd58 Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sun, 12 Nov 2023 19:31:34 +0400 Subject: [PATCH 06/35] Test --- .github/workflows/docker-image.yml | 28 +++++---- e2e/.gitignore | 5 ++ e2e/package-lock.json | 91 ++++++++++++++++++++++++++++++ e2e/package.json | 17 ++++++ e2e/playwright.config.ts | 77 +++++++++++++++++++++++++ 5 files changed, 207 insertions(+), 11 deletions(-) create mode 100644 e2e/.gitignore create mode 100644 e2e/package-lock.json create mode 100644 e2e/package.json create mode 100644 e2e/playwright.config.ts diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index ee32820f..daeab2cb 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -36,21 +36,27 @@ jobs: e2e: timeout-minutes: 60 runs-on: ubuntu-latest - container: - image: mcr.microsoft.com/playwright:v1.39.0-jammy - volumes: - - ./e2e:/usr/playwright if: github.event_name == 'push' || github.event_name == 'pull_request' steps: - uses: actions/checkout@v3 -# - uses: actions/setup-node@v3 -# with: -# node-version: 18 -# - name: Install dependencies -# run: npm ci - - name: Run your tests - working-directory: /usr/playwright + - uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Install dependencies + working-directory: ./e2e + run: npm ci + - name: Install Playwright Browsers + working-directory: ./e2e + run: npx playwright install --with-deps + - name: Run Playwright tests + working-directory: ./e2e run: npx playwright test + - uses: actions/upload-artifact@v3 + if: always() + with: + name: playwright-report + path: e2e/playwright-report/ + retention-days: 30 # Push image to GitHub Packages. # The image tag pattern is: diff --git a/e2e/.gitignore b/e2e/.gitignore new file mode 100644 index 00000000..68c5d18f --- /dev/null +++ b/e2e/.gitignore @@ -0,0 +1,5 @@ +node_modules/ +/test-results/ +/playwright-report/ +/blob-report/ +/playwright/.cache/ diff --git a/e2e/package-lock.json b/e2e/package-lock.json new file mode 100644 index 00000000..970377d0 --- /dev/null +++ b/e2e/package-lock.json @@ -0,0 +1,91 @@ +{ + "name": "e2e", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "e2e", + "version": "1.0.0", + "license": "ISC", + "devDependencies": { + "@playwright/test": "^1.39.0", + "@types/node": "^20.9.0" + } + }, + "node_modules/@playwright/test": { + "version": "1.39.0", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.39.0.tgz", + "integrity": "sha512-3u1iFqgzl7zr004bGPYiN/5EZpRUSFddQBra8Rqll5N0/vfpqlP9I9EXqAoGacuAbX6c9Ulg/Cjqglp5VkK6UQ==", + "dev": true, + "dependencies": { + "playwright": "1.39.0" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/@types/node": { + "version": "20.9.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.9.0.tgz", + "integrity": "sha512-nekiGu2NDb1BcVofVcEKMIwzlx4NjHlcjhoxxKBNLtz15Y1z7MYf549DFvkHSId02Ax6kGwWntIBPC3l/JZcmw==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/playwright": { + "version": "1.39.0", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.39.0.tgz", + "integrity": "sha512-naE5QT11uC/Oiq0BwZ50gDmy8c8WLPRTEWuSSFVG2egBka/1qMoSqYQcROMT9zLwJ86oPofcTH2jBY/5wWOgIw==", + "dev": true, + "dependencies": { + "playwright-core": "1.39.0" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=16" + }, + "optionalDependencies": { + "fsevents": "2.3.2" + } + }, + "node_modules/playwright-core": { + "version": "1.39.0", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.39.0.tgz", + "integrity": "sha512-+k4pdZgs1qiM+OUkSjx96YiKsXsmb59evFoqv8SKO067qBA+Z2s/dCzJij/ZhdQcs2zlTAgRKfeiiLm8PQ2qvw==", + "dev": true, + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + } + } +} diff --git a/e2e/package.json b/e2e/package.json new file mode 100644 index 00000000..02a61cbf --- /dev/null +++ b/e2e/package.json @@ -0,0 +1,17 @@ +{ + "name": "e2e", + "version": "1.0.0", + "description": "", + "main": "index.js", + "directories": { + "test": "tests" + }, + "scripts": {}, + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "@playwright/test": "^1.39.0", + "@types/node": "^20.9.0" + } +} diff --git a/e2e/playwright.config.ts b/e2e/playwright.config.ts new file mode 100644 index 00000000..301801ee --- /dev/null +++ b/e2e/playwright.config.ts @@ -0,0 +1,77 @@ +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', + /* Run tests in files in parallel */ + fullyParallel: true, + /* Fail the build on CI if you accidentally left test.only in the source code. */ + forbidOnly: !!process.env.CI, + /* Retry on CI only */ + retries: process.env.CI ? 2 : 0, + /* Opt out of parallel tests on CI. */ + workers: process.env.CI ? 1 : undefined, + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ + reporter: 'html', + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ + use: { + /* Base URL to use in actions like `await page.goto('/')`. */ + // baseURL: 'http://127.0.0.1:3000', + + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: 'on-first-retry', + }, + + /* Configure projects for major browsers */ + projects: [ + { + name: 'chromium', + use: { ...devices['Desktop Chrome'] }, + }, + + { + name: 'firefox', + use: { ...devices['Desktop Firefox'] }, + }, + + { + name: 'webkit', + use: { ...devices['Desktop Safari'] }, + }, + + /* Test against mobile viewports. */ + // { + // name: 'Mobile Chrome', + // use: { ...devices['Pixel 5'] }, + // }, + // { + // name: 'Mobile Safari', + // use: { ...devices['iPhone 12'] }, + // }, + + /* Test against branded browsers. */ + // { + // name: 'Microsoft Edge', + // use: { ...devices['Desktop Edge'], channel: 'msedge' }, + // }, + // { + // name: 'Google Chrome', + // use: { ...devices['Desktop Chrome'], channel: 'chrome' }, + // }, + ], + + /* Run your local dev server before starting the tests */ + // webServer: { + // command: 'npm run start', + // url: 'http://127.0.0.1:3000', + // reuseExistingServer: !process.env.CI, + // }, +}); From d717b2da0f4f22ef931b777238a920a8cd62002b Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sun, 12 Nov 2023 19:46:39 +0400 Subject: [PATCH 07/35] Test --- .github/workflows/docker-image.yml | 96 ++++++++++++++++++------------ e2e/playwright.config.ts | 18 +++--- 2 files changed, 67 insertions(+), 47 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index daeab2cb..86963d5b 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -33,46 +33,24 @@ jobs: dockerfile: "Dockerfile" config: "hadolint.yaml" - e2e: - timeout-minutes: 60 - runs-on: ubuntu-latest - if: github.event_name == 'push' || github.event_name == 'pull_request' - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 18 - - name: Install dependencies - working-directory: ./e2e - run: npm ci - - name: Install Playwright Browsers - working-directory: ./e2e - run: npx playwright install --with-deps - - name: Run Playwright tests - working-directory: ./e2e - run: npx playwright test - - uses: actions/upload-artifact@v3 - if: always() - with: - name: playwright-report - path: e2e/playwright-report/ - retention-days: 30 - - # Push image to GitHub Packages. # The image tag pattern is: # for pull-requests: --, eg: 1.35.2-20210125-25 # for tags: # for `master` branch: latest + -latest + -- # being parsed from the Dockerfile - push: - needs: [test] + tags: + needs: [ test ] runs-on: ubuntu-latest if: github.event_name == 'push' || github.event_name == 'pull_request' + outputs: + REGISTRY_TAGS: ${{ steps.generate.outputs.REGISTRY_TAGS }} + REGISTRY_TAGS_VERSION: ${{ steps.generate.outputs.REGISTRY_TAGS_VERSION }} + REGISTRY_TAGS_PR_NUMBER: ${{ steps.generate.outputs.REGISTRY_TAGS_PR_NUMBER }} + SHA_SHORT: ${{ steps.generate.outputs.SHA_SHORT }} steps: - name: Checkout uses: actions/checkout@v3 - - - name: Generate tags + - name: Generate tags id: generate run: | @@ -92,7 +70,7 @@ jobs: # Strip git ref prefix from version and use it as suffix for version VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') - + # Get the Taqasta version from the "VERSION" file TAQASTA_VERSION=$(cat VERSION) @@ -118,13 +96,13 @@ jobs: SHA_SHORT=${{ github.sha }} [ "${{ github.event_name }}" == "pull_request" ] && SHA_SHORT=$(echo ${{ github.event.pull_request.head.sha }} | cut -c1-8) - + echo IMAGE_ID=$IMAGE_ID echo VERSION=$VERSION echo REGISTRY_TAGS=$REGISTRY_TAGS echo SHA_SHORT=$SHA_SHORT echo EventName=${{ github.event_name }} - + echo headref=${{ github.head_ref }} echo "Final image tag to be pushed:" echo $REGISTRY_TAGS @@ -132,6 +110,43 @@ jobs: echo "REGISTRY_TAGS_VERSION=$VERSION" >> $GITHUB_OUTPUT echo "REGISTRY_TAGS_PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_OUTPUT + +# e2e: +# timeout-minutes: 60 +# runs-on: ubuntu-latest +# if: github.event_name == 'push' || github.event_name == 'pull_request' +# steps: +# - uses: actions/checkout@v3 +# - uses: actions/setup-node@v3 +# with: +# node-version: 18 +# - name: Install dependencies +# working-directory: ./e2e +# run: npm ci +# - name: Install Playwright Browsers +# working-directory: ./e2e +# run: npx playwright install chromium --with-deps +# - name: Run Playwright tests +# working-directory: ./e2e +# run: npx playwright test +# - uses: actions/upload-artifact@v3 +# if: always() +# with: +# name: playwright-report +# path: e2e/playwright-report/ +# retention-days: 30 + + # Builds & pushes the image to GitHub registry + push: + needs: [tags] + runs-on: ubuntu-latest + outputs: + digest: ${{ steps.docker_build.outputs.digest }} + imageid: ${{ steps.docker_build.outputs.imageid }} + if: github.event_name == 'push' || github.event_name == 'pull_request' + steps: + - name: Checkout + uses: actions/checkout@v3 - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -165,7 +180,7 @@ jobs: secrets: | COMPOSER_TOKEN=${{ secrets.GITHUB_TOKEN }} push: true - tags: ${{ steps.generate.outputs.REGISTRY_TAGS }} + tags: ${{ needs.tags.outputs.REGISTRY_TAGS }} cache-from: type=gha cache-to: type=gha,mode=max - @@ -173,17 +188,22 @@ jobs: run: echo ${{ steps.docker_build.outputs.digest }} - name: Image tags debug - run: echo ${{ steps.generate.outputs.REGISTRY_TAGS }} + run: echo ${{ needs.tags.outputs.REGISTRY_TAGS }} + notify: + needs: [push] + runs-on: ubuntu-latest + if: github.event_name == 'push' || github.event_name == 'pull_request' + steps: - name: Notify about image tag - if: github.event_name == 'pull_request' && steps.docker_build.outputs.digest != '' - uses: hasura/comment-progress@v2.2.0 + if: github.event_name == 'pull_request' && needs.push.outputs.digest != '' + uses: hasura/comment-progress@v2.3.0 with: github-token: ${{ secrets.GITHUB_TOKEN }} repository: ${{ github.repository }} number: ${{ github.event.number }} id: comment - message: ":whale: The image based on [${{ steps.generate.outputs.SHA_SHORT }}](https://github.com/WikiTeq/Taqasta/pull/${{ steps.generate.outputs.REGISTRY_TAGS_PR_NUMBER }}/commits/${{ github.event.pull_request.head.sha }}) commit has been built with `${{ steps.generate.outputs.REGISTRY_TAGS_VERSION }}` tag as [${{ steps.generate.outputs.REGISTRY_TAGS }}](https://github.com/${{ github.repository }}/pkgs/container/${{ env.IMAGE_NAME }}/${{ steps.docker_build.outputs.imageid }}?tag=${{ steps.generate.outputs.REGISTRY_TAGS_VERSION }})" + message: ":whale: The image based on [${{ needs.tags.outputs.SHA_SHORT }}](https://github.com/WikiTeq/Taqasta/pull/${{ needs.tags.outputs.REGISTRY_TAGS_PR_NUMBER }}/commits/${{ github.event.pull_request.head.sha }}) commit has been built with `${{ needs.tags.outputs.REGISTRY_TAGS_VERSION }}` tag as [${{ needs.tags.outputs.REGISTRY_TAGS }}](https://github.com/${{ github.repository }}/pkgs/container/${{ env.IMAGE_NAME }}/${{ needs.push.outputs.imageid }}?tag=${{ needs.tags.outputs.REGISTRY_TAGS_VERSION }})" recreate: true fail: false diff --git a/e2e/playwright.config.ts b/e2e/playwright.config.ts index 301801ee..10745502 100644 --- a/e2e/playwright.config.ts +++ b/e2e/playwright.config.ts @@ -37,15 +37,15 @@ export default defineConfig({ use: { ...devices['Desktop Chrome'] }, }, - { - name: 'firefox', - use: { ...devices['Desktop Firefox'] }, - }, - - { - name: 'webkit', - use: { ...devices['Desktop Safari'] }, - }, + // { + // name: 'firefox', + // use: { ...devices['Desktop Firefox'] }, + // }, + // + // { + // name: 'webkit', + // use: { ...devices['Desktop Safari'] }, + // }, /* Test against mobile viewports. */ // { From 3abec60e0319562cffcea57b8ec12d9f6b67acec Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sun, 12 Nov 2023 19:49:54 +0400 Subject: [PATCH 08/35] Test --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 86963d5b..0a772722 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -191,7 +191,7 @@ jobs: run: echo ${{ needs.tags.outputs.REGISTRY_TAGS }} notify: - needs: [push] + needs: [tags,push] runs-on: ubuntu-latest if: github.event_name == 'push' || github.event_name == 'pull_request' steps: From d64cf7582ed28f533548c5359e04967c973d609b Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sun, 12 Nov 2023 20:59:33 +0400 Subject: [PATCH 09/35] Test --- .env.ci | 34 ++++++++++++++ .github/workflows/docker-image.yml | 22 ++++++++- docker-compose.yml | 73 ++++++++++++++++++++++++++++++ 3 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 .env.ci create mode 100644 docker-compose.yml diff --git a/.env.ci b/.env.ci new file mode 100644 index 00000000..2717743e --- /dev/null +++ b/.env.ci @@ -0,0 +1,34 @@ +PORT=80 +MW_SITE_SERVER=http://localhost:80 +MW_SITE_NAME=MyWiki +MW_SITE_LANG=en +MW_ENABLE_UPLOADS=1 +MW_USE_INSTANT_COMMONS=0 +MW_AUTOUPDATE=true +MW_MAIN_CACHE_TYPE=CACHE_NONE +MW_LOAD_SKINS=Vector +MW_DEFAULT_SKIN=vector +MW_LOAD_EXTENSIONS=ParserFunctions +MW_USE_CACHE_DIRECTORY= +MW_SHOW_EXCEPTION_DETAILS=true +MW_USE_IMAGE_MAGIC= +MW_MEMCACHED_SERVERS= +MW_PROXY_SERVERS= +MW_FLOW_NAMESPACES= +MW_ENABLE_SITEMAP_GENERATOR= + + +MW_ADMIN_USER=admin +MW_ADMIN_PASS=rand0mmysqlpassw0rd1! + +MW_DB_INSTALLDB_PASS=mediawiki +MW_DB_TYPE=mysql + +MW_DB_NAME=mediawiki +MW_DB_PASS=mediawiki +MW_SECRET_KEY=jf843y8973098waujda9odu89seyf9s4fy98sof49gyh47e3w9yhf9os + +MW_ENABLE_EMAIL=false +MW_ENABLE_USER_EMAIL=false +MW_EMERGENCY_CONTACT=apache@invalid +MW_PASSWORD_SENDER=apache@invalid diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 0a772722..0ae88d24 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -111,6 +111,26 @@ jobs: echo "REGISTRY_TAGS_PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_OUTPUT + deploy: + needs: [tags] + runs-on: ubuntu-latest + if: github.event_name == 'push' || github.event_name == 'pull_request' + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Docker Compose + uses: yu-ichiro/spin-up-docker-compose-action@main + env: + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + file: docker-compose.yml + cache-key: simple-docker-compose + + - name: Give containers a moment to init + shell: bash + run: sleep 30s + # e2e: # timeout-minutes: 60 # runs-on: ubuntu-latest @@ -138,7 +158,7 @@ jobs: # Builds & pushes the image to GitHub registry push: - needs: [tags] + needs: [deploy] runs-on: ubuntu-latest outputs: digest: ${{ steps.docker_build.outputs.digest }} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..9225d946 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,73 @@ +version: '3.1' +services: + db: + image: mysql:8.0 + command: --default-authentication-plugin=mysql_native_password --expire_logs_days=3 + cap_add: + - SYS_NICE # CAP_SYS_NICE, fix error mbind: Operation not permitted + restart: unless-stopped + environment: + - MYSQL_ROOT_HOST=% + - MYSQL_ROOT_PASSWORD=${MW_DB_INSTALLDB_PASS:-mediawiki} + - MYSQL_DATABASE=${MW_DB_NAME:-mediawiki} + volumes: + - initdb:/docker-entrypoint-initdb.d + - mysql:/var/lib/mysql + + web: + build: + context: . + dockerfile: Dockerfile + args: + COMPOSER_TOKEN: ${COMPOSER_TOKEN:-} + restart: unless-stopped + ports: + - "${PORT:-127.0.0.1:8081}:80" + links: + - db + env_file: + - .env.ci + environment: + - MW_ADMIN_USER=${MW_ADMIN_USER:-admin} + - MW_ADMIN_PASS=${MW_ADMIN_PASS:-Passsw0rd!} + - MW_DB_NAME=${MW_DB_NAME:-mediawiki} + - MW_DB_INSTALLDB_USER=root + - MW_DB_INSTALLDB_PASS=${MW_DB_INSTALLDB_PASS:-mediawiki} + - MW_DB_USER=root + - MW_DB_PASS=${MW_DB_PASS:-mediawiki} + - MW_SECRET_KEY + - MW_SITE_SERVER + - MW_SITE_NAME + - MW_SITE_LANG + - MW_ENABLE_UPLOADS + - MW_USE_INSTANT_COMMONS + - MW_AUTOUPDATE + - MW_MAIN_CACHE_TYPE + - MW_LOAD_SKINS=${MW_LOAD_SKINS:-Vector,chameleon} + - MW_DEFAULT_SKIN=${MW_DEFAULT_SKIN:-chameleon} + - MW_LOAD_EXTENSIONS=${MW_LOAD_EXTENSIONS:-ParserFunctions,WikiEditor} + - MW_ENABLE_EMAIL + - MW_ENABLE_USER_EMAIL + - MW_EMERGENCY_CONTACT + - MW_PASSWORD_SENDER + - MW_DB_TYPE=${MW_DB_TYPE:-mysql} + - MW_USE_CACHE_DIRECTORY + - MW_SHOW_EXCEPTION_DETAILS + - MW_MEMCACHED_SERVERS + - MW_PROXY_SERVERS + - MW_FLOW_NAMESPACES + - MW_SEARCH_TYPE + - MW_ENABLE_SITEMAP_GENERATOR + - MW_CIRRUS_SEARCH_SERVERS + - PHP_UPLOAD_MAX_FILESIZE=500M + - PHP_POST_MAX_SIZE=500M + - MW_DEBUG_MODE + volumes: + - mediawiki:/mediawiki + - settings:/var/www/mediawiki/w/_settings + +volumes: + mediawiki: + mysql: + initdb: + settings: From 6872884deced8bc078bf95c191e75160ac956e0a Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sun, 12 Nov 2023 21:10:38 +0400 Subject: [PATCH 10/35] Test --- .github/workflows/docker-image.yml | 105 +++++++++++++++++++++-------- e2e/tests/example.spec.ts | 14 +--- 2 files changed, 79 insertions(+), 40 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 0ae88d24..5e3bafe7 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -20,7 +20,7 @@ env: IMAGE_NAME: taqasta jobs: - # Test the image Dockerfile syntax using https://github.com/replicatedhq/dockerfilelint + # Lint the image Dockerfile syntax using https://github.com/replicatedhq/dockerfilelint test: runs-on: ubuntu-latest if: github.event_name == 'push' || github.event_name == 'pull_request' @@ -33,6 +33,7 @@ jobs: dockerfile: "Dockerfile" config: "hadolint.yaml" + # Generate image tags # The image tag pattern is: # for pull-requests: --, eg: 1.35.2-20210125-25 # for tags: @@ -111,10 +112,56 @@ jobs: echo "REGISTRY_TAGS_PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_OUTPUT - deploy: + # Pre-build the image, no push + build: needs: [tags] runs-on: ubuntu-latest if: github.event_name == 'push' || github.event_name == 'pull_request' + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + with: + install: true + + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v3 + with: + context: . + platforms: linux/amd64, linux/arm64 + secrets: | + COMPOSER_TOKEN=${{ secrets.GITHUB_TOKEN }} + push: false + tags: ${{ needs.tags.outputs.REGISTRY_TAGS }} + cache-from: type=gha + cache-to: type=gha,mode=max + + # Deploy via Compose + deploy: + needs: [build] + runs-on: ubuntu-latest + if: github.event_name == 'push' || github.event_name == 'pull_request' steps: - name: Checkout uses: actions/checkout@v3 @@ -131,32 +178,33 @@ jobs: shell: bash run: sleep 30s -# e2e: -# timeout-minutes: 60 -# runs-on: ubuntu-latest -# if: github.event_name == 'push' || github.event_name == 'pull_request' -# steps: -# - uses: actions/checkout@v3 -# - uses: actions/setup-node@v3 -# with: -# node-version: 18 -# - name: Install dependencies -# working-directory: ./e2e -# run: npm ci -# - name: Install Playwright Browsers -# working-directory: ./e2e -# run: npx playwright install chromium --with-deps -# - name: Run Playwright tests -# working-directory: ./e2e -# run: npx playwright test -# - uses: actions/upload-artifact@v3 -# if: always() -# with: -# name: playwright-report -# path: e2e/playwright-report/ -# retention-days: 30 - - # Builds & pushes the image to GitHub registry + # Do some end-to-end testing + e2e: + timeout-minutes: 30 + runs-on: ubuntu-latest + if: github.event_name == 'push' || github.event_name == 'pull_request' + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Install dependencies + working-directory: ./e2e + run: npm ci + - name: Install Playwright Browsers + working-directory: ./e2e + run: npx playwright install chromium --with-deps + - name: Run Playwright tests + working-directory: ./e2e + run: npx playwright test + - uses: actions/upload-artifact@v3 + if: always() + with: + name: playwright-report + path: e2e/playwright-report/ + retention-days: 10 + + # Builds from cache & push the image to GitHub registry this time push: needs: [deploy] runs-on: ubuntu-latest @@ -210,6 +258,7 @@ jobs: name: Image tags debug run: echo ${{ needs.tags.outputs.REGISTRY_TAGS }} + # Send a message to the PR thread notify: needs: [tags,push] runs-on: ubuntu-latest diff --git a/e2e/tests/example.spec.ts b/e2e/tests/example.spec.ts index 54a906a4..9211c88c 100644 --- a/e2e/tests/example.spec.ts +++ b/e2e/tests/example.spec.ts @@ -1,18 +1,8 @@ import { test, expect } from '@playwright/test'; test('has title', async ({ page }) => { - await page.goto('https://playwright.dev/'); + await page.goto('http://localhost:80/'); // Expect a title "to contain" a substring. - await expect(page).toHaveTitle(/Playwright/); -}); - -test('get started link', async ({ page }) => { - await page.goto('https://playwright.dev/'); - - // Click the get started link. - await page.getByRole('link', { name: 'Get started' }).click(); - - // Expects page to have a heading with the name of Installation. - await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); + await expect(page).toHaveTitle(/MediaWiki/); }); From 993a432b0ddebeb81e9cff88ef1f545aa2e679b8 Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sun, 12 Nov 2023 21:11:16 +0400 Subject: [PATCH 11/35] Test --- .github/workflows/docker-image.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 5e3bafe7..6aceba81 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -180,6 +180,7 @@ jobs: # Do some end-to-end testing e2e: + needs: [deploy] timeout-minutes: 30 runs-on: ubuntu-latest if: github.event_name == 'push' || github.event_name == 'pull_request' @@ -206,7 +207,7 @@ jobs: # Builds from cache & push the image to GitHub registry this time push: - needs: [deploy] + needs: [e2e] runs-on: ubuntu-latest outputs: digest: ${{ steps.docker_build.outputs.digest }} From 02d51c38da8aeda731347b6606a6a93efc78adaa Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sun, 12 Nov 2023 21:12:12 +0400 Subject: [PATCH 12/35] Test --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 6aceba81..086cb625 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -207,7 +207,7 @@ jobs: # Builds from cache & push the image to GitHub registry this time push: - needs: [e2e] + needs: [tags,e2e] runs-on: ubuntu-latest outputs: digest: ${{ steps.docker_build.outputs.digest }} From 37eb54c815261578efdf0fc8e1cea11ed39700c5 Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sun, 12 Nov 2023 21:22:47 +0400 Subject: [PATCH 13/35] Test --- .github/workflows/docker-image.yml | 43 ++++++++++++++++++------------ 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 086cb625..5349f7bc 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -116,6 +116,11 @@ jobs: build: needs: [tags] runs-on: ubuntu-latest +# services: +# registry: +# image: registry:2 +# ports: +# - 5000:5000 if: github.event_name == 'push' || github.event_name == 'pull_request' steps: - name: Checkout @@ -137,13 +142,6 @@ jobs: restore-keys: | ${{ runner.os }}-buildx- - - name: Login to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push id: docker_build uses: docker/build-push-action@v3 @@ -158,33 +156,44 @@ jobs: cache-to: type=gha,mode=max # Deploy via Compose - deploy: + deploy-e2e: needs: [build] + timeout-minutes: 30 runs-on: ubuntu-latest if: github.event_name == 'push' || github.event_name == 'pull_request' steps: - name: Checkout uses: actions/checkout@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + with: + install: true + + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + - name: Setup Docker Compose uses: yu-ichiro/spin-up-docker-compose-action@main env: COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DOCKER_BUILDKIT: 1 + COMPOSE_DOCKER_CLI_BUILD: 1 with: file: docker-compose.yml - cache-key: simple-docker-compose + cache-key: ${{ runner.os }}-buildx-${{ github.sha }} + shared: true +# registry: true - name: Give containers a moment to init shell: bash run: sleep 30s - # Do some end-to-end testing - e2e: - needs: [deploy] - timeout-minutes: 30 - runs-on: ubuntu-latest - if: github.event_name == 'push' || github.event_name == 'pull_request' - steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: @@ -207,7 +216,7 @@ jobs: # Builds from cache & push the image to GitHub registry this time push: - needs: [tags,e2e] + needs: [tags,deploy-e2e] runs-on: ubuntu-latest outputs: digest: ${{ steps.docker_build.outputs.digest }} From 80b15840300d6771f9b60b10a91dcdbe3c157776 Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sun, 12 Nov 2023 21:25:05 +0400 Subject: [PATCH 14/35] Test --- .github/workflows/docker-image.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 5349f7bc..60534859 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -21,7 +21,7 @@ env: jobs: # Lint the image Dockerfile syntax using https://github.com/replicatedhq/dockerfilelint - test: + lint: runs-on: ubuntu-latest if: github.event_name == 'push' || github.event_name == 'pull_request' steps: @@ -40,7 +40,7 @@ jobs: # for `master` branch: latest + -latest + -- # being parsed from the Dockerfile tags: - needs: [ test ] + needs: [lint] runs-on: ubuntu-latest if: github.event_name == 'push' || github.event_name == 'pull_request' outputs: @@ -187,7 +187,7 @@ jobs: with: file: docker-compose.yml cache-key: ${{ runner.os }}-buildx-${{ github.sha }} - shared: true +# shared: true # registry: true - name: Give containers a moment to init From ddd1545472aa1f7244590726b460479ef5fc6367 Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sun, 12 Nov 2023 21:26:44 +0400 Subject: [PATCH 15/35] Test --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 60534859..fa001eee 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -188,7 +188,7 @@ jobs: file: docker-compose.yml cache-key: ${{ runner.os }}-buildx-${{ github.sha }} # shared: true -# registry: true +# registry: true - name: Give containers a moment to init shell: bash From e84213de8f79dd1420217491ae89a3e7ed0a6411 Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sun, 12 Nov 2023 21:28:02 +0400 Subject: [PATCH 16/35] Test2 --- .github/workflows/docker-image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index fa001eee..1c9c1d17 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -188,7 +188,7 @@ jobs: file: docker-compose.yml cache-key: ${{ runner.os }}-buildx-${{ github.sha }} # shared: true -# registry: true +# registry: true - name: Give containers a moment to init shell: bash @@ -268,7 +268,7 @@ jobs: name: Image tags debug run: echo ${{ needs.tags.outputs.REGISTRY_TAGS }} - # Send a message to the PR thread + # Send a message to the PR thread notify: needs: [tags,push] runs-on: ubuntu-latest From c568d378f82eaa867626839ea3e0c190fac5c7c0 Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sun, 12 Nov 2023 21:32:35 +0400 Subject: [PATCH 17/35] Test2 --- .github/workflows/docker-image.yml | 39 ++++++++++++++++++++---------- docker-compose.yml | 6 +---- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 1c9c1d17..961792ae 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -116,11 +116,11 @@ jobs: build: needs: [tags] runs-on: ubuntu-latest -# services: -# registry: -# image: registry:2 -# ports: -# - 5000:5000 + services: + registry: + image: registry:2 + ports: + - 5000:5000 if: github.event_name == 'push' || github.event_name == 'pull_request' steps: - name: Checkout @@ -133,6 +133,7 @@ jobs: uses: docker/setup-buildx-action@v2 with: install: true + driver-opts: network=host - name: Cache Docker layers uses: actions/cache@v3 @@ -150,8 +151,8 @@ jobs: platforms: linux/amd64, linux/arm64 secrets: | COMPOSER_TOKEN=${{ secrets.GITHUB_TOKEN }} - push: false - tags: ${{ needs.tags.outputs.REGISTRY_TAGS }} + push: true + tags: localhost:5000/taqasta/taqasta:latest cache-from: type=gha cache-to: type=gha,mode=max @@ -159,6 +160,11 @@ jobs: deploy-e2e: needs: [build] timeout-minutes: 30 + services: + registry: + image: registry:2 + ports: + - 5000:5000 runs-on: ubuntu-latest if: github.event_name == 'push' || github.event_name == 'pull_request' steps: @@ -169,6 +175,7 @@ jobs: uses: docker/setup-buildx-action@v2 with: install: true + driver-opts: network=host - name: Cache Docker layers uses: actions/cache@v3 @@ -179,16 +186,22 @@ jobs: ${{ runner.os }}-buildx- - name: Setup Docker Compose - uses: yu-ichiro/spin-up-docker-compose-action@main env: COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} DOCKER_BUILDKIT: 1 COMPOSE_DOCKER_CLI_BUILD: 1 - with: - file: docker-compose.yml - cache-key: ${{ runner.os }}-buildx-${{ github.sha }} -# shared: true -# registry: true + shell: bash + run: docker-compose up -d + +# - name: Setup Docker Compose +# uses: yu-ichiro/spin-up-docker-compose-action@main +# env: +# COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# DOCKER_BUILDKIT: 1 +# COMPOSE_DOCKER_CLI_BUILD: 1 +# with: +# file: docker-compose.yml +# cache-key: ${{ runner.os }}-buildx-${{ github.sha }} - name: Give containers a moment to init shell: bash diff --git a/docker-compose.yml b/docker-compose.yml index 9225d946..c6ea81d9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,11 +15,7 @@ services: - mysql:/var/lib/mysql web: - build: - context: . - dockerfile: Dockerfile - args: - COMPOSER_TOKEN: ${COMPOSER_TOKEN:-} + image: localhost:5000/taqasta/taqasta:latest restart: unless-stopped ports: - "${PORT:-127.0.0.1:8081}:80" From c3cffe7157fdb4a27b9114bfe713ab8ac2276fc7 Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sun, 12 Nov 2023 22:56:04 +0400 Subject: [PATCH 18/35] Test2 --- .github/workflows/docker-image.yml | 6 +++--- docker-compose.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 961792ae..b9e2e187 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -145,14 +145,14 @@ jobs: - name: Build and push id: docker_build - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5 with: context: . platforms: linux/amd64, linux/arm64 secrets: | COMPOSER_TOKEN=${{ secrets.GITHUB_TOKEN }} push: true - tags: localhost:5000/taqasta/taqasta:latest + tags: localhost:5000/taqasta:latest cache-from: type=gha cache-to: type=gha,mode=max @@ -264,7 +264,7 @@ jobs: - name: Build and push id: docker_build - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5 with: context: . platforms: linux/amd64, linux/arm64 diff --git a/docker-compose.yml b/docker-compose.yml index c6ea81d9..6e35d4c7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,7 +15,7 @@ services: - mysql:/var/lib/mysql web: - image: localhost:5000/taqasta/taqasta:latest + image: localhost:5000/taqasta:latest restart: unless-stopped ports: - "${PORT:-127.0.0.1:8081}:80" From b16fbe9644b8da4ec63474d035eaf69f15a3f00b Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sun, 12 Nov 2023 22:59:44 +0400 Subject: [PATCH 19/35] Test2 --- .github/workflows/docker-image.yml | 31 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index b9e2e187..b0c04b3b 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -116,11 +116,11 @@ jobs: build: needs: [tags] runs-on: ubuntu-latest - services: - registry: - image: registry:2 - ports: - - 5000:5000 +# services: +# registry: +# image: registry:2 +# ports: +# - 5000:5000 if: github.event_name == 'push' || github.event_name == 'pull_request' steps: - name: Checkout @@ -130,7 +130,7 @@ jobs: uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 with: install: true driver-opts: network=host @@ -151,8 +151,9 @@ jobs: platforms: linux/amd64, linux/arm64 secrets: | COMPOSER_TOKEN=${{ secrets.GITHUB_TOKEN }} - push: true - tags: localhost:5000/taqasta:latest +# push: true +# tags: localhost:5000/taqasta:latest + tags: ${{ needs.tags.outputs.REGISTRY_TAGS }} cache-from: type=gha cache-to: type=gha,mode=max @@ -160,11 +161,11 @@ jobs: deploy-e2e: needs: [build] timeout-minutes: 30 - services: - registry: - image: registry:2 - ports: - - 5000:5000 +# services: +# registry: +# image: registry:2 +# ports: +# - 5000:5000 runs-on: ubuntu-latest if: github.event_name == 'push' || github.event_name == 'pull_request' steps: @@ -172,7 +173,7 @@ jobs: uses: actions/checkout@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 with: install: true driver-opts: network=host @@ -243,7 +244,7 @@ jobs: uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 with: install: true - From 9a45af5678f927364ac30003b5a6dfa7d748ec65 Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sun, 12 Nov 2023 23:00:17 +0400 Subject: [PATCH 20/35] Test2 --- docker-compose.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 6e35d4c7..9c9693f0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,7 +15,9 @@ services: - mysql:/var/lib/mysql web: - image: localhost:5000/taqasta:latest + build: + context: . + dockerfile: Dockerfile restart: unless-stopped ports: - "${PORT:-127.0.0.1:8081}:80" From 97688a4b88dff0c689cd1a0becc6edbc34a59e9a Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sun, 12 Nov 2023 23:13:31 +0400 Subject: [PATCH 21/35] Test2 --- .github/workflows/docker-image.yml | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index b0c04b3b..0b610b00 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -40,7 +40,6 @@ jobs: # for `master` branch: latest + -latest + -- # being parsed from the Dockerfile tags: - needs: [lint] runs-on: ubuntu-latest if: github.event_name == 'push' || github.event_name == 'pull_request' outputs: @@ -116,6 +115,8 @@ jobs: build: needs: [tags] runs-on: ubuntu-latest + outputs: + builder_name: ${{ steps.docker_build.outputs.name }} # services: # registry: # image: registry:2 @@ -133,7 +134,6 @@ jobs: uses: docker/setup-buildx-action@v3 with: install: true - driver-opts: network=host - name: Cache Docker layers uses: actions/cache@v3 @@ -151,6 +151,7 @@ jobs: platforms: linux/amd64, linux/arm64 secrets: | COMPOSER_TOKEN=${{ secrets.GITHUB_TOKEN }} + push: false # push: true # tags: localhost:5000/taqasta:latest tags: ${{ needs.tags.outputs.REGISTRY_TAGS }} @@ -176,7 +177,6 @@ jobs: uses: docker/setup-buildx-action@v3 with: install: true - driver-opts: network=host - name: Cache Docker layers uses: actions/cache@v3 @@ -186,13 +186,27 @@ jobs: restore-keys: | ${{ runner.os }}-buildx- + - name: Build and push + id: docker_build + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64, linux/arm64 + secrets: | + COMPOSER_TOKEN=${{ secrets.GITHUB_TOKEN }} + push: false + builder: ${{ needs.build.outputs.builder_name }} + tags: ${{ needs.tags.outputs.REGISTRY_TAGS }} + cache-from: type=gha + cache-to: type=gha,mode=max + load: true + - name: Setup Docker Compose env: COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} DOCKER_BUILDKIT: 1 - COMPOSE_DOCKER_CLI_BUILD: 1 shell: bash - run: docker-compose up -d + run: DOCKER_BUILDKIT=1 docker-compose up -d --builder ${{ needs.build.outputs.builder_name }} # - name: Setup Docker Compose # uses: yu-ichiro/spin-up-docker-compose-action@main From 99f2194dacddfb850991386bfc508fdb2916ddb0 Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sun, 12 Nov 2023 23:15:37 +0400 Subject: [PATCH 22/35] Test2 --- .github/workflows/docker-image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 0b610b00..77a86e25 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -148,7 +148,7 @@ jobs: uses: docker/build-push-action@v5 with: context: . - platforms: linux/amd64, linux/arm64 + platforms: linux/amd64 secrets: | COMPOSER_TOKEN=${{ secrets.GITHUB_TOKEN }} push: false @@ -191,7 +191,7 @@ jobs: uses: docker/build-push-action@v5 with: context: . - platforms: linux/amd64, linux/arm64 + platforms: linux/amd64 secrets: | COMPOSER_TOKEN=${{ secrets.GITHUB_TOKEN }} push: false From 1a038386e45aa5e4fafed7e92eb472fc13929813 Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sun, 12 Nov 2023 23:18:38 +0400 Subject: [PATCH 23/35] Test2 --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 77a86e25..a7278a04 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -206,7 +206,7 @@ jobs: COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} DOCKER_BUILDKIT: 1 shell: bash - run: DOCKER_BUILDKIT=1 docker-compose up -d --builder ${{ needs.build.outputs.builder_name }} + run: DOCKER_BUILDKIT=1 docker-compose up -d # - name: Setup Docker Compose # uses: yu-ichiro/spin-up-docker-compose-action@main From 7ba7e090b099e6b9960f46f1e72aec02c115864b Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sun, 12 Nov 2023 23:22:06 +0400 Subject: [PATCH 24/35] Test2 --- .github/workflows/docker-image.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index a7278a04..41c0c8c1 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -161,7 +161,7 @@ jobs: # Deploy via Compose deploy-e2e: needs: [build] - timeout-minutes: 30 + timeout-minutes: 60 # services: # registry: # image: registry:2 @@ -206,7 +206,7 @@ jobs: COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} DOCKER_BUILDKIT: 1 shell: bash - run: DOCKER_BUILDKIT=1 docker-compose up -d + run: DOCKER_BUILDKIT=1 docker compose up -d # - name: Setup Docker Compose # uses: yu-ichiro/spin-up-docker-compose-action@main @@ -222,10 +222,9 @@ jobs: shell: bash run: sleep 30s - - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: - node-version: 18 + node-version: 20 - name: Install dependencies working-directory: ./e2e run: npm ci @@ -240,7 +239,7 @@ jobs: with: name: playwright-report path: e2e/playwright-report/ - retention-days: 10 + retention-days: 7 # Builds from cache & push the image to GitHub registry this time push: From 7418af6641b2769589ce6f9b5970c4cfef89f196 Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sun, 12 Nov 2023 23:26:54 +0400 Subject: [PATCH 25/35] Test2 --- .env.ci | 4 +- .github/workflows/docker-image.yml | 70 +++++++----------------------- docker-compose.yml | 2 +- e2e/tests/example.spec.ts | 2 +- 4 files changed, 19 insertions(+), 59 deletions(-) diff --git a/.env.ci b/.env.ci index 2717743e..15eb9cbb 100644 --- a/.env.ci +++ b/.env.ci @@ -1,5 +1,5 @@ -PORT=80 -MW_SITE_SERVER=http://localhost:80 +PORT=8000 +MW_SITE_SERVER=http://localhost:8000 MW_SITE_NAME=MyWiki MW_SITE_LANG=en MW_ENABLE_UPLOADS=1 diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 41c0c8c1..8439d175 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -25,7 +25,7 @@ jobs: runs-on: ubuntu-latest if: github.event_name == 'push' || github.event_name == 'pull_request' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Run linter (hadolint) uses: vedmaka/hadolint-action@master @@ -49,7 +49,7 @@ jobs: SHA_SHORT: ${{ steps.generate.outputs.SHA_SHORT }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Generate tags id: generate run: | @@ -111,56 +111,9 @@ jobs: echo "REGISTRY_TAGS_PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_OUTPUT - # Pre-build the image, no push - build: - needs: [tags] - runs-on: ubuntu-latest - outputs: - builder_name: ${{ steps.docker_build.outputs.name }} -# services: -# registry: -# image: registry:2 -# ports: -# - 5000:5000 - if: github.event_name == 'push' || github.event_name == 'pull_request' - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - with: - install: true - - - name: Cache Docker layers - uses: actions/cache@v3 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - - - name: Build and push - id: docker_build - uses: docker/build-push-action@v5 - with: - context: . - platforms: linux/amd64 - secrets: | - COMPOSER_TOKEN=${{ secrets.GITHUB_TOKEN }} - push: false -# push: true -# tags: localhost:5000/taqasta:latest - tags: ${{ needs.tags.outputs.REGISTRY_TAGS }} - cache-from: type=gha - cache-to: type=gha,mode=max - - # Deploy via Compose + # Pre-build the image, deploy via compose and run e2e deploy-e2e: - needs: [build] + needs: [tags] timeout-minutes: 60 # services: # registry: @@ -171,7 +124,10 @@ jobs: if: github.event_name == 'push' || github.event_name == 'pull_request' steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -222,7 +178,11 @@ jobs: shell: bash run: sleep 30s - - uses: actions/setup-node@v3 + - name: Test cURL + shell: bash + run: curl -IXGET http://locahost:8000 + + - uses: actions/setup-node@v4 with: node-version: 20 - name: Install dependencies @@ -251,10 +211,10 @@ jobs: if: github.event_name == 'push' || github.event_name == 'pull_request' steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 diff --git a/docker-compose.yml b/docker-compose.yml index 9c9693f0..b258ed37 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,7 +20,7 @@ services: dockerfile: Dockerfile restart: unless-stopped ports: - - "${PORT:-127.0.0.1:8081}:80" + - "${PORT:-127.0.0.1:8000}:80" links: - db env_file: diff --git a/e2e/tests/example.spec.ts b/e2e/tests/example.spec.ts index 9211c88c..0743f374 100644 --- a/e2e/tests/example.spec.ts +++ b/e2e/tests/example.spec.ts @@ -1,7 +1,7 @@ import { test, expect } from '@playwright/test'; test('has title', async ({ page }) => { - await page.goto('http://localhost:80/'); + await page.goto('http://localhost:8000/'); // Expect a title "to contain" a substring. await expect(page).toHaveTitle(/MediaWiki/); From e19c5f33a4f6ad29d53d556da7a83b75277c3dbb Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sun, 12 Nov 2023 23:31:03 +0400 Subject: [PATCH 26/35] Test2 --- .github/workflows/docker-image.yml | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 8439d175..bac84505 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -164,23 +164,13 @@ jobs: shell: bash run: DOCKER_BUILDKIT=1 docker compose up -d -# - name: Setup Docker Compose -# uses: yu-ichiro/spin-up-docker-compose-action@main -# env: -# COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# DOCKER_BUILDKIT: 1 -# COMPOSE_DOCKER_CLI_BUILD: 1 -# with: -# file: docker-compose.yml -# cache-key: ${{ runner.os }}-buildx-${{ github.sha }} - - name: Give containers a moment to init shell: bash run: sleep 30s - name: Test cURL shell: bash - run: curl -IXGET http://locahost:8000 + run: docker compose ps && docker compose logs --tail 100 web - uses: actions/setup-node@v4 with: @@ -201,6 +191,11 @@ jobs: path: e2e/playwright-report/ retention-days: 7 + - name: Stop containers + if: always() + shell: bash + run: docker-compose down + # Builds from cache & push the image to GitHub registry this time push: needs: [tags,deploy-e2e] From 97acb11712847c7f9e41bbbd14a6fc1c6fce1949 Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sun, 12 Nov 2023 23:38:31 +0400 Subject: [PATCH 27/35] Test2 --- .github/workflows/docker-image.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index bac84505..df270309 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -151,7 +151,6 @@ jobs: secrets: | COMPOSER_TOKEN=${{ secrets.GITHUB_TOKEN }} push: false - builder: ${{ needs.build.outputs.builder_name }} tags: ${{ needs.tags.outputs.REGISTRY_TAGS }} cache-from: type=gha cache-to: type=gha,mode=max @@ -168,9 +167,9 @@ jobs: shell: bash run: sleep 30s - - name: Test cURL + - name: Wait for wiki shell: bash - run: docker compose ps && docker compose logs --tail 100 web + run: curl --head -X GET --retry 10 --retry-connrefused --retry-delay 10 http://localhost:8000 - uses: actions/setup-node@v4 with: @@ -185,7 +184,7 @@ jobs: working-directory: ./e2e run: npx playwright test - uses: actions/upload-artifact@v3 - if: always() + if: failure() with: name: playwright-report path: e2e/playwright-report/ From 475aa31ef3efe024ed74e86fde951384809ee8f0 Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sun, 12 Nov 2023 23:41:40 +0400 Subject: [PATCH 28/35] Test2 --- .github/workflows/docker-image.yml | 4 +++- e2e/playwright.config.ts | 5 ++--- e2e/tests/example.spec.ts | 3 +-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index df270309..a3a9dd88 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -142,6 +142,7 @@ jobs: restore-keys: | ${{ runner.os }}-buildx- + # We could perform the build in a separate job, but why for? let's save some bandwidth on caches - name: Build and push id: docker_build uses: docker/build-push-action@v5 @@ -165,12 +166,13 @@ jobs: - name: Give containers a moment to init shell: bash - run: sleep 30s + run: sleep 10s - name: Wait for wiki shell: bash run: curl --head -X GET --retry 10 --retry-connrefused --retry-delay 10 http://localhost:8000 + # todo, migrate to docker image? https://playwright.dev/docs/docker - uses: actions/setup-node@v4 with: node-version: 20 diff --git a/e2e/playwright.config.ts b/e2e/playwright.config.ts index 10745502..6f4b6ada 100644 --- a/e2e/playwright.config.ts +++ b/e2e/playwright.config.ts @@ -12,7 +12,7 @@ import { defineConfig, devices } from '@playwright/test'; export default defineConfig({ testDir: './tests', /* Run tests in files in parallel */ - fullyParallel: true, + fullyParallel: false, /* Fail the build on CI if you accidentally left test.only in the source code. */ forbidOnly: !!process.env.CI, /* Retry on CI only */ @@ -24,8 +24,7 @@ export default defineConfig({ /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { /* Base URL to use in actions like `await page.goto('/')`. */ - // baseURL: 'http://127.0.0.1:3000', - + baseURL: 'http://localhost:8000', /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ trace: 'on-first-retry', }, diff --git a/e2e/tests/example.spec.ts b/e2e/tests/example.spec.ts index 0743f374..a0c7df6b 100644 --- a/e2e/tests/example.spec.ts +++ b/e2e/tests/example.spec.ts @@ -1,8 +1,7 @@ import { test, expect } from '@playwright/test'; test('has title', async ({ page }) => { - await page.goto('http://localhost:8000/'); - + await page.goto('/'); // Expect a title "to contain" a substring. await expect(page).toHaveTitle(/MediaWiki/); }); From d0b4e6615f7d23fe9b6ef5095edfabd97ecf1e46 Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Mon, 13 Nov 2023 01:35:40 +0400 Subject: [PATCH 29/35] Test2 --- .github/workflows/docker-image.yml | 2 +- e2e/tests/base.spec.ts | 64 ++++++++++++++++++++++++++++++ e2e/tests/edit.spec.ts | 15 +++++++ e2e/tests/example.spec.ts | 7 ---- 4 files changed, 80 insertions(+), 8 deletions(-) create mode 100644 e2e/tests/base.spec.ts create mode 100644 e2e/tests/edit.spec.ts delete mode 100644 e2e/tests/example.spec.ts diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index a3a9dd88..63f3c367 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -195,7 +195,7 @@ jobs: - name: Stop containers if: always() shell: bash - run: docker-compose down + run: docker-compose down --volumes --timeout 60 # Builds from cache & push the image to GitHub registry this time push: diff --git a/e2e/tests/base.spec.ts b/e2e/tests/base.spec.ts new file mode 100644 index 00000000..d34ddedb --- /dev/null +++ b/e2e/tests/base.spec.ts @@ -0,0 +1,64 @@ +import {test, expect} from '@playwright/test'; + +test('has successful installation message', async ({page}) => { + await page.goto('/'); + await expect(page.locator('#content')).toContainText(/MediaWiki has been installed/); +}); + +test('has a login link', async ({page}) => { + await page.goto('/'); + await expect(page.locator('#pt-login')).toContainText(/Log in/); +}); + +test('has a signup link', async ({page}) => { + await page.goto('/'); + await expect(page.locator('#pt-createaccount')).toContainText(/Create account/); +}); + +test('has chameleon skin enabled by default', async ({page}) => { + await page.goto('/'); + await expect(page.locator('body')).toHaveClass(/skin-chameleon/); +}); + +test('edit for anonymous is enabled by default', async ({page}) => { + await page.goto('/'); + await expect(page.locator('#ca-edit')).toHaveCount(1); +}); + +test('visual editor is enabled', async ({page}) => { + await page.goto('/'); + await expect(page.locator('#ca-ve-edit')).toHaveCount(1); +}); + +test('special version works', async ({page}) => { + await page.goto('/wiki/Special:Version'); + await expect(page.locator('#firstHeading')).toContainText(/Version/); +}); + +test('special version software installed', async ({page}) => { + await page.goto('/wiki/Special:Version'); + await expect(page.locator('#sv-software')).toContainText(/PHP/); + await expect(page.locator('#sv-software')).toContainText(/MySQL/); + await expect(page.locator('#sv-software')).toContainText(/ICU/); + await expect(page.locator('#sv-software')).toContainText(/LuaSandbox/); + await expect(page.locator('#sv-software')).toContainText(/Lua/); +}); + +test('API endpoint works', async ({page}) => { + await page.goto('/w/api.php'); + await expect(page).toHaveTitle(/MediaWiki API help/) +}); + +test('robots.txt is in place', async ({page}) => { + await page.goto('/robots.txt'); + //let contents = await page.content(); + //expect(contents).toContain(/User-agent/); + await expect(page.locator('pre')).toContainText(/User-agent/); +}); + +// Can be enabled later +// test('robots.txt contains sitemap instruction', async ({page}) => { +// await page.goto('/robots.txt'); +// await expect(page.locator('pre')).toContainText(/Sitemap/); +// }); + diff --git a/e2e/tests/edit.spec.ts b/e2e/tests/edit.spec.ts new file mode 100644 index 00000000..0ea7e190 --- /dev/null +++ b/e2e/tests/edit.spec.ts @@ -0,0 +1,15 @@ +import {test, expect} from '@playwright/test'; + +test('can edit a page', async ({page}) => { + await page.goto('/'); + await expect(page.locator('#ca-edit > a')).toHaveCount(1); + await page.locator('#ca-edit > a').click(); + await expect(page).toHaveTitle(/Editing/) + await expect(page.locator('#wpTextbox1')).toHaveCount(1); + await page.locator('#wpTextbox1').fill('u9es348923hjf8546344'); + await expect(page.locator('#wpSave')).toHaveCount(1); + await expect(page.locator('#wpSave')).toBeEnabled(); + await page.locator('#wpSave').click(); + await expect(page.getByText('Your edit was saved.')).toHaveCount(1); + await expect(page.locator('#mw-content-text')).toContainText(/u9es348923hjf8546344/); +}); diff --git a/e2e/tests/example.spec.ts b/e2e/tests/example.spec.ts deleted file mode 100644 index a0c7df6b..00000000 --- a/e2e/tests/example.spec.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { test, expect } from '@playwright/test'; - -test('has title', async ({ page }) => { - await page.goto('/'); - // Expect a title "to contain" a substring. - await expect(page).toHaveTitle(/MediaWiki/); -}); From 3b72f8676ec8d1edc03ac211577851e1e00f164f Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Mon, 13 Nov 2023 01:44:58 +0400 Subject: [PATCH 30/35] Test2 --- .env.ci | 1 + docker-compose.yml | 1 + e2e/playwright.config.ts | 4 +++- e2e/tests/base.spec.ts | 5 +++++ e2e/tests/edit.spec.ts | 6 +++++- 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.env.ci b/.env.ci index 15eb9cbb..c7b30c88 100644 --- a/.env.ci +++ b/.env.ci @@ -1,3 +1,4 @@ +# Note: this is a dummy env file for CI, do not modify or use it until you know what you're doing PORT=8000 MW_SITE_SERVER=http://localhost:8000 MW_SITE_NAME=MyWiki diff --git a/docker-compose.yml b/docker-compose.yml index b258ed37..f9239c7a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,3 +1,4 @@ +# # Note: this is a dummy Compose file for CI, do not modify or use it until you know what you're doing version: '3.1' services: db: diff --git a/e2e/playwright.config.ts b/e2e/playwright.config.ts index 6f4b6ada..9328dbf0 100644 --- a/e2e/playwright.config.ts +++ b/e2e/playwright.config.ts @@ -16,7 +16,7 @@ export default defineConfig({ /* Fail the build on CI if you accidentally left test.only in the source code. */ forbidOnly: !!process.env.CI, /* Retry on CI only */ - retries: process.env.CI ? 2 : 0, + retries: process.env.CI ? 1 : 0, /* Opt out of parallel tests on CI. */ workers: process.env.CI ? 1 : undefined, /* Reporter to use. See https://playwright.dev/docs/test-reporters */ @@ -29,6 +29,8 @@ export default defineConfig({ trace: 'on-first-retry', }, + globalTimeout: 60 * 60 * 1000, + /* Configure projects for major browsers */ projects: [ { diff --git a/e2e/tests/base.spec.ts b/e2e/tests/base.spec.ts index d34ddedb..8456785d 100644 --- a/e2e/tests/base.spec.ts +++ b/e2e/tests/base.spec.ts @@ -1,4 +1,9 @@ import {test, expect} from '@playwright/test'; +import {defineConfig} from '@playwright/test'; + +export default defineConfig({ + timeout: 5 * 60 * 1000, +}); test('has successful installation message', async ({page}) => { await page.goto('/'); diff --git a/e2e/tests/edit.spec.ts b/e2e/tests/edit.spec.ts index 0ea7e190..9028b32a 100644 --- a/e2e/tests/edit.spec.ts +++ b/e2e/tests/edit.spec.ts @@ -1,4 +1,8 @@ -import {test, expect} from '@playwright/test'; +import {test, expect, defineConfig} from '@playwright/test'; + +export default defineConfig({ + timeout: 5 * 60 * 1000, +}); test('can edit a page', async ({page}) => { await page.goto('/'); From e49116dcb0eda6ce54d541832dff9667f28ba665 Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Mon, 13 Nov 2023 01:53:21 +0400 Subject: [PATCH 31/35] Test2 --- e2e/playwright.config.ts | 3 ++- e2e/tests/base.spec.ts | 2 +- e2e/tests/edit.spec.ts | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/e2e/playwright.config.ts b/e2e/playwright.config.ts index 9328dbf0..ce28980a 100644 --- a/e2e/playwright.config.ts +++ b/e2e/playwright.config.ts @@ -18,7 +18,7 @@ export default defineConfig({ /* Retry on CI only */ retries: process.env.CI ? 1 : 0, /* Opt out of parallel tests on CI. */ - workers: process.env.CI ? 1 : undefined, + workers: process.env.CI ? 1 : 1, /* Reporter to use. See https://playwright.dev/docs/test-reporters */ reporter: 'html', /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ @@ -29,6 +29,7 @@ export default defineConfig({ trace: 'on-first-retry', }, + // global timeout per suite globalTimeout: 60 * 60 * 1000, /* Configure projects for major browsers */ diff --git a/e2e/tests/base.spec.ts b/e2e/tests/base.spec.ts index 8456785d..90665d0b 100644 --- a/e2e/tests/base.spec.ts +++ b/e2e/tests/base.spec.ts @@ -2,7 +2,7 @@ import {test, expect} from '@playwright/test'; import {defineConfig} from '@playwright/test'; export default defineConfig({ - timeout: 5 * 60 * 1000, + timeout: 5 * 60 * 1000, // 5 minutes per test }); test('has successful installation message', async ({page}) => { diff --git a/e2e/tests/edit.spec.ts b/e2e/tests/edit.spec.ts index 9028b32a..9507ff78 100644 --- a/e2e/tests/edit.spec.ts +++ b/e2e/tests/edit.spec.ts @@ -1,7 +1,7 @@ import {test, expect, defineConfig} from '@playwright/test'; export default defineConfig({ - timeout: 5 * 60 * 1000, + timeout: 5 * 60 * 1000, // 5 minutes per test }); test('can edit a page', async ({page}) => { @@ -14,6 +14,5 @@ test('can edit a page', async ({page}) => { await expect(page.locator('#wpSave')).toHaveCount(1); await expect(page.locator('#wpSave')).toBeEnabled(); await page.locator('#wpSave').click(); - await expect(page.getByText('Your edit was saved.')).toHaveCount(1); await expect(page.locator('#mw-content-text')).toContainText(/u9es348923hjf8546344/); }); From 68f5064b4e2555859aea1d9eceac5a18d6ae7152 Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Mon, 13 Nov 2023 02:04:45 +0400 Subject: [PATCH 32/35] Test2 --- .github/workflows/docker-image.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 63f3c367..9dc071e7 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -114,7 +114,15 @@ jobs: # Pre-build the image, deploy via compose and run e2e deploy-e2e: needs: [tags] + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + environment: + name: github-pages + url: ${{ steps.deployment_pages.outputs.page_url }} timeout-minutes: 60 + outputs: + pages_url: ${{ steps.deployment_pages.outputs.page_url }} # services: # registry: # image: registry:2 @@ -192,6 +200,18 @@ jobs: path: e2e/playwright-report/ retention-days: 7 + - name: Deploy to GitHub Pages + if: failure() + id: deployment_pages + uses: actions/deploy-pages@v2 + with: + artifact_name: playwright-report + + - name: Wait for wiki + if: failure() + shell: bash + run: echo ${{ steps.deployment_pages.outputs.page_url }} + - name: Stop containers if: always() shell: bash From 3292a90d2b9f39067e12018c7e8ee9983c126bf5 Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Mon, 13 Nov 2023 02:15:51 +0400 Subject: [PATCH 33/35] Test2 --- .github/workflows/docker-image.yml | 1 + e2e/tests/{base.spec.ts => 001-base.spec.ts} | 0 e2e/tests/{edit.spec.ts => 002-edit.spec.ts} | 0 3 files changed, 1 insertion(+) rename e2e/tests/{base.spec.ts => 001-base.spec.ts} (100%) rename e2e/tests/{edit.spec.ts => 002-edit.spec.ts} (100%) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 9dc071e7..67d2f05a 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -206,6 +206,7 @@ jobs: uses: actions/deploy-pages@v2 with: artifact_name: playwright-report + token: ${{ secrets.GITHUB_TOKEN }} - name: Wait for wiki if: failure() diff --git a/e2e/tests/base.spec.ts b/e2e/tests/001-base.spec.ts similarity index 100% rename from e2e/tests/base.spec.ts rename to e2e/tests/001-base.spec.ts diff --git a/e2e/tests/edit.spec.ts b/e2e/tests/002-edit.spec.ts similarity index 100% rename from e2e/tests/edit.spec.ts rename to e2e/tests/002-edit.spec.ts From 3619c66a0b7f56ed18b81a9e8481f8a30b69bf99 Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Mon, 13 Nov 2023 02:24:12 +0400 Subject: [PATCH 34/35] Test2 --- .github/workflows/docker-image.yml | 51 +++++++++++++++++------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 67d2f05a..ee2127f3 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -114,12 +114,6 @@ jobs: # Pre-build the image, deploy via compose and run e2e deploy-e2e: needs: [tags] - permissions: - pages: write # to deploy to Pages - id-token: write # to verify the deployment originates from an appropriate source - environment: - name: github-pages - url: ${{ steps.deployment_pages.outputs.page_url }} timeout-minutes: 60 outputs: pages_url: ${{ steps.deployment_pages.outputs.page_url }} @@ -174,7 +168,7 @@ jobs: - name: Give containers a moment to init shell: bash - run: sleep 10s + run: sleep 60s - name: Wait for wiki shell: bash @@ -193,25 +187,20 @@ jobs: - name: Run Playwright tests working-directory: ./e2e run: npx playwright test - - uses: actions/upload-artifact@v3 - if: failure() +# - uses: actions/upload-artifact@v3 +# if: failure() +# with: +# name: playwright-report +# path: e2e/playwright-report/ +# retention-days: 7 + + - name: Upload screenshots as a github-pages artifact + uses: actions/upload-pages-artifact@v2 with: name: playwright-report path: e2e/playwright-report/ retention-days: 7 - - - name: Deploy to GitHub Pages - if: failure() - id: deployment_pages - uses: actions/deploy-pages@v2 - with: - artifact_name: playwright-report - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Wait for wiki - if: failure() - shell: bash - run: echo ${{ steps.deployment_pages.outputs.page_url }} + if-no-files-found: error - name: Stop containers if: always() @@ -290,3 +279,21 @@ jobs: message: ":whale: The image based on [${{ needs.tags.outputs.SHA_SHORT }}](https://github.com/WikiTeq/Taqasta/pull/${{ needs.tags.outputs.REGISTRY_TAGS_PR_NUMBER }}/commits/${{ github.event.pull_request.head.sha }}) commit has been built with `${{ needs.tags.outputs.REGISTRY_TAGS_VERSION }}` tag as [${{ needs.tags.outputs.REGISTRY_TAGS }}](https://github.com/${{ github.repository }}/pkgs/container/${{ env.IMAGE_NAME }}/${{ needs.push.outputs.imageid }}?tag=${{ needs.tags.outputs.REGISTRY_TAGS_VERSION }})" recreate: true fail: false + + report-pages: + needs: [deploy-e2e] + runs-on: ubuntu-latest + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + environment: + name: github-pages + url: ${{ steps.deployment_pages.outputs.page_url }} + if: failure() && ( github.event_name == 'push' || github.event_name == 'pull_request' ) + steps: + - name: Deploy to GitHub Pages + id: deployment_pages + uses: actions/deploy-pages@v2 + with: + artifact_name: playwright-report + token: ${{ secrets.GITHUB_TOKEN }} From 5ba1be375cd2f9a1077fe37610d856f1cdb11acd Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Mon, 13 Nov 2023 02:31:51 +0400 Subject: [PATCH 35/35] Test2 --- .github/workflows/docker-image.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index ee2127f3..c065b931 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -168,9 +168,13 @@ jobs: - name: Give containers a moment to init shell: bash - run: sleep 60s + run: sleep 30s - - name: Wait for wiki + - name: Wait for init + shell: bash + run: while ! docker compose logs web --tail 10 | grep -q '>>>>> run-maintenance-script.sh <<<<<'; do sleep 2; done + + - name: Wait for apache shell: bash run: curl --head -X GET --retry 10 --retry-connrefused --retry-delay 10 http://localhost:8000 @@ -196,6 +200,7 @@ jobs: - name: Upload screenshots as a github-pages artifact uses: actions/upload-pages-artifact@v2 + if: failure() with: name: playwright-report path: e2e/playwright-report/