Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions .github/workflows/extension-guides-directives.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
on:
push:
branches:
- master
paths:
- 'extensions/GuidesDirectives/**'
- 'src/phpDocumentor/Extension/**'
- 'src/phpDocumentor/Guides/**'
- 'src/phpDocumentor/Descriptor/**'
- 'src/phpDocumentor/Query/**'
- '.github/workflows/extension-guides-directives.yml'
pull_request:
paths:
- 'extensions/GuidesDirectives/**'
- 'src/phpDocumentor/Extension/**'
- 'src/phpDocumentor/Guides/**'
- 'src/phpDocumentor/Descriptor/**'
- 'src/phpDocumentor/Query/**'
- '.github/workflows/extension-guides-directives.yml'
workflow_dispatch:
name: Extension - GuidesDirectives

env:
extensions: mbstring, intl, iconv, libxml, dom, json, simplexml, zlib, fileinfo
key: cache-v1
defaultPHPVersion: '8.1'

jobs:
unit:
name: Unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7

- name: Setup cache environment
id: cache-env
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ env.defaultPHPVersion }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}

- name: Cache extensions
uses: actions/cache@v6
with:
path: ${{ steps.cache-env.outputs.dir }}
key: ${{ steps.cache-env.outputs.key }}
restore-keys: ${{ steps.cache-env.outputs.key }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.defaultPHPVersion }}
extensions: ${{ env.extensions }}
ini-values: memory_limit=2G, display_errors=On, error_reporting=-1

- name: Install Composer dependencies & cache dependencies
uses: "ramsey/composer-install@v4"
with:
composer-options: --optimize-autoloader

- name: Run the extension's PHPUnit suite
run: ./bin/phpunit -c extensions/GuidesDirectives/phpunit.xml.dist --no-coverage

e2e:
name: E2E (composer install + Cypress)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7

- name: Setup cache environment
id: cache-env
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ env.defaultPHPVersion }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}

- name: Cache extensions
uses: actions/cache@v6
with:
path: ${{ steps.cache-env.outputs.dir }}
key: ${{ steps.cache-env.outputs.key }}
restore-keys: ${{ steps.cache-env.outputs.key }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.defaultPHPVersion }}
extensions: ${{ env.extensions }}
ini-values: memory_limit=2G, display_errors=On, error_reporting=-1
tools: composer:v2

- name: Install phpDocumentor's own Composer dependencies
uses: "ramsey/composer-install@v4"
with:
composer-options: --optimize-autoloader

- name: Install the extension into the fixture project via Composer
working-directory: extensions/GuidesDirectives/tests/e2e/fixture-project
run: composer install --no-interaction

- name: Build the fixture project's docs
working-directory: extensions/GuidesDirectives/tests/e2e/fixture-project
run: ../../../../../bin/phpdoc --config=phpdoc.xml --target=${{ github.workspace }}/build/guides-directives --force -vvv

- name: Test the rendered output using Cypress
uses: cypress-io/github-action@v7
with:
spec: extensions/GuidesDirectives/tests/e2e/cypress/integration/*.spec.js
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ help:
@echo "build/clean/index.html - builds the 'clean' template's example project";
@echo "cypress/integration/*.spec.js - runs e2e tests on a specific specification";
@echo "";
@echo "unit-test-extension-guides-directives - runs the GuidesDirectives extension's own PHPUnit suite";
@echo "e2e-test-guides-directives - installs the GuidesDirectives extension via composer into a fixture project and verifies the rendered output using Cypress";
@echo "test-extension-guides-directives - runs both of the above";
@echo "";
@echo "== Code Quality ==";
@echo "lint - performs all linting on the code";
@echo "phpcs - performs code-style checks";
Expand Down Expand Up @@ -117,6 +121,23 @@ cypress/integration/default/%.spec.js: node_modules/.bin/cypress build/default/i
cypress/integration/clean/%.spec.js: node_modules/.bin/cypress build/clean/index.html .RUN_ALWAYS
docker run -it --rm -eCYPRESS_CACHE_FOLDER="/e2e/var/cache/.cypress" -v ${CURDIR}:/e2e -w /e2e cypress/included:${CYPRESS_VERSION} -s $@

.PHONY: unit-test-extension-guides-directives
unit-test-extension-guides-directives:
${.DOCKER_COMPOSE_RUN} --entrypoint=bin/phpunit phpdoc-pcov -c extensions/GuidesDirectives/phpunit.xml.dist --no-coverage

extensions/GuidesDirectives/tests/e2e/fixture-project/vendor/autoload.php: extensions/GuidesDirectives/composer.json extensions/GuidesDirectives/tests/e2e/fixture-project/composer.json
${.DOCKER_COMPOSE_RUN} --entrypoint=/bin/bash phpdoc -c "cd extensions/GuidesDirectives/tests/e2e/fixture-project && composer install"

build/guides-directives/guide/index.html: extensions/GuidesDirectives/tests/e2e/fixture-project/vendor/autoload.php extensions/GuidesDirectives/**/*.php extensions/GuidesDirectives/tests/e2e/fixture-project/**/* .RUN_ALWAYS
${.DOCKER_COMPOSE_RUN} --entrypoint=/bin/bash phpdoc -c "cd extensions/GuidesDirectives/tests/e2e/fixture-project && ../../../../../bin/phpdoc --config=phpdoc.xml --target=/opt/phpdoc/build/guides-directives --force"

.PHONY: e2e-test-guides-directives
e2e-test-guides-directives: node_modules/.bin/cypress build/guides-directives/guide/index.html
docker run -it --rm -eCYPRESS_CACHE_FOLDER="/e2e/var/cache/.cypress" -v ${CURDIR}:/e2e -w /e2e cypress/included:${CYPRESS_VERSION} --spec "extensions/GuidesDirectives/tests/e2e/cypress/integration/*.spec.js"

.PHONY: test-extension-guides-directives
test-extension-guides-directives: unit-test-extension-guides-directives e2e-test-guides-directives

.PHONY: composer-require-checker
composer-require-checker:
${.DOCKER_COMPOSE_RUN} --entrypoint=./tools/composer-require-checker phpdoc check --config-file /opt/phpdoc/composer-require-config.json composer.json
Expand Down
6 changes: 6 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
"type": "path",
"url": "incubator/json-path",
"canonical": true
},
{
"type": "path",
"url": "extensions/GuidesDirectives",
"canonical": true
}
],
"require": {
Expand Down Expand Up @@ -103,6 +108,7 @@
"mikey179/vfsstream": "^1.2",
"mockery/mockery": "^1.0",
"phpat/phpat": "^0.10.20",
"phpdocumentor/extension-guides-directives": "dev-master@dev",
"phpspec/prophecy-phpunit": "^2.2",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^1.10",
Expand Down
Loading
Loading