Skip to content

Add CONTRIBUTING.md #163

Add CONTRIBUTING.md

Add CONTRIBUTING.md #163

name: Diagnostic build log
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
jobs:
require-diagnostic-build-log:
name: Require diagnostic build log bundle in PR
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Verify new diagnostic .logd and .json are committed in this PR
shell: bash
run: |
set -euo pipefail
base_sha="${{ github.event.pull_request.base.sha }}"
head_sha="${{ github.event.pull_request.head.sha }}"
echo "Checking PR diff from ${base_sha} to ${head_sha}"
mapfile -t new_logd < <(
git diff --name-only --diff-filter=A "${base_sha}...${head_sha}" -- 'diagnostic/*.logd'
)
mapfile -t new_json < <(
git diff --name-only --diff-filter=A "${base_sha}...${head_sha}" -- 'diagnostic/*.json'
)
if [ "${#new_logd[@]}" -eq 0 ]; then
echo "::error::This PR must commit a new diagnostic .logd file under diagnostic/."
exit 1
fi
if [ "${#new_json[@]}" -eq 0 ]; then
echo "::error::This PR must commit a new diagnostic .json file under diagnostic/."
exit 1
fi
echo "Found new diagnostic .logd file(s):"
printf ' - %s\n' "${new_logd[@]}"
echo "Found new diagnostic .json file(s):"
printf ' - %s\n' "${new_json[@]}"
for file in "${new_logd[@]}" "${new_json[@]}"; do
if [ ! -f "${file}" ]; then
echo "::error file=${file}::Diagnostic file path is not a file."
exit 1
fi
if [ ! -s "${file}" ]; then
echo "::error file=${file}::Diagnostic file is empty."
exit 1
fi
done