Skip to content

Commit 097a2b0

Browse files
committed
Open issues about missing configuration reference
1 parent 580c0ac commit 097a2b0

File tree

3 files changed

+186
-0
lines changed

3 files changed

+186
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Verify docs
2+
3+
on:
4+
schedule:
5+
- cron: '0 10 * * *'
6+
7+
jobs:
8+
use:
9+
name: Configuration reference
10+
runs-on: Ubuntu-20.04
11+
strategy:
12+
fail-fast: false
13+
14+
steps:
15+
- name: Set up PHP
16+
uses: shivammathur/[email protected]
17+
with:
18+
php-version: 7.4
19+
coverage: none
20+
21+
- name: Checkout code
22+
uses: actions/checkout@v2
23+
24+
- name: Get composer cache directory
25+
id: composer-cache
26+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
27+
28+
- name: Cache dependencies
29+
uses: actions/cache@v2
30+
with:
31+
path: ${{ steps.composer-cache.outputs.dir }}
32+
key: composer-${{ runner.os }}-7.4-${{ hashFiles('composer.*') }}
33+
restore-keys: |
34+
composer-${{ runner.os }}-7.4-
35+
composer-${{ runner.os }}-
36+
composer-
37+
38+
- name: Checkout Symfony repo
39+
run: composer create-project --stability dev symfony/website-skeleton .github/workflows/docs-configuration-reference/symfony
40+
41+
- name: Checkout Symfony Docs repo
42+
run: git clone https://github.com/symfony/symfony-docs .github/workflows/docs-configuration-reference/docs
43+
44+
- name: Download dependencies
45+
run: composer install --no-interaction --optimize-autoloader
46+
47+
- name: Verify docs
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.CARSONPROD_GITHUB_TOKEN }}
50+
run: |
51+
CURRENT_DIR=$(pwd)
52+
for item in "debug:DebugBundle" "framework:FrameworkBundle" "security:SecurityBundle" "twig:TwigBundle" "web_profiler:WebProfilerBundle"
53+
do
54+
FILE=$(echo $item | cut -d ":" -f1)
55+
BUNDLE=$(echo $item | cut -d ":" -f2)
56+
echo ::group::$BUNDLE
57+
58+
echo "Trying to find missing config keys"
59+
cd .github/workflows/docs-configuration-reference
60+
./run.php `pwd`/symfony `pwd`/docs/reference/configuration/$FILE.rst $BUNDLE > $CURRENT_DIR/output.txt
61+
62+
cd $CURRENT_DIR
63+
cat output.txt
64+
65+
if [ -s ./output.txt ]; then
66+
echo "Creating an issue"
67+
echo -e "I found that there are some configuration missing for the $BUNDLE configuration reference page. This is a list of what is missing: \n\n\`\`\`" > issue.txt
68+
cat ./output.txt >> issue.txt
69+
echo -e "\n\`\`\`\n\nCould someone please add these?" >> issue.txt
70+
bin/console app:issue:open symfony/symfony-docs "[$BUNDLE] Missing configuration reference" `pwd`/issue.txt
71+
fi
72+
echo ::endgroup::
73+
done
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
if ($argc !== 4) {
5+
echo "./run.php path-to-symfony path-to-docs-page FrameworkBundle \n";
6+
exit(2);
7+
}
8+
9+
// Input
10+
$symfony = $argv[1];
11+
$docPage = $argv[2];
12+
$bundleName = $argv[3];
13+
require $symfony.'/vendor/autoload.php';
14+
15+
$referenceContent = file_get_contents($docPage);
16+
$process = new \Symfony\Component\Process\Process(['bin/console','config:dump-reference', $bundleName, '--format', 'yaml'], $symfony);
17+
$process->run();
18+
if (0 !== $process->getExitCode()) {
19+
error_log("We could not get configuration reference\n");
20+
error_log($process->getErrorOutput());
21+
exit(3);
22+
}
23+
$output = $process->getOutput();
24+
$config = \Symfony\Component\Yaml\Yaml::parse($output);
25+
26+
// always remove the first key
27+
$config = $config[$key = array_key_first($config)];
28+
29+
$missingKeys = [];
30+
parseConfigKeys($referenceContent, $config, $key, $missingKeys);
31+
32+
if (count($missingKeys) === 0) {
33+
error_log("We found nothing\n");
34+
}
35+
36+
foreach ($missingKeys as $key) {
37+
echo '- '.$key.PHP_EOL;
38+
}
39+
40+
exit(0);
41+
42+
function parseConfigKeys(string $doc, array $config, string $base, array &$missingKeys) {
43+
foreach ($config as $key => $value) {
44+
if (!str_contains($doc, $key)) {
45+
$missingKeys[] = $base . '.' . $key;
46+
}
47+
if (is_array($value)) {
48+
parseConfigKeys($doc, $value, $base . '.' . $key, $missingKeys);
49+
}
50+
}
51+
}

src/Command/OpenIssueCommand.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
namespace App\Command;
4+
5+
use App\Api\Issue\IssueApi;
6+
use App\Service\RepositoryProvider;
7+
use Symfony\Component\Console\Command\Command;
8+
use Symfony\Component\Console\Input\InputArgument;
9+
use Symfony\Component\Console\Input\InputInterface;
10+
use Symfony\Component\Console\Output\OutputInterface;
11+
12+
/**
13+
* Open or update issues.
14+
*
15+
* @author Tobias Nyholm <[email protected]>
16+
*/
17+
class OpenIssueCommand extends Command
18+
{
19+
protected static $defaultName = 'app:issue:open';
20+
private $issueApi;
21+
private $repositoryProvider;
22+
23+
public function __construct(RepositoryProvider $repositoryProvider, IssueApi $issueApi)
24+
{
25+
parent::__construct();
26+
$this->issueApi = $issueApi;
27+
$this->repositoryProvider = $repositoryProvider;
28+
}
29+
30+
protected function configure()
31+
{
32+
$this->addArgument('repository', InputArgument::REQUIRED, 'The full name to the repository, eg symfony/symfony-docs');
33+
$this->addArgument('title', InputArgument::REQUIRED, 'The title of the issue');
34+
$this->addArgument('file', InputArgument::REQUIRED, 'The path to the issue body text file');
35+
}
36+
37+
protected function execute(InputInterface $input, OutputInterface $output)
38+
{
39+
/** @var string $repositoryName */
40+
$repositoryName = $input->getArgument('repository');
41+
$repository = $this->repositoryProvider->getRepository($repositoryName);
42+
if (null === $repository) {
43+
$output->writeln('Repository not configured');
44+
45+
return 1;
46+
}
47+
48+
/** @var string $title */
49+
$title = $input->getArgument('title');
50+
/** @var string $filePath */
51+
$filePath = $input->getArgument('file');
52+
53+
$body = file_get_contents($filePath);
54+
if (false === $body) {
55+
return 1;
56+
}
57+
58+
$this->issueApi->open($repository, $title, $body, ['help wanted']);
59+
60+
return 0;
61+
}
62+
}

0 commit comments

Comments
 (0)