From e53981dd63a2d867c7369d5d9c70e558b22d4aa4 Mon Sep 17 00:00:00 2001 From: Tiziano Santoro Date: Tue, 21 Apr 2020 10:00:03 +0100 Subject: [PATCH] Make rust doc deterministic (#878) Avoid committing if there is no change compared to the previous version, to keep history clean. Ref #246 --- .github/workflows/build_rust_docs.yaml | 11 ++++++++--- scripts/build_gh_pages | 3 +++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_rust_docs.yaml b/.github/workflows/build_rust_docs.yaml index aa517a6b44d..7b287c05ee3 100644 --- a/.github/workflows/build_rust_docs.yaml +++ b/.github/workflows/build_rust_docs.yaml @@ -52,11 +52,16 @@ jobs: run: ./scripts/docker_run ./scripts/build_gh_pages ./out # From the "out" folder, commit the results and push to gh-pages. - # This step only applies to `push` events (not `pull_request`). + # This step only applies to `push` events (not `pull_request`), and only if there are actual + # changes to commit in the "out" folder. - name: Commit and push (post-merge only) if: github.event_name == 'push' run: | cd ./out git add . - git commit --message="Update gh-pages from ${GITHUB_SHA}" - git push + if [[ -n "$(git status --porcelain)" ]]; then + git commit --message="Update gh-pages from ${GITHUB_SHA}" + git push + else + echo 'no changes to commit' + fi diff --git a/scripts/build_gh_pages b/scripts/build_gh_pages index d31042f45c9..d54d9b1c61f 100755 --- a/scripts/build_gh_pages +++ b/scripts/build_gh_pages @@ -35,6 +35,9 @@ cargo doc --no-deps --target-dir="${TARGET_DIR}" # Remove non-doc artifacts from the target dir. rm --recursive --force "${TARGET_DIR}/debug" +# Remove non-deterministic files. +rm "${TARGET_DIR}/.rustc_info.json" + # The docs generated from the Cargo workspace do not include a workspace-level index, so we generate # one here and redirect to the Oak SDK documentation. cat <<-END > "${TARGET_DIR}/index.html"