Skip to content

Check today's snapshot #1682

Check today's snapshot

Check today's snapshot #1682

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: {}
jobs:
check-todays-snapshot:
runs-on: ubuntu-latest
container: fedora:38
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
- uses: actions/checkout@v3
- name: "Variables and functions"
shell: bash -e {0}
run: |
source github/functions.sh
today=`date +%Y%m%d`
username=@fedora-llvm-team
echo "username=$username" >> $GITHUB_ENV
echo "today_yyyymmdd=$today" >> $GITHUB_ENV
echo "project_today=$username/llvm-snapshots-incubator-$today" >> $GITHUB_ENV
- name: "Install GitHub’s official command line tool: gh"
shell: bash -e {0}
run: |
source github/functions.sh
install_gh_client
- name: "Check for good builds"
shell: bash -e {0}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAINTAINER_HANDLE: "tbaederr"
run: |
source github/functions.sh
if was_broken_snapshot_detected_today; then
echo "We already filed an issue for broken snapshots 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 ! has_all_good_builds ${{env.project_today}} > /tmp/diff; then
if grep -i "failed" /tmp/diff; then
cat <<EOF > body.txt
Hello @${MAINTAINER_HANDLE},
looking at the [Fedora Copr build monitor](https://copr.fedorainfracloud.org/coprs/g/fedora-llvm-team/llvm-snapshots-incubator-${{env.today_yyyymmdd}}/monitor/) for ${{env.today_yyyymmdd}} we found at least one failed build:
\`\`\`diff
$(cat /tmp/diff)
\`\`\`
EOF
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`
# Ensure labels for OS, project and arch exist in github project
for arch in $archs; do gh --repo ${GITHUB_REPOSITORY} label create arch/$arch --force; done
for project in $projects; do gh --repo ${GITHUB_REPOSITORY} label create project/$project --force; done
for os in $oses; do gh --repo ${GITHUB_REPOSITORY} label create os/$os --force; done
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`
gh --repo ${GITHUB_REPOSITORY} issue create \
--label broken_snapshot_detected $os_labels $arch_labels $project_labels \
--assignee ${MAINTAINER_HANDLE} \
--title "Broken snapshot for ${{env.today_yyyymmdd}} detected" \
--body-file body.txt
exit 1
fi
fi