diff --git a/.github/workflows/docs-configuration-reference.yml b/.github/workflows/docs-configuration-reference.yml new file mode 100644 index 00000000..25302986 --- /dev/null +++ b/.github/workflows/docs-configuration-reference.yml @@ -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/setup-php@2.7.0 + 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 diff --git a/.github/workflows/docs-configuration-reference/run.php b/.github/workflows/docs-configuration-reference/run.php new file mode 100755 index 00000000..13df2c0f --- /dev/null +++ b/.github/workflows/docs-configuration-reference/run.php @@ -0,0 +1,51 @@ +#!/usr/bin/env php +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); + } + } +} diff --git a/src/Command/OpenIssueCommand.php b/src/Command/OpenIssueCommand.php new file mode 100644 index 00000000..96845d86 --- /dev/null +++ b/src/Command/OpenIssueCommand.php @@ -0,0 +1,62 @@ + + */ +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; + } +}