Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sccache reporting in CI summaries. #3621

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
import os
import re

# sccache started reporting PTX/CUBIN hits.
# We filter these out as they are not included in the `compile_requests` counter.
sccache_languages = ["C/C++", "CUDA"]


def job_succeeded(job):
# The job was successful if the success file exists:
Expand Down Expand Up @@ -91,7 +95,8 @@ def update_summary_entry(entry, job, job_times=None):
if "counts" in cache_hits:
counts = cache_hits["counts"]
for lang, lang_hits in counts.items():
hits += lang_hits
if lang in sccache_languages:
hits += lang_hits
if "sccache" not in entry:
entry["sccache"] = {"requests": requests, "hits": hits}
else:
Expand Down
44 changes: 28 additions & 16 deletions .github/actions/workflow-run-job-linux/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,16 @@ runs:
ln -s "$(pwd)" "${{github.workspace}}"
cd "${{github.workspace}}"

cat <<"EOF" > ci.sh
mkdir artifacts

cat <<'EOF' > ci.sh
#! /usr/bin/env bash
set -eo pipefail
set -euo pipefail
echo -e "\e[1;34mRunning as '$(whoami)' user in $(pwd):\e[0m"
echo -e "\e[1;34m${COMMAND}\e[0m"
eval "${COMMAND}" || exit_code=$?
if [ ! -z "$exit_code" ]; then
eval "${COMMAND}"
exit_code=$?
if [[ "$exit_code" -ne 0 ]]; then
echo -e "::group::️❗ \e[1;31mInstructions to Reproduce CI Failure Locally\e[0m"
echo "::error:: To replicate this failure locally, follow the steps below:"
echo "1. Clone the repository, and navigate to the correct branch and commit:"
Expand All @@ -107,6 +110,22 @@ runs:
echo " - Continuous Integration (CI) Overview: https://github.com/NVIDIA/cccl/blob/main/ci-overview.md"
exit $exit_code
fi

# Copy any artifacts we want to preserve out of the container:
results_dir=/artifacts

# Finds a matching file in the repo directory and copies it to the results directory.
find_and_copy() {
filename="$1"
filepath="$(find . -name "${filename}" -print -quit)"
if [[ -z "$filepath" ]]; then
echo "${filename} does not exist in repo directory."
return 1
fi
cp -v "$filepath" "$results_dir"
}

find_and_copy "sccache_stats.json" || :
EOF

chmod +x ci.sh
Expand Down Expand Up @@ -167,6 +186,7 @@ runs:
--env "GITHUB_REPOSITORY=$GITHUB_REPOSITORY" \
--env "GITHUB_STEP_SUMMARY=$GITHUB_STEP_SUMMARY" \
--volume "${{github.workspace}}/ci.sh:/ci.sh" \
--volume "${{github.workspace}}/artifacts:/artifacts" \
--volume "$(host_path "$RUNNER_TEMP")/.aws:/root/.aws" \
--volume "$(dirname "$(dirname "${{github.workspace}}")"):/__w" \
-- /ci.sh
Expand All @@ -180,18 +200,10 @@ runs:

touch "$result_dir/success"

# Finds a matching file in the repo directory and copies it to the results directory.
find_and_copy() {
filename="$1"
filepath="$(find ${{github.event.repository.name}} -name "${filename}" -print -quit)"
if [[ -z "$filepath" ]]; then
echo "${filename} does not exist in repo directory."
return 1
fi
cp -v "$filepath" "$result_dir"
}

find_and_copy "sccache_stats.json" || true # Ignore failures
artifacts_exist="$(ls -A artifacts)"
if [ "$artifacts_exist" ]; then
cp -rv artifacts/* "$result_dir"
fi

echo "::group::Job artifacts"
tree "$result_dir"
Expand Down
Loading