File: ci-pages-notify.bash

package info (click to toggle)
verilator 5.044-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 69,096 kB
  • sloc: cpp: 152,937; python: 22,624; ansic: 11,002; yacc: 6,111; lex: 2,011; makefile: 1,428; sh: 603; perl: 302
file content (46 lines) | stat: -rwxr-xr-x 1,607 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env bash
# DESCRIPTION: Verilator: CI script for 'pages.yml', notifies PRs
#
# Copyright 2025 by Geza Lore. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
#
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0

# Notify PRs via comment that their coverage reports are available

# Get the current repo URL - might differ on a fork
readonly REPO_URL=$(gh repo view --json url --jq .url)

# Create artifacts root directory
ARTIFACTS_ROOT=artifacts
mkdir -p ${ARTIFACTS_ROOT}

for RUN_ID in ${COVERAGE_PR_RUN_IDS//,/ }; do
  echo "@@@ Processing run ${RUN_ID}"

  # Create workflow artifacts directory
  ARTIFACTS_DIR=${ARTIFACTS_ROOT}/${RUN_ID}
  mkdir -p ${ARTIFACTS_DIR}

  # Download artifact of this run, if exists
  gh run download ${RUN_ID} --name coverage-pr-notification --dir ${ARTIFACTS_DIR} || true
  ls -lsha ${ARTIFACTS_DIR}

  # Move on if no notification is required
  if [ ! -f ${ARTIFACTS_DIR}/pr-number.txt ]; then
    echo "No notification found"
    continue
  fi
  echo "Posting notification found"

  cat ${ARTIFACTS_DIR}/body.txt
  gh pr comment $(cat ${ARTIFACTS_DIR}/pr-number.txt) --body-file ${ARTIFACTS_DIR}/body.txt

  # Get the artifact ID
  ARTIFACT_ID=$(gh api "repos/{owner}/{repo}/actions/runs/${RUN_ID}/artifacts" --jq '.artifacts[] | select(.name == "coverage-pr-notification") | .id')

  # Delete it, so we only notify once
  gh api --method DELETE "repos/{owner}/{repo}/actions/artifacts/${ARTIFACT_ID}"
done