8000 minor #15257 Verify code blocks (Nyholm) · SirRFI/symfony-docs@69c6ef7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 69c6ef7

Browse files
committed
minor symfony#15257 Verify code blocks (Nyholm)
This PR was squashed before being merged into the 4.4 branch. Discussion ---------- Verify code blocks This PR is a first step to make sure we are using valid code blocks. I created a [small parser](https://github.com/symfony-docs-tools/code-block-checker) that will replace [the PR to the docs builder](https://github.com/weaverryan/docs-builder/pull/97). This CI job will look at the modified files, and give the the the [code-block-checker](https://github.com/symfony-docs-tools/code-block-checker). That project will find the code blocks and make sure they are using valid syntax. It also supports a baseline so we can write invalid syntax if we want to. (it may sometimes make the examples more readable See symfony#15250) ~~The next step is to make sure one can actually run code examples. Im planning to get all examples that starts with a comment and figure out if that is a filepath to the config directory. I will then capture any symfony errors when using that config.~~ This is super helpful when updating the PHP config to use the config builders. EDIT: I included "the next step" in this PR. We do run all config examples. Note that thanks to the baseline feature, will only report **new** errors on modified code blocks. Commits ------- c92641d Verify code blocks
2 parents 5398a93 + c92641d commit 69c6ef7

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,63 @@ jobs:
103103
uses: docker://oskarstark/doctor-rst
104104
with:
105105
args: --short --error-format=github --cache-file=/github/workspace/.cache/doctor-rst.cache
106+
107+
symfony-code-block-checker:
108+
name: Code Blocks
109+
runs-on: Ubuntu-20.04
110+
continue-on-error: true
111+
steps:
112+
- name: Checkout code
113+
uses: actions/checkout@v2
114+
115+
- name: Set-up PHP
116+
uses: shivammathur/setup-php@v2
117+
with:
118+
php-version: 8.0
119+
coverage: none
120+
121+
- name: Fetch branch from where the PR started
122+
run: git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
123+
124+
- name: Find modified files
125+
id: find-files
126+
run: echo "::set-output name=files::$(git diff --name-only origin/${{ github.base_ref }} HEAD | grep ".rst" | tr '\n' ' ')"
127+
128+
- name: Get composer cache directory
129+
id: composercache
130+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
131+
132+
- name: Cache dependencies
133+
uses: actions/cache@v2
134+
with:
135+
path: ${{ steps.composercache.outputs.dir }}
136+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
137+
restore-keys: ${{ runner.os }}-composer-
138+
139+
- name: Install dependencies
140+
if: ${{ steps.find-files.outputs.files }}
141+
run: |
142+
git clone --depth 15 https://github.com/symfony-docs-tools/code-block-checker.git ../_checker
143+
cd ../_checker
144+
composer install
145+
146+
- name: Install test application
147+
if: ${{ steps.find-files.outputs.files }}
148+
run: |
149+
git clone -b ${{ github.base_ref }} --depth 5 --single-branch https://github.com/symfony-docs-tools/symfony-application.git ../_sf_app
150+
cd ../_sf_app
151+
composer update
152+
153+
- name: Generate baseline
154+
if: ${{ steps.find-files.outputs.files }}
155+
run: |
156+
CURRENT=$(git rev-parse HEAD)
157+
git checkout -m ${{ github.base_ref }}
158+
../_checker/code-block-checker.php verify:docs `pwd` ${{ steps.find-files.outputs.files }} --generate-baseline=baseline.json --symfony-application=`realpath ../_sf_app`
159+
git checkout -m $CURRENT
160+
cat baseline.json
161+
162+
- name: Verify examples
163+
if: ${{ steps.find-files.outputs.files }}
164+
run: |
165+
../_checker/code-block-checker.php verify:docs `pwd` ${{ steps.find-files.outputs.files }} --baseline=baseline.json --output-format=github --symfony-application=`realpath ../_sf_app`

0 commit comments

Comments
 (0)
0