-
Notifications
You must be signed in to change notification settings - Fork 31
Open issues for missing config reference #141
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
Open
Nyholm
wants to merge
2
commits into
symfony-tools:master
Choose a base branch
from
Nyholm:config-reference
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: Verify docs | ||
|
||
on: | ||
schedule: | ||
- cron: '0 10 * * *' | ||
|
||
jobs: | ||
use: | ||
name: Configuration reference | ||
runs-on: Ubuntu-20.04 | ||
strategy: | ||
fail-fast: false | ||
|
||
steps: | ||
- name: Set up PHP | ||
uses: shivammathur/[email protected] | ||
with: | ||
php-version: 7.4 | ||
coverage: none | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Get composer cache directory | ||
id: composer-cache | ||
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: composer-${{ runner.os }}-7.4-${{ hashFiles('composer.*') }} | ||
restore-keys: | | ||
composer-${{ runner.os }}-7.4- | ||
composer-${{ runner.os }}- | ||
composer- | ||
|
||
- name: Checkout Symfony repo | ||
run: composer create-project --stability dev symfony/website-skeleton .github/workflows/docs-configuration-reference/symfony | ||
|
||
- name: Checkout Symfony Docs repo | ||
run: git clone https://github.com/symfony/symfony-docs .github/workflows/docs-configuration-reference/docs | ||
|
||
- name: Download dependencies | ||
run: composer install --no-interaction --optimize-autoloader | ||
|
||
- name: Verify docs | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.CARSONPROD_GITHUB_TOKEN }} | ||
run: | | ||
CURRENT_DIR=$(pwd) | ||
for item in "debug:DebugBundle" "framework:FrameworkBundle" "security:SecurityBundle" "twig:TwigBundle" "web_profiler:WebProfilerBundle" | ||
do | ||
FILE=$(echo $item | cut -d ":" -f1) | ||
BUNDLE=$(echo $item | cut -d ":" -f2) | ||
echo ::group::$BUNDLE | ||
|
||
echo "Trying to find missing config keys" | ||
cd .github/workflows/docs-configuration-reference | ||
./run.php `pwd`/symfony `pwd`/docs/reference/configuration/$FILE.rst $BUNDLE > $CURRENT_DIR/output.txt | ||
|
||
cd $CURRENT_DIR | ||
cat output.txt | ||
|
||
if [ -s ./output.txt ]; then | ||
echo "Creating an issue" | ||
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 | ||
cat ./output.txt >> issue.txt | ||
echo -e "\n\`\`\`\n\nCould someone please add these?" >> issue.txt | ||
bin/console app:issue:open symfony/symfony-docs "[$BUNDLE] Missing configuration reference" `pwd`/issue.txt | ||
fi | ||
echo ::endgroup:: | ||
done |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
if ($argc !== 4) { | ||
echo "./run.php path-to-symfony path-to-docs-page FrameworkBundle \n"; | ||
exit(2); | ||
} | ||
|
||
// Input | ||
$symfony = $argv[1]; | ||
$docPage = $argv[2]; | ||
$bundleName = $argv[3]; | ||
require $symfony.'/vendor/autoload.php'; | ||
|
||
$referenceContent = file_get_contents($docPage); | ||
$process = new \Symfony\Component\Process\Process(['bin/console','config:dump-reference', $bundleName, '--format', 'yaml'], $symfony); | ||
$process->run(); | ||
if (0 !== $process->getExitCode()) { | ||
error_log("We could not get configuration reference\n"); | ||
error_log($process->getErrorOutput()); | ||
exit(3); | ||
} | ||
$output = $process->getOutput(); | ||
$config = \Symfony\Component\Yaml\Yaml::parse($output); | ||
|
||
// always remove the first key | ||
$config = $config[$key = array_key_first($config)]; | ||
|
||
$missingKeys = []; | ||
parseConfigKeys($referenceContent, $config, $key, $missingKeys); | ||
|
||
if (count($missingKeys) === 0) { | ||
error_log("We found nothing\n"); | ||
} | ||
|
||
foreach ($missingKeys as $key) { | ||
echo '- '.$key.PHP_EOL; | ||
} | ||
|
||
exit(0); | ||
|
||
function parseConfigKeys(string $doc, array $config, string $base, array &$missingKeys) { | ||
foreach ($config as $key => $value) { | ||
if (!is_numeric($key) && !str_contains($doc, $key)) { | ||
$missingKeys[] = $base . '.' . $key; | ||
} | ||
if (is_array($value)) { | ||
parseConfigKeys($doc, $value, $base . '.' . $key, $missingKeys); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
namespace App\Command; | ||
|
||
use App\Api\Issue\IssueApi; | ||
use App\Service\RepositoryProvider; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
* Open or update issues. | ||
* | ||
* @author Tobias Nyholm <[email protected]> | ||
*/ | ||
class OpenIssueCommand extends Command | ||
{ | ||
protected static $defaultName = 'app:issue:open'; | ||
private $issueApi; | ||
private $repositoryProvider; | ||
|
||
public function __construct(RepositoryProvider $repositoryProvider, IssueApi $issueApi) | ||
{ | ||
parent::__construct(); | ||
$this->issueApi = $issueApi; | ||
$this->repositoryProvider = $repositoryProvider; | ||
} | ||
|
||
protected function configure() | ||
{ | ||
$this->addArgument('repository', InputArgument::REQUIRED, 'The full name to the repository, eg symfony/symfony-docs'); | ||
$this->addArgument('title', InputArgument::REQUIRED, 'The title of the issue'); | ||
$this->addArgument('file', InputArgument::REQUIRED, 'The path to the issue body text file'); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
/** @var string $repositoryName */ | ||
$repositoryName = $input->getArgument('repository'); | ||
$repository = $this->repositoryProvider->getRepository($repositoryName); | ||
if (null === $repository) { | ||
$output->writeln('Repository not configured'); | ||
|
||
return 1; | ||
} | ||
|
||
/** @var string $title */ | ||
$title = $input->getArgument('title'); | ||
/** @var string $filePath */ | ||
$filePath = $input->getArgument('file'); | ||
|
||
$body = file_get_contents($filePath); | ||
if (false === $body) { | ||
return 1; | ||
} | ||
|
||
$this->issueApi->open($repository, $title, $body, ['help wanted']); | ||
|
||
return 0; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.