Skip to content

Commit 74252c2

Browse files
committed
Verify code blocks
1 parent 6d99029 commit 74252c2

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

.github/workflows/code-blocks.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Code Blocks
2+
3+
on:
4+
pull_request: ~
5+
6+
jobs:
7+
symfony-code-block-checker:
8+
name: Verify
9+
runs-on: Ubuntu-20.04
10+
continue-on-error: true
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v2
14+
15+
- name: Set-up PHP
16+
uses: shivammathur/setup-php@v2
17+
with:
18+
php-version: 8.0
19+
coverage: none
20+
21+
- name: Fetch branch from where the PR started
22+
run: git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
23+
24+
- name: Find modified files
25+
id: find-files
26+
run: echo "::set-output name=files::$(git diff --name-only origin/${{ github.base_ref }} HEAD | grep ".rst" | tr '\n' ' ')"
27+
28+
- name: Get composer cache directory
29+
id: composercache
30+
working-directory: _build
31+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
32+
33+
- name: Cache dependencies
34+
uses: actions/cache@v2
35+
with:
36+
path: ${{ steps.composercache.outputs.dir }}
37+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
38+
restore-keys: ${{ runner.os }}-composer-
39+
40+
- name: Install dependencies
41+
if: ${{ steps.find-files.outputs.files }}
42+
run: |
43+
git clone --depth 15 https://github.com/symfony-docs-tools/code-block-checker.git ../_checker
44+
cd ../_checker
45+
composer install
46+
47+
- name: Generate baseline
48+
if: ${{ steps.find-files.outputs.files }}
49+
run: |
50+
CURRENT=$(git rev-parse HEAD)
51+
git checkout -m ${{ github.base_ref }}
52+
../_checker/code-block-checker.php verify:docs `pwd` ${{ steps.find-files.outputs.files }} --generate-baseline=baseline.json
53+
git checkout -m $CURRENT
54+
cat baseline.json
55+
56+
- name: Verify examples
57+
if: ${{ steps.find-files.outputs.files }}
58+
run: |
59+
../_checker/code-block-checker.php verify:docs `pwd` ${{ steps.find-files.outputs.files }} --baseline=baseline.json --output-format=github

0 commit comments

Comments
 (0)