@@ -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