Skip to content

Commit e7a6a8c

Browse files
authored
chore(presubmits): block only merge PRs on doc check failures (googleapis#12708)
Towards googleapis#12004
1 parent ee3b676 commit e7a6a8c

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

.github/workflows/docs.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,64 @@ permissions:
1212
contents: read
1313

1414
jobs:
15+
# The two jobs "docs" and "docsfx" are marked as required checks
16+
# (and reset as such periodically) elsewhere in our
17+
# automation. Since we don't want to block non-release PRs on docs
18+
# failures, we want these checks to always show up as succeeded for
19+
# those PRs. For release PRs, we do want the checks to run and block
20+
# merge on failure.
21+
#
22+
# We accomplish this by using an "if:" conditional. Jobs
23+
# thus skipped via a conditional (i.e. a false condition) show as
24+
# having succeeded. See:
25+
# https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
26+
#
27+
# Since we want advance notice of docs errors, we also have two
28+
# corresponding non-required checks, the jobs "docs-warnings" and
29+
# "docfx-warnings", that run for all non-release PRs (i.e., when the
30+
# "docs" and "docfx" jobs don't run).
31+
#
32+
#
33+
# PLEASE ENSURE THE FOLLOWING AT ALL TIMES:
34+
#
35+
# - the "*-warnings" checks remain NON-REQUIRED in the repo
36+
# settings.
37+
#
38+
# - the steps for the jobs "docs" and "docfx" are identical to the
39+
# ones in "docs-warnings" and "docfx-warnings", respectively. We
40+
# will be able to avoid config duplication once GitHub actions
41+
# support YAML anchors (see
42+
# https://github.com/actions/runner/issues/1182)
1543
docs:
44+
if: github.actor == 'release-please'
45+
runs-on: ubuntu-latest
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@v4
49+
# Use a fetch-depth of 2 to avoid error `fatal: origin/main...HEAD: no merge base`
50+
# See https://github.com/googleapis/google-cloud-python/issues/12013
51+
# and https://github.com/actions/checkout#checkout-head.
52+
with:
53+
fetch-depth: 2
54+
- name: Setup Python
55+
uses: actions/setup-python@v5
56+
with:
57+
python-version: "3.10"
58+
- name: Install nox
59+
run: |
60+
python -m pip install --upgrade setuptools pip wheel
61+
python -m pip install nox
62+
- name: Run docs
63+
env:
64+
BUILD_TYPE: presubmit
65+
TEST_TYPE: docs
66+
PY_VERSION: "3.10"
67+
run: |
68+
ci/run_conditional_tests.sh
69+
docs-warnings:
70+
if: github.actor != 'release-please'
71+
name: "Docs warnings: will block release"
72+
continue-on-error: true
1673
runs-on: ubuntu-latest
1774
steps:
1875
- name: Checkout
@@ -38,6 +95,35 @@ jobs:
3895
run: |
3996
ci/run_conditional_tests.sh
4097
docfx:
98+
if: github.actor == 'release-please'
99+
runs-on: ubuntu-latest
100+
steps:
101+
- name: Checkout
102+
uses: actions/checkout@v4
103+
# Use a fetch-depth of 2 to avoid error `fatal: origin/main...HEAD: no merge base`
104+
# See https://github.com/googleapis/google-cloud-python/issues/12013
105+
# and https://github.com/actions/checkout#checkout-head.
106+
with:
107+
fetch-depth: 2
108+
- name: Setup Python
109+
uses: actions/setup-python@v5
110+
with:
111+
python-version: "3.10"
112+
- name: Install nox
113+
run: |
114+
python -m pip install --upgrade setuptools pip wheel
115+
python -m pip install nox
116+
- name: Run docfx
117+
env:
118+
BUILD_TYPE: presubmit
119+
TEST_TYPE: docfx
120+
PY_VERSION: "3.10"
121+
run: |
122+
ci/run_conditional_tests.sh
123+
docfx-warnings:
124+
if: github.actor != 'release-please'
125+
name: "Docfx warnings: will block release"
126+
continue-on-error: true
41127
runs-on: ubuntu-latest
42128
steps:
43129
- name: Checkout

0 commit comments

Comments
 (0)