-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #112407 - tgross35:ci-docs-publish, r=Mark-Simulacrum
Publish docs as github artifacts during CI Discussed here: https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/Building.20docs.20for.20PR.20CI The goal is to make docs available for download after CI runs on PRs, for easy review of API changes. Notes: - Currently this only captures library documentation (`core`, `alloc`, `std`, `test`, `proc_macro`) - You can't see artifacts until the entire workflow run has completed actions/upload-artifact#53 - There is currently a generic file name `ci-artifacts`. No way to customize this based on contained files unfortunately actions/upload-artifact#349 You can find the results at the bottom of the CI "summary" page: <img width="379" alt="image" src="https://github.com/rust-lang/rust/assets/13724985/d3748e59-242c-40f8-9f54-82177b9b481b">
- Loading branch information
Showing
4 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
# Compress doc artifacts and name them based on the commit, or the date if | ||
# commit is not available. | ||
|
||
set -euox pipefail | ||
|
||
# Try to get short commit hash, fallback to date | ||
if [ -n "$HEAD_SHA" ]; then | ||
short_rev=$(echo "${HEAD_SHA}" | cut -c1-8) | ||
else | ||
short_rev=$(git rev-parse --short HEAD || date -u +'%Y-%m-%dT%H%M%SZ') | ||
fi | ||
|
||
# Try to get branch, fallback to none | ||
branch=$(git branch --show-current || echo) | ||
|
||
if [ -n "$branch" ]; then | ||
branch="${branch}-" | ||
fi | ||
|
||
if [ "${GITHUB_EVENT_NAME:=none}" = "pull_request" ]; then | ||
pr_num=$(echo "$GITHUB_REF_NAME" | cut -d'/' -f1) | ||
name="doc-${pr_num}-${short_rev}" | ||
else | ||
name="doc-${branch}${short_rev}" | ||
fi | ||
|
||
|
||
if [ -d "obj/staging/doc" ]; then | ||
mkdir -p obj/artifacts/doc | ||
|
||
# Level 12 seems to give a good tradeoff of time vs. space savings | ||
ZSTD_CLEVEL=12 ZSTD_NBTHREADS=4 \ | ||
tar --zstd -cf "obj/artifacts/doc/${name}.tar.zst" -C obj/staging/doc . | ||
|
||
ls -lh obj/artifacts/doc | ||
fi | ||
|
||
# Set this environment variable for future use if running in CI | ||
if [ -n "$GITHUB_ENV" ]; then | ||
echo "DOC_ARTIFACT_NAME=${name}" >> "$GITHUB_ENV" | ||
fi |