Skip to content

Commit

Permalink
Add Update third-party tests workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius committed Apr 3, 2024
1 parent 2d88aa4 commit 83b50f0
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/update_third_party_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Update third-party tests

on:
schedule:
- cron: "0 3 * * 2" # 2 = Tuesday
workflow_dispatch:

concurrency:
group: update-third-party-tests-${{ github.ref }}
cancel-in-progress: true

jobs:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- run: |
scripts/update_third_party_tests.sh
cargo test --test third_party_0 --test third_party_1
env:
BLESS: 1
- name: Create pull request
uses: peter-evans/create-pull-request@v6
with:
title: "Update AFLplusplus"
token: ${{ secrets.REPO_TOKEN }}
branch-suffix: random
41 changes: 41 additions & 0 deletions scripts/update_third_party_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#! /bin/bash

# set -x
set -euo pipefail

if [[ $# -ne 0 ]]; then
echo "$0: expect no arguments" >&2
exit 1
fi

SCRIPTS="$(dirname "$(realpath "$0")")"
WORKSPACE="$(realpath "$SCRIPTS"/..)"

cd "$WORKSPACE"/necessist/tests/third_party_tests

find . -name '*.toml' |
while read X; do
URL="$(cat "$X" | sed -n 's/^url = "\([^"]*\)"$/\1/;T;p')"
REV="$(cat "$X" | sed -n 's/^rev = "\([^"]*\)"$/\1/;T;p')"
if [[ -z "$REV" ]]; then
continue;
fi
# smoelius: Skip revisions that are hashes.
if [[ "$REV" =~ [0-9A-Fa-f]{7,40} ]]; then
continue;
fi
ORG="$(echo "$URL" | sed -n 's,^https://github.com/\([^/]*\)/[^/]*.*$,\1,;T;p')"
REPO="$(echo "$URL" | sed -n 's,^https://github.com/[^/]*/\([^/]*\).*$,\1,;T;p')"
LATEST_RELEASE_URL="https://api.github.com/repos/$ORG/$REPO/releases/latest"
LATEST_RELEASE="$(curl \
-H "Accept: application/vnd.github+json" \
-H "Authentication: Bearer $GITHUB_TOKEN" \
--silent --show-error "$LATEST_RELEASE_URL")"
TAG="$(echo "$LATEST_RELEASE" | jq -r .tag_name)"
if [[ "$TAG" = 'null' ]]; then
echo -n "$X: "
echo "$LATEST_RELEASE" | jq .
continue
fi
sed -i "s/^rev = \"[^\"]*\"$/rev = \"$TAG\"/" "$X"
done

0 comments on commit 83b50f0

Please sign in to comment.