From 83b50f045683516bb04e6813d881e8ede661e4dd Mon Sep 17 00:00:00 2001 From: Samuel Moelius Date: Tue, 2 Apr 2024 22:01:24 -0400 Subject: [PATCH] Add `Update third-party tests` workflow --- .../workflows/update_third_party_tests.yml | 31 ++++++++++++++ scripts/update_third_party_tests.sh | 41 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 .github/workflows/update_third_party_tests.yml create mode 100755 scripts/update_third_party_tests.sh diff --git a/.github/workflows/update_third_party_tests.yml b/.github/workflows/update_third_party_tests.yml new file mode 100644 index 00000000..7384e69f --- /dev/null +++ b/.github/workflows/update_third_party_tests.yml @@ -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 diff --git a/scripts/update_third_party_tests.sh b/scripts/update_third_party_tests.sh new file mode 100755 index 00000000..42b43d35 --- /dev/null +++ b/scripts/update_third_party_tests.sh @@ -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