forked from symfony/symfony-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
146 lines (115 loc) · 5.25 KB
/
ci.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: CI
on:
push:
branches-ignore:
- 'github-comments'
pull_request:
branches-ignore:
- 'github-comments'
permissions:
contents: read
jobs:
symfony-docs-builder-build:
name: Build (symfony-tools/docs-builder)
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Set-up PHP"
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
coverage: none
tools: "composer:v2"
- name: Get composer cache directory
id: composercache
working-directory: _build
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: "Install dependencies"
working-directory: _build
run: composer install --prefer-dist --no-progress
- name: "Build the docs"
working-directory: _build
run: php build.php --disable-cache
doctor-rst:
name: Lint (DOCtor-RST)
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Create cache dir"
run: mkdir .cache
- name: "Extract base branch name"
run: echo "branch=$(echo ${GITHUB_BASE_REF:=${GITHUB_REF##*/}})" >> $GITHUB_OUTPUT
id: extract_base_branch
- name: "Cache DOCtor-RST"
uses: actions/cache@v3
with:
path: .cache
key: ${{ runner.os }}-doctor-rst-${{ steps.extract_base_branch.outputs.branch }}
- name: "Run DOCtor-RST"
uses: docker://oskarstark/doctor-rst:1.62.3
with:
args: --short --error-format=github --cache-file=/github/workspace/.cache/doctor-rst.cache
symfony-code-block-checker:
name: Code Blocks
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
path: 'docs'
- name: Set-up PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
coverage: none
- name: Fetch branch from where the PR started
working-directory: docs
run: git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
- name: Find modified files
id: find-files
working-directory: docs
run: echo "files=$(git diff --name-only origin/${{ github.base_ref }} HEAD | grep ".rst" | tr '\n' ' ')" >> $GITHUB_OUTPUT
- name: Get composer cache directory
id: composercache
working-directory: docs/_build
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
if: ${{ steps.find-files.outputs.files }}
uses: actions/cache@v3
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-codeBlocks-${{ hashFiles('_checker/composer.lock', '_sf_app/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-codeBlocks-
- name: Install dependencies
if: ${{ steps.find-files.outputs.files }}
run: composer create-project symfony-tools/code-block-checker:@dev _checker
- name: Install test application
if: ${{ steps.find-files.outputs.files }}
run: |
git clone -b ${{ github.base_ref }} --depth 5 --single-branch https://github.com/symfony-tools/symfony-application.git _sf_app
cd _sf_app
composer update
- name: Generate baseline
if: ${{ steps.find-files.outputs.files }}
working-directory: docs
run: |
CURRENT=$(git rev-parse HEAD)
git checkout -m ${{ github.base_ref }}
../_checker/code-block-checker.php verify:docs `pwd` ${{ steps.find-files.outputs.files }} --generate-baseline=baseline.json --symfony-application=`realpath ../_sf_app`
git checkout -m $CURRENT
cat baseline.json
- name: Verify examples
if: ${{ steps.find-files.outputs.files }}
working-directory: docs
run: |
../_checker/code-block-checker.php verify:docs `pwd` ${{ steps.find-files.outputs.files }} --baseline=baseline.json --output-format=github --symfony-application=`realpath ../_sf_app`