Testing e2e test 3 #45
This file contains hidden or 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: Tests | |
| on: | |
| push: | |
| branches: [ "**" ] | |
| pull_request: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| jobs: | |
| phpunit-tests: | |
| name: PHPUnit Tests | |
| runs-on: ubuntu-latest | |
| services: | |
| mysql: | |
| image: mysql:8.0 | |
| env: | |
| MYSQL_ROOT_PASSWORD: root | |
| MYSQL_DATABASE: ojs_ci | |
| ports: | |
| - 3306:3306 | |
| options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
| steps: | |
| - name: Checkout OJS | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: pkp/ojs | |
| ref: stable-3_5_0 | |
| path: ojs | |
| submodules: recursive | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.2' | |
| extensions: mbstring, xml, pdo_mysql, intl, zip, bcmath, curl, gd | |
| coverage: xdebug | |
| - name: Install PKP dependencies | |
| working-directory: ojs/lib/pkp | |
| run: composer install --no-interaction --no-progress --optimize-autoloader | |
| - name: Checkout plugin | |
| uses: actions/checkout@v4 | |
| with: | |
| path: ojs/plugins/generic/codecheck | |
| - name: Install plugin dependencies | |
| working-directory: ojs/plugins/generic/codecheck | |
| run: composer install --no-interaction || true | |
| - name: Create .env file | |
| working-directory: ojs/plugins/generic/codecheck | |
| run: | | |
| cat > .env << EOF | |
| GITHUB_TOKEN=${{ secrets.CODECHECK_GITHUB_TOKEN }} | |
| GITHUB_OWNER=${{ secrets.CODECHECK_GITHUB_OWNER }} | |
| GITHUB_REPO=${{ secrets.CODECHECK_GITHUB_REPO }} | |
| EOF | |
| - name: Setup OJS database | |
| working-directory: ojs | |
| run: | | |
| mysql -h 127.0.0.1 -u root -proot -e "CREATE DATABASE IF NOT EXISTS ojs_ci;" | |
| cp config.TEMPLATE.inc.php config.inc.php | |
| sed -i 's/username = .*/username = root/' config.inc.php | |
| sed -i 's/password = .*/password = root/' config.inc.php | |
| sed -i 's/name = .*/name = ojs_ci/' config.inc.php | |
| sed -i 's/host = .*/host = 127.0.0.1/' config.inc.php | |
| - name: Create MySQL socket symlink | |
| run: | | |
| sudo mkdir -p /tmp | |
| sudo ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock || true | |
| - name: Run PHPUnit tests | |
| working-directory: ojs/plugins/generic/codecheck/tests | |
| run: sh runTests.sh | |
| - name: Run PHPUnit tests with coverage | |
| working-directory: ojs/plugins/generic/codecheck/tests | |
| run: sh runTests.sh --coverage-report=true | |
| - name: Upload coverage report | |
| if: success() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: phpunit-coverage | |
| path: ojs/plugins/generic/codecheck/tests/results/ | |
| if-no-files-found: ignore | |
| - name: Upload test logs | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: phpunit-logs | |
| path: | | |
| ojs/plugins/generic/codecheck/tests/*.log | |
| ojs/plugins/generic/codecheck/tests/*.xml | |
| if-no-files-found: ignore | |
| component-tests: | |
| name: Cypress Component Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run component tests | |
| run: npm run test:component | |
| - name: Upload screenshots | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: cypress-screenshots | |
| path: cypress/screenshots | |
| if-no-files-found: ignore | |
| e2e-tests: | |
| name: Cypress E2E Tests | |
| runs-on: ubuntu-latest | |
| services: | |
| mysql: | |
| image: mysql:8.0 | |
| env: | |
| MYSQL_ROOT_PASSWORD: root | |
| MYSQL_DATABASE: ojs_dump | |
| ports: | |
| - 3306:3306 | |
| options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
| steps: | |
| - name: Checkout OJS | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: pkp/ojs | |
| ref: stable-3_5_0 | |
| path: ojs | |
| submodules: recursive | |
| - name: Checkout plugin | |
| uses: actions/checkout@v4 | |
| with: | |
| path: ojs/plugins/generic/codecheck | |
| - name: Checkout PKP datasets | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: pkp/datasets | |
| path: datasets | |
| - name: Copy test data into datasets directory | |
| run: | | |
| mkdir -p datasets/ojs | |
| cp -r ojs/plugins/generic/codecheck/testData/stable-3_5_0-codecheck datasets/ojs/ | |
| - name: Prepare OJS files and public directories | |
| run: | | |
| mkdir -p ojs/files | |
| mkdir -p ojs/public | |
| - name: Import test database | |
| working-directory: ojs | |
| env: | |
| DBTYPE: MySQL | |
| DBTYPE_SYMBOLIC: mysql | |
| DBUSERNAME: root | |
| DBPASSWORD: root | |
| DBNAME: ojs_dump | |
| DBHOST: 127.0.0.1 | |
| APP: ojs | |
| BRANCH: stable-3_5_0-codecheck | |
| run: | | |
| mysql -h 127.0.0.1 -u root -proot ojs_dump < ../datasets/ojs/stable-3_5_0-codecheck/mysql/database.sql | |
| - name: Load test files | |
| working-directory: ojs | |
| env: | |
| DBTYPE: MySQL | |
| DBTYPE_SYMBOLIC: mysql | |
| DBUSERNAME: root | |
| DBPASSWORD: root | |
| DBNAME: ojs_dump | |
| DBHOST: 127.0.0.1 | |
| APP: ojs | |
| BRANCH: stable-3_5_0-codecheck | |
| run: bash ../datasets/tools/loadfiles.sh | |
| - name: Patch config.inc.php for CI environment | |
| working-directory: ojs | |
| run: | | |
| sed -i 's/host = localhost/host = 127.0.0.1/' config.inc.php | |
| sed -i 's/name = ojs$/name = ojs_dump/' config.inc.php | |
| sed -i 's|base_url = "http://localhost:8888/ojs"|base_url = "http://localhost:8888"|' config.inc.php | |
| sed -i 's|files_dir = .*|files_dir = /home/runner/work/ojs-codecheck/ojs-codecheck/ojs/files|' config.inc.php | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.2' | |
| extensions: mbstring, xml, pdo_mysql, intl, zip, bcmath, curl, gd | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| cache-dependency-path: ojs/plugins/generic/codecheck/package-lock.json | |
| - name: Install plugin npm dependencies | |
| working-directory: ojs/plugins/generic/codecheck | |
| run: npm ci | |
| - name: Start OJS PHP server | |
| run: | | |
| php -S localhost:8888 -t ojs & | |
| echo $! > /tmp/php-server.pid | |
| - name: Wait for OJS to be ready | |
| run: | | |
| timeout 60 bash -c 'until curl -s -o /dev/null -w "%{http_code}" http://localhost:8888 | grep -qE "^[23]"; do sleep 2; done' | |
| - name: Run Cypress E2E tests | |
| working-directory: ojs/plugins/generic/codecheck | |
| run: npm run test:e2e | |
| env: | |
| CYPRESS_BASE_URL: http://localhost:8888 | |
| - name: Upload E2E screenshots | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: e2e-screenshots | |
| path: ojs/plugins/generic/codecheck/cypress/screenshots | |
| if-no-files-found: ignore | |
| - name: Upload E2E videos | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: e2e-videos | |
| path: ojs/plugins/generic/codecheck/cypress/videos | |
| if-no-files-found: ignore | |
| - name: Stop PHP server | |
| if: always() | |
| run: kill $(cat /tmp/php-server.pid) || true |