-
Notifications
You must be signed in to change notification settings - Fork 8
169 lines (140 loc) · 6.83 KB
/
check-todays-snapshot.yml
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: "Check today's snapshot"
on:
schedule:
# At every 60th minute.
# See https://docs.github.com/en/actions/reference/events-that-trigger-workflows#schedule
- cron: "*/60 * * * *"
workflow_dispatch: {}
permissions:
# We need this in order to create or update broken snapshot issues
issues: write
jobs:
check-todays-snapshot:
strategy:
fail-fast: false
matrix:
name: [standalone, big-merge, bootstrap]
include:
- name: standalone
maintainer_handle: "tuliom"
copr_project_tpl: "@fedora-llvm-team/llvm-snapshots-incubator-YYYYMMDD"
copr_monitor_tpl: "https://copr.fedorainfracloud.org/coprs/g/fedora-llvm-team/llvm-snapshots-incubator-YYYYMMDD/monitor/"
needs_llvm_snapshot_builder: true
- name: big-merge
maintainer_handle: "kwk"
copr_project_tpl: "@fedora-llvm-team/llvm-snapshots-big-merge-YYYYMMDD"
copr_monitor_tpl: "https://copr.fedorainfracloud.org/coprs/g/fedora-llvm-team/llvm-snapshots-big-merge-YYYYMMDD/monitor/"
extra_script_file: "scripts/functions-big-merge.sh"
needs_llvm_snapshot_builder: false
- name: bootstrap
maintainer_handle: "kwk"
copr_project_tpl: "@fedora-llvm-team/llvm-snapshots-bootstrap-YYYYMMDD"
copr_monitor_tpl: "https://copr.fedorainfracloud.org/coprs/g/fedora-llvm-team/llvm-snapshots-bootstrap-YYYYMMDD/monitor/"
extra_script_file: "scripts/functions-bootstrap.sh"
needs_llvm_snapshot_builder: false
runs-on: ubuntu-latest
container: fedora:39
steps:
- name: Setup Copr config file
env:
# You need to have those secrets in your repo.
# See also: https://copr.fedorainfracloud.org/api/.
COPR_CONFIG_FILE: ${{ secrets.COPR_CONFIG }}
run: |
mkdir -p ~/.config
printf "$COPR_CONFIG_FILE" > ~/.config/copr
- name: Install Copr CLI
run: |
dnf install -y copr-cli diffutils pcre2-tools jq
- uses: actions/checkout@v4
- name: "Variables and functions"
shell: bash -e {0}
run: |
source scripts/functions.sh
[[ ! -z "${{ matrix.extra_script_file }}" ]] && source ${{ matrix.extra_script_file }}
today=`date +%Y%m%d`
username=@fedora-llvm-team
echo "username=$username" >> $GITHUB_ENV
echo "today_yyyymmdd=$today" >> $GITHUB_ENV
echo "project_today=${{ matrix.copr_project_tpl }}" | sed "s/YYYYMMDD/$today/" >> $GITHUB_ENV
echo "monitor_url=${{ matrix.copr_monitor_tpl }}" | sed "s/YYYYMMDD/$today/" >> $GITHUB_ENV
- name: "Install GitHub’s official command line tool: gh"
shell: bash -e {0}
run: |
source scripts/functions.sh
[[ ! -z "${{ matrix.extra_script_file }}" ]] && source ${{ matrix.extra_script_file }}
install_gh_client
- name: "Check for good builds"
shell: bash -e {0}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
source scripts/functions.sh
[[ ! -z "${{ matrix.extra_script_file }}" ]] && source ${{ matrix.extra_script_file }}
if was_broken_snapshot_detected_today ${GITHUB_REPOSITORY} ${{ matrix.name }}; then
echo "We already filed an issue for broken snapshots today."
handle_error_causes \
${GITHUB_REPOSITORY} \
${{ matrix.name }} \
${{ matrix.maintainer_handle }} \
${{ env.project_today }}
exit 0;
fi
if ! copr_project_exists ${{ env.project_today }}; then
echo "The copr project ${{ env.project_today }} does not exist (yet)."
exit 0;
fi
if [ "${{ matrix.needs_llvm_snapshot_builder }}" == "true" ]; then
extra_packages=llvm-snapshot-builder
fi
if ! has_all_good_builds ${{ env.project_today }} $extra_packages > /tmp/diff; then
if grep -i "failed" /tmp/diff; then
cat <<EOF > body.txt
Hello @${{ matrix.maintainer_handle }},
<details>
<summary>Looking at the <a href="${{ env.monitor_url }}">Fedora Copr build monitor</a> for ${{ env.today_yyyymmdd }} we found at least one failed build.</summary>
\`\`\`diff
$(cat /tmp/diff)
\`\`\`
</details>
The CI system will update this very comment over time to list the errors.
Please note, that logs snippets will be limited to `max_context_bytes` bytes.
`update_marker`
EOF
causes_file=`mktemp`
archs=`grep -ioP 'failed\s+[^-]+-[0-9,rawhide]+-\K[^\s]+' /tmp/diff | sort | uniq`
projects=`grep -ioP 'failed\s+[^\s]+\s+\K[^\s]+$' /tmp/diff | sort | uniq`
oses=`grep -ioP 'failed\s+\K.*' /tmp/diff | cut -d '-' -f 1-2 | sort | uniq`
error_causes=`get_error_causes ${{ env.project_today }} $causes_file`
# Ensure labels for arch, project, OS, strategy and error cause
# exist in the github project
create_labels_for_archs ${GITHUB_REPOSITORY} "$archs"
create_labels_for_projects ${GITHUB_REPOSITORY} "$projects"
create_labels_for_oses ${GITHUB_REPOSITORY} "$oses"
create_labels_for_strategies ${GITHUB_REPOSITORY} "${{ matrix.name }}"
create_labels_for_error_causes ${GITHUB_REPOSITORY} "$error_causes"
os_labels=`for os in $oses; do echo -n " --label os/$os "; done`
arch_labels=`for arch in $archs; do echo -n " --label arch/$arch " ; done`
project_labels=`for project in $projects; do echo -n " --label project/$project "; done`
error_labels=`for cause in $error_causes; do echo -n " --label error/$cause "; done`
strategy_labels=" --label strategy/${{ matrix.name }} "
gh --repo ${GITHUB_REPOSITORY} issue create \
--label broken_snapshot_detected $strategy_labels $os_labels $arch_labels $project_labels $error_labels \
--assignee ${{ matrix.maintainer_handle }} \
--title "Broken snapshot for ${{ env.today_yyyymmdd }} detected (${{ matrix.name }})" \
--body-file body.txt
# When you create an issue with:
# gh issue create
# the issue is not immediately found with:
# gh issue list
# Therefore we give it a bit of time before we continue here.
sleep 5;
handle_error_causes \
${GITHUB_REPOSITORY} \
${{ matrix.name }} \
${{ matrix.maintainer_handle }} \
${{ env.project_today }} \
$causes_file
exit 1
fi
fi