removed environment.setup #12
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: E2E_API Tests All | |
on: | |
schedule: | |
# workflow will run daily at 7:00 AM BDT (1:00 AM UTC) | |
- cron: '0 1 * * *' | |
# workflow will trigger on pull request | |
# pull_request: | |
# branches: [develop] | |
# workflow will trigger on push to develop branch | |
push: | |
branches: [develop, e2e-pw] | |
# workflow can be manually triggered | |
workflow_dispatch: | |
inputs: | |
testsuite: | |
description: Choose which test suite to run | |
default: All | |
type: choice | |
options: | |
- E2E | |
- API | |
- All | |
# Cancels all previous workflow runs for pull requests that have not completed. | |
concurrency: | |
# The concurrency group contains the workflow name and the branch name for pull requests or the commit hash for any other events. | |
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} | |
cancel-in-progress: true | |
# workflow permissions | |
permissions: | |
checks: write | |
contents: write | |
issues: write | |
pull-requests: write | |
# workflow environment variables | |
env: | |
ADMIN: admin | |
ADMIN_PASSWORD: password | |
VENDOR: vendor1 | |
VENDOR2: vendor2 | |
CUSTOMER: customer1 | |
USER_PASSWORD: 01dokan01 | |
GMAP: ${{secrets.GMAP}} | |
LICENSE_KEY: ${{secrets.LICENSE_KEY}} | |
BASE_URL: http://localhost:9999 | |
CI: true | |
DOKAN_PRO: true | |
FORCE_COLOR: 1 | |
DB_HOST_NAME: localhost | |
DB_USER_NAME: root | |
DB_USER_PASSWORD: password | |
DATABASE: tests-wordpress | |
DB_PREFIX: wp | |
PR_NUMBER: ${{ github.event.number }} | |
SHA: ${{ github.event.pull_request.head.sha }} | |
SYSTEM_INFO: ./tests/pw/playwright/systemInfo.json | |
API_TEST_RESULT: ./tests/pw/playwright-report/api/summary-report/results.json | |
E2E_TEST_RESULT: ./tests/pw/playwright-report/e2e/summary-report/results.json | |
jobs: | |
tests: | |
name: e2e_api tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout testing repo | |
uses: actions/checkout@v3 | |
with: | |
ref: 'e2e-pw' | |
- name: Use desired version of NodeJS | |
if: success() | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16' | |
cache: 'npm' | |
- name: Clone dokan-pro | |
if: success() | |
uses: actions/checkout@v3 | |
with: | |
repository: getdokan/dokan-pro | |
token: ${{ secrets.ACCESS_TOKEN }} | |
path: 'plugins/dokan-pro' | |
ref: 'develop' | |
- name: Composer install and build (Dokan-lite) | |
if: success() | |
run: | | |
composer install --no-dev -o | |
- name: Npm install and build (Dokan-lite) | |
if: success() | |
run: | | |
npm ci | |
npm run build | |
- name: Composer install and build (Dokan-pro) | |
if: success() | |
run: | | |
cd plugins/dokan-pro | |
composer install --no-dev -o | |
- name: Npm install and build (Dokan-pro) | |
if: success() | |
run: | | |
cd plugins/dokan-pro | |
npm ci | |
npm run build | |
# Install test dependencies | |
- name: Install dependencies | |
if: success() | |
run: | | |
cd tests/pw | |
npm ci | |
# Start wordpress environment | |
- name: Start WordPress Env | |
id: wp-env | |
if: success() | |
run: | | |
cd tests/pw | |
npm run start:env | |
# Grab test db port | |
- name: Get Test DB PORT | |
id: db-port | |
if: success() | |
run: | | |
cd tests/pw | |
echo "DB_PORT=$(docker ps -f ancestor='mariadb' -f name='tests-mysql' --format='{{.Ports}}' | sed -E 's/.*:(.*)->.*/\1/')" >> $GITHUB_ENV | |
# db port | |
- name: DB PORT | |
if: success() | |
run: | | |
cd tests/pw | |
echo "The value of test DB_PORT is ${{ env.DB_PORT }}" | |
# Set permalink structure | |
- name: Set Permalink structure | |
if: success() | |
run: | | |
cd tests/pw | |
npm run wp-env run tests-cli wp rewrite structure /%postname%/ | |
# curl http://localhost:9999/wp-json/wp/v2 | |
# Activate theme | |
- name: Activate theme:Storefront | |
if: success() | |
run: | | |
cd tests/pw | |
npm run wp-env run tests-cli wp theme activate storefront | |
# Get Playwright version | |
- name: Get installed Playwright version | |
id: playwright-version | |
if: success() | |
run: | | |
cd tests/pw | |
echo "PLAYWRIGHT_VERSION=$(npm ls @playwright/test --json | jq --raw-output '.dependencies["@playwright/test"].version')" >> $GITHUB_ENV | |
# Cache browser binaries, cache key is based on Playwright version and OS | |
- name: Cache playwright binaries | |
id: playwright-cache | |
if: success() | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/ms-playwright | |
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }} | |
restore-keys: | | |
${{ runner.os }}-playwright- | |
# Install browser binaries & OS dependencies if cache missed | |
- name: Install Playwright browser binaries & OS dependencies | |
id: pw-install | |
if: success() && steps.playwright-cache.outputs.cache-hit != 'true' | |
run: | | |
cd tests/pw | |
npm run pw:browser-with-deps | |
# Install only the OS dependencies if cache hit not needed | |
# - name: Install Playwright OS dependencies | |
# if: steps.playwright-cache.outputs.cache-hit == 'true' | |
# run: | | |
# cd tests/pw | |
# npm run pw:deps-only | |
# Run e2e tests | |
- name: 🧪 Running the e2e tests | |
id: e2e-test | |
if: success() || ( success() && (github.event_name == 'workflow_dispatch' && (github.event.inputs.testsuite == 'E2E' || github.event.inputs.testsuite == 'All'))) | |
timeout-minutes: 40 | |
run: | | |
cd tests/pw | |
npm run test:e2e:pro | |
# Run API tests | |
- name: 🧪 Running the api tests | |
id: api-test | |
if: always() && steps.db-port.outcome == 'success' || ( always() && steps.db-port.outcome == 'success' && (github.event_name == 'workflow_dispatch' && (github.event.inputs.testsuite == 'API' || github.event.inputs.testsuite == 'All'))) | |
timeout-minutes: 5 | |
run: | | |
cd tests/pw | |
npm run test:api:pro | |
# Prepare test summary | |
- name: Prepare test summary | |
id: prepare-test-summary | |
uses: actions/github-script@v6 | |
if: always() | |
with: | |
result-encoding: string | |
script: | | |
const script = require("./tests/pw/utils/gitTestSummary.ts") | |
return await script({github, context, core}) | |
# Find PR comment | |
- name: Find PR comment by github-actions[bot] | |
uses: peter-evans/find-comment@v2 | |
id: find-comment | |
if: github.event_name == 'pull_request' | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: 'github-actions[bot]' | |
body-includes: Tests Summary | |
# Post test summary as PR comment | |
- name: Create or update PR comment | |
uses: peter-evans/create-or-update-comment@v2 | |
if: github.event_name == 'pull_request' | |
with: | |
comment-id: ${{ steps.find-comment.outputs.comment-id }} | |
issue-number: ${{ github.event.pull_request.number }} | |
body: ${{ steps.prepare-test-summary.outputs.result }} | |
edit-mode: replace | |
# - name: Generate Test Report | |
# uses: phoenix-actions/test-reporting@v8 | |
# id: test-report # Set ID reference for step | |
# if: success() || failure() # run this step even if previous step failed | |
# with: | |
# name: e2e tests result # Name of the check run which will be created | |
# path: tests/pw/playwright-report/results.xml # Path to test results | |
# reporter: jest-junit | |
# only-summary: "false" # Allows you to generate only the summary. | |
# list-suites: "all" # Limits which test suites are listed: 'all', 'failed' | |
# list-tests: "all" # Limits which test cases are listed: 'all','failed', 'none' | |
# fail-on-error: "true" # Set action as failed if test report contains any failed test | |
# - name: Test results | |
# run: | | |
# echo "url is ${{ steps.test-report.outputs.runHtmlUrl }}" | |
# Upload artifacts | |
- name: Archive test artifacts (screenshots, HTML snapshots, Reports) | |
uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: test-artifact | |
path: | | |
tests/pw/playwright | |
tests/pw/playwright-report | |
if-no-files-found: ignore | |
retention-days: 30 | |
# | |
# publishTestResults: | |
# name: Publish HTML report to GH Pages | |
# if: always() # We want this to always run, even if test fail prior to this step running | |
# uses: peaceiris/actions-gh-pages@v3 | |
# with: | |
# github_token: ${{ secrets.GITHUB_TOKEN }} | |
# publish_dir: tests/pw/playwright-report # This is where index.html will be output | |
# keep_files: true # Set this to true to make sure we don't wipe out the other content in GitHub Pages | |
# user_name: "github-actions[bot]" # This will be the username that gets stamped in the repo commit | |
# user_email: "github-actions[bot]@users.noreply.github.com" # This will be the user email that gets stamped in the repo c | |
# - name: Test results | |
# if: always() | |
# run: | | |
# echo "url is https://$GITHUB_REPOSITORY_OWNER.github.io/${GITHUB_REPOSITORY#*/}" | |
# publishTestResults: | |
# name: Publish Test Result | |
# needs: tests | |
# runs-on: ubuntu-latest | |
# if: always() | |
# steps: | |
# - name: Download artifacts | |
# uses: actions/download-artifact@v2 | |
# id: download | |
# - name: Publish HTML report to GH Pages | |
# if: always() # We want this to always run, even if test fail prior to this step running | |
# uses: peaceiris/actions-gh-pages@v3 | |
# with: | |
# github_token: ${{ secrets.GITHUB_TOKEN }} | |
# publish_dir: ${{steps.download.outputs.download-path}} # This is where index.html will be output | |
# # keep_files: true # Set this to true to make sure we don't wipe out the other content in GitHub Pages | |
# user_name: "github-actions[bot]" # This will be the username that gets stamped in the repo commit | |
# user_email: "github-actions[bot]@users.noreply.github.com" # This will be the user email that gets stamped in the repo commit | |
# # redundant / in echo url remove before run | |
# - name: Test results | |
# run: | | |
# echo "url is https://$GITHUB_REPOSITORY_OWNER.github.io/${GITHUB_REPOSITORY#/*/}" | |
# iff: github.event_name == 'pull_request' | |
# - name: Log github context & env variables | |
# env: | |
# GITHUB_CONTEXT: ${{ toJson(github) }} | |
# run: | | |
# echo "$GITHUB_CONTEXT" | |
# env |