Skip to content

Commit c2be1e5

Browse files
committed
Fix older docs builds and allow writing over existing tags
1 parent 1e0583d commit c2be1e5

1 file changed

Lines changed: 65 additions & 16 deletions

File tree

‎.github/workflows/backfill-docs.yml‎

Lines changed: 65 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,18 @@ on:
1010
description: 'Python version to build with (default: the one recorded in the tag)'
1111
required: false
1212
type: string
13+
compiler-version:
14+
description: 'DPC++ version to build with (default: the one required by the tag)'
15+
required: false
16+
type: string
1317

1418
permissions:
1519
contents: read
1620

1721
env:
1822
CHECK_CONFIG_SCRIPT: "import sys; from packaging.version import parse; print('true' if parse('0.17.0') <= parse(sys.argv[1]) < parse('0.22.0') else 'false')"
23+
# dpctl gained NumPy 2 support in 0.18.0dev1; earlier tags fail to build against it.
24+
NUMPY_SPEC_SCRIPT: "import sys; from packaging.version import parse; print('numpy<2' if parse(sys.argv[1]) < parse('0.18.0dev1') else 'numpy')"
1925
# Used only for tags that predate the docs workflow and so record no version.
2026
DEFAULT_PYTHON_VERSION: '3.10'
2127

@@ -39,9 +45,48 @@ jobs:
3945
echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" \
4046
| sudo tee /etc/apt/sources.list.d/oneAPI.list
4147
sudo apt update
48+
- name: Checkout repo at tag
49+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
50+
with:
51+
ref: ${{ github.event.inputs.tag }}
52+
fetch-depth: 0
53+
persist-credentials: false
54+
- name: Resolve DPC++ version for the tag
55+
id: resolve-compiler
56+
env:
57+
TAG: ${{ github.event.inputs.tag }}
58+
COMPILER_VERSION_INPUT: ${{ github.event.inputs.compiler-version }}
59+
run: |
60+
COMPILER_PACKAGE=intel-oneapi-compiler-dpcpp-cpp
61+
62+
if [[ -n "${COMPILER_VERSION_INPUT}" ]]; then
63+
COMPILER_VERSION="${COMPILER_VERSION_INPUT}"
64+
echo "Using DPC++ ${COMPILER_VERSION} requested via workflow input."
65+
else
66+
# build against compiler version declared in the conda recipe
67+
COMPILER_VERSION=$(grep -oP 'required_compiler_version\s*=\s*"\K[^"]+' \
68+
conda-recipe/meta.yaml 2>/dev/null | head -n 1 || true)
69+
if [[ -z "${COMPILER_VERSION}" ]]; then
70+
echo "${TAG} declares no required_compiler_version. Using the latest DPC++."
71+
echo "package=${COMPILER_PACKAGE}" >> "$GITHUB_OUTPUT"
72+
exit 0
73+
fi
74+
echo "${TAG} requires DPC++ ${COMPILER_VERSION}."
75+
fi
76+
77+
VERSIONED_PACKAGE="${COMPILER_PACKAGE}-$(cut -d. -f1,2 <<< "${COMPILER_VERSION}")"
78+
if apt-cache show "${VERSIONED_PACKAGE}" > /dev/null 2>&1; then
79+
COMPILER_PACKAGE="${VERSIONED_PACKAGE}"
80+
echo "Installing ${COMPILER_PACKAGE}."
81+
else
82+
echo "::warning::${VERSIONED_PACKAGE} is not in the Intel apt repository. Using the latest DPC++ instead."
83+
fi
84+
echo "package=${COMPILER_PACKAGE}" >> "$GITHUB_OUTPUT"
4285
- name: Install Intel OneAPI
86+
env:
87+
COMPILER_PACKAGE: ${{ steps.resolve-compiler.outputs.package }}
4388
run: |
44-
sudo apt install intel-oneapi-compiler-dpcpp-cpp
89+
sudo apt install "${COMPILER_PACKAGE}"
4590
sudo apt install intel-oneapi-tbb
4691
sudo apt install intel-oneapi-umf
4792
sudo apt install hwloc
@@ -54,12 +99,6 @@ jobs:
5499
- name: Install Ninja
55100
run: |
56101
sudo apt-get install ninja-build
57-
- name: Checkout repo at tag
58-
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
59-
with:
60-
ref: ${{ github.event.inputs.tag }}
61-
fetch-depth: 0
62-
persist-credentials: false
63102
- name: Resolve Python version for the tag
64103
id: resolve-python
65104
env:
@@ -88,8 +127,13 @@ jobs:
88127
architecture: x64
89128
- name: Install sphinx dependencies
90129
shell: bash -l {0}
130+
env:
131+
TAG: ${{ github.event.inputs.tag }}
91132
run: |
92-
pip install numpy cython setuptools">=70.1" scikit-build cmake sphinx"<7.2" pydot graphviz furo \
133+
pip install packaging
134+
NUMPY_SPEC=$(python -c "$NUMPY_SPEC_SCRIPT" "$TAG")
135+
echo "Building against ${NUMPY_SPEC}."
136+
pip install "${NUMPY_SPEC}" cython setuptools">=70.1" scikit-build cmake sphinx"<7.2" pydot graphviz furo \
93137
sphinxcontrib-programoutput sphinxcontrib-googleanalytics sphinx-design \
94138
sphinxcontrib-jsmath sphinx-copybutton sphinxcontrib-spelling \
95139
versioneer[toml]==0.29
@@ -98,13 +142,18 @@ jobs:
98142
env:
99143
TAG: ${{ github.event.inputs.tag }}
100144
run: |
101-
NEEDS_CONFIG=$(python -c "$CHECK_CONFIG_SCRIPT" "$TAG")
145+
git fetch origin master
146+
147+
# a tag cannot list the versions released after it, so the version list
148+
# behind the sidebar dropdown always has to come from master
149+
git checkout origin/master -- docs/doc_versions.txt
102150
151+
NEEDS_CONFIG=$(python -c "$CHECK_CONFIG_SCRIPT" "$TAG")
103152
if [[ "${NEEDS_CONFIG}" == "true" ]]; then
104-
git fetch origin master
105-
git checkout origin/master -- docs/doc_sources/conf.py.in docs/doc_sources/_templates/versions.html docs/doc_versions.txt
153+
git checkout origin/master -- docs/doc_sources/conf.py.in \
154+
docs/doc_sources/_templates/versions.html
106155
else
107-
echo "Version does not require docs config injection."
156+
echo "Tag already has the current docs template, only the version list was injected."
108157
fi
109158
- name: Build dpctl+docs
110159
shell: bash -l {0}
@@ -138,10 +187,10 @@ jobs:
138187
git remote add tokened_docs https://IntelPython:${{ secrets.GITHUB_TOKEN }}@github.com/IntelPython/dpctl.git
139188
git fetch tokened_docs
140189
git checkout --track tokened_docs/gh-pages
141-
[ -d "${TAG}" ] || mkdir "${TAG}"
142-
rm -rf "${TAG:?}/*"
143-
mv ~/docs/* "${TAG}/" || exit 1
144-
git add "${TAG}"
190+
# replace the directory outright so a re-run cannot merge into stale docs
191+
rm -rf "${TAG:?}"
192+
mv ~/docs "${TAG}" || exit 1
193+
git add --all "${TAG}"
145194
git config user.name 'github-actions[doc-deploy-bot]'
146195
git config user.email 'github-actions[doc-deploy-bot]@users.noreply.github.com'
147196
git commit -m "Docs backfilled for ${TAG}."

0 commit comments

Comments
 (0)