Skip to content

[POC] Added new PHP doc builder CI integration #14490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 28, 2020
Merged
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
38 changes: 38 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,44 @@ jobs:
- name: "Build documentation"
run: make -C _build SPHINXOPTS="-nqW -j auto" html

build-php:
name: Symfony doc builder

runs-on: ubuntu-latest

continue-on-error: true

steps:
- name: "Checkout"
uses: actions/checkout@v2

- name: "Set-up PHP"
uses: shivammathur/setup-php@v2
with:
php-version: 7.2
coverage: none
tools: "composer:v2"

- name: Get composer cache directory
id: composercache
working-directory: _build
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: "Install dependencies"
working-directory: _build
run: composer install --prefer-dist --no-progress

- name: "Build the docs"
working-directory: _build
run: php build.php -vvv

doctor-rst:
name: DOCtor-RST

Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/_build/doctrees
/_build/spelling
/_build/html
/_build/logs.txt
/_build/vendor
/_build/output
*.pyc
20 changes: 5 additions & 15 deletions .symfony.cloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
name: symfonydocs

# The toolstack used to build the application.
type: "python:3.7"
type: "php:7.2"

# The configuration of app when it is exposed to the web.
web:
# The public directory of the app, relative to its root.
document_root: "/_build/html"
document_root: "/_build/output"
index_files:
- index.html
whitelist:
Expand Down Expand Up @@ -40,19 +40,9 @@ web:
# The size of the persistent disk of the application (in MB).
disk: 512

# Build time dependencies.
dependencies:
python:
virtualenv: 15.1.0

# The hooks that will be performed when the package is deployed.
hooks:
build: |
virtualenv .virtualenv
. .virtualenv/bin/activate
# SymfonyCloud currently sets PIP_USER=1.
export PIP_USER=
pip install pip==9.0.1 wheel==0.29.0
pip install -r _build/.requirements.txt
find .virtualenv -type f -name "*.rst" -delete
make -C _build html
cd _build
composer install --prefer-dist --no-progress
php build.php
45 changes: 45 additions & 0 deletions _build/build.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env php
<?php
require __DIR__.'/vendor/autoload.php';

use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Console\Input\InputOption;

(new Application('Symfony Docs Builder', '1.0'))
->register('build-docs')
->addOption('generate-fjson-files', null, InputOption::VALUE_NONE, 'Use this option to generate docs both in HTML and JSON formats')
->addOption('disable-cache', null, InputOption::VALUE_NONE, 'Use this option to force a full regeneration of all doc contents')
->setCode(function(InputInterface $input, OutputInterface $output) {
$command = [
'php',
'vendor/symfony/docs-builder/bin/console',
'build:docs',
sprintf('--save-errors=%s', __DIR__.'/logs.txt'),
__DIR__.'/../',
__DIR__.'/output/',
];

if ($input->getOption('generate-fjson-files')) {
$command[] = '--output-json';
}

if ($input->getOption('disable-cache')) {
$command[] = '--disable-cache';
}

$process = new Process($command);
$process->setTimeout(3600);

$this->getHelper('process')->run($output, $process);

if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
})
->getApplication()
->setDefaultCommand('build-docs', true)
->run();
22 changes: 22 additions & 0 deletions _build/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"minimum-stability": "dev",
"prefer-stable": true,
"repositories": [
{ "type": "git", "url": "https://github.com/weaverryan/docs-builder" }
],
"config": {
"platform": {
"php": "7.2.9"
},
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"require": {
"php": ">=7.2.9",
"symfony/console": "^4.1",
"symfony/docs-builder": "dev-master",
"symfony/process": "9999999-dev"
}
}
Loading