mirror of
https://github.com/RustyRaptor/flathub.git
synced 2026-12-03 15:45:20 -07:00
external-data-checker: Use code search and shard apps
This commit is contained in:
1 parent
d28484d740
commit
75cdffb8b3
2 files changed
+65
-9
No files matched your search
@@ -11,9 +11,7 @@ git config --global user.email "sysadmin@flathub.org"
|
||||
mkdir flathub
|
||||
cd flathub || exit
|
||||
|
||||
gh repo list flathub --visibility public -L 8000 --json url --json isArchived --jq '.[] | select(.isArchived == false)|.url' | parallel "git clone --depth 1 {}"
|
||||
|
||||
echo "==> Deleting inactive repos"
|
||||
echo "==> Fetching inactive repos"
|
||||
inactive_repos_url="https://builds.flathub.org/api/inactive-repos.txt"
|
||||
inactive_repos_file=$(mktemp) || exit 1
|
||||
|
||||
@@ -32,16 +30,68 @@ while IFS= read -r folder || [[ -n "$folder" ]]; do
|
||||
fi
|
||||
done < "$inactive_repos_file"
|
||||
|
||||
while IFS= read -r folder; do
|
||||
if [[ -d "./$folder" ]]; then
|
||||
echo "==> Deleting $folder"
|
||||
rm -rf -- "./$folder"
|
||||
fi
|
||||
declare -A inactive_repos=()
|
||||
while IFS= read -r folder || [[ -n "$folder" ]]; do
|
||||
inactive_repos["$folder"]=1
|
||||
done < "$inactive_repos_file"
|
||||
|
||||
rm -f -- "$inactive_repos_file"
|
||||
|
||||
mapfile -t checker_apps < <( grep -rl -E 'extra-data|x-checker-data|\.AppImage' | cut -d/ -f1 | sort -u | shuf )
|
||||
declare -A candidates=()
|
||||
if [[ -n "${APP_ID:-}" ]]; then
|
||||
if [[ ! "$APP_ID" =~ ^[A-Za-z0-9._-]+$ || "$APP_ID" == "." || "$APP_ID" == ".." ]]; then
|
||||
echo "Invalid application ID" >&2
|
||||
exit 1
|
||||
fi
|
||||
candidates["$APP_ID"]=1
|
||||
else
|
||||
hour=$(date -u +%H)
|
||||
shard=$((10#$hour / 4))
|
||||
echo "==> Discovering apps for shard $shard/6"
|
||||
for marker in extra-data x-checker-data .AppImage; do
|
||||
for extension in json yaml yml; do
|
||||
query="\"$marker\" org:flathub in:file extension:$extension"
|
||||
page=1
|
||||
while :; do
|
||||
sleep 6.1
|
||||
result=$(gh api --method GET search/code \
|
||||
-f q="$query" -F per_page=100 -F page="$page") || exit 1
|
||||
if ! jq -e '.incomplete_results == false and .total_count < 1000' \
|
||||
<<< "$result" > /dev/null; then
|
||||
echo "Incomplete search or 1000-result ceiling reached: $query (page $page)" >&2
|
||||
exit 1
|
||||
fi
|
||||
repos=$(jq -r '.items[].repository | select(.private == false) | .name' \
|
||||
<<< "$result") || exit 1
|
||||
while IFS= read -r repo; do
|
||||
[[ -n "$repo" ]] || continue
|
||||
if [[ "$marker" == extra-data ]]; then
|
||||
candidates["$repo"]=1
|
||||
elif [[ -z "${candidates[$repo]:-}" ]]; then
|
||||
candidates["$repo"]=0
|
||||
fi
|
||||
done <<< "$repos"
|
||||
total=$(jq -r '.total_count' <<< "$result") || exit 1
|
||||
((page * 100 < total)) || break
|
||||
((page++))
|
||||
done
|
||||
done
|
||||
done
|
||||
fi
|
||||
|
||||
checker_apps=()
|
||||
for repo in "${!candidates[@]}"; do
|
||||
[[ -z "${inactive_repos[$repo]:-}" ]] || continue
|
||||
if [[ "${candidates[$repo]}" == 0 ]]; then
|
||||
checksum=$(printf '%s' "$repo" | cksum)
|
||||
checksum=${checksum%% *}
|
||||
((checksum % 6 == shard)) || continue
|
||||
fi
|
||||
active=$(gh api "repos/flathub/$repo" --jq '.archived == false and .private == false') || exit 1
|
||||
[[ "$active" == true ]] || continue
|
||||
git clone --depth 1 "https://github.com/flathub/$repo.git" || exit 1
|
||||
checker_apps+=("$repo")
|
||||
done
|
||||
|
||||
for repo in "${checker_apps[@]}"; do
|
||||
FEDC_OPTS=()
|
||||
|
||||
@@ -4,6 +4,11 @@ on:
|
||||
- cron: '0 */4 * * *'
|
||||
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
app_id:
|
||||
description: 'Application ID to check instead of the global shard'
|
||||
required: false
|
||||
type: string
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
@@ -25,3 +30,4 @@ jobs:
|
||||
- uses: ./.github/actions/flatpak-external-data-checker
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.FLATHUBBOT_TOKEN }}
|
||||
APP_ID: ${{ inputs.app_id }}
|
||||
Reference in new issue
Block a user