From a12c7f8d37ff64501f221eab4853e8548a3263dc Mon Sep 17 00:00:00 2001 From: Zakk Date: Thu, 1 Oct 2026 17:23:17 +1000 Subject: [PATCH] .github: share Gentoo setup and changed-package detection The repeated stage3 setup obscures the package tests. Because gh pr view stops at 100 files, use every API page so large PRs test every changed package. Match ignore prefixes literally because regex metacharacters also exclude unrelated paths. Signed-off-by: Zakk --- .github/actions/setup-gentoo/action.yml | 52 +++++++ .github/workflows/emerge-on-pr.yml | 183 ++---------------------- .github/workflows/tatt.yml | 114 +-------------- scripts/emerge-targets.sh | 86 +++++++++++ scripts/tatt-targets.sh | 100 +++++++++++++ 5 files changed, 257 insertions(+), 278 deletions(-) create mode 100644 .github/actions/setup-gentoo/action.yml create mode 100755 scripts/emerge-targets.sh create mode 100755 scripts/tatt-targets.sh diff --git a/.github/actions/setup-gentoo/action.yml b/.github/actions/setup-gentoo/action.yml new file mode 100644 index 0000000000..8f99216849 --- /dev/null +++ b/.github/actions/setup-gentoo/action.yml @@ -0,0 +1,52 @@ +name: Setup Gentoo +description: Configure the stage3 container for overlay CI +runs: + using: composite + steps: + - name: sync gentoo main tree + shell: bash + run: emerge-webrsync --no-pgp-verify + + - name: setup repo + shell: bash + run: | + mkdir -p /etc/portage/repos.conf + cat > /etc/portage/repos.conf/ci.conf << EOF + [$(cat profiles/repo_name)] + location = $(realpath .) + priority = 0 + EOF + + - name: setup portage config + shell: bash + run: | + cat >> /etc/portage/make.conf << EOF + MAKEOPTS="\${MAKEOPTS} -j$(nproc)" + PORTAGE_ELOG_CLASSES="qa warn error" + PORTAGE_ELOG_SYSTEM="save" + FETCHCOMMAND="\${FETCHCOMMAND} --no-verbose" + RESUMECOMMAND="\${RESUMECOMMAND} --no-verbose" + EOF + cat > /etc/portage/binrepos.conf/ci.conf << EOF + [$(cat profiles/repo_name)-binhost] + sync-uri = https://distfiles.gentoozh.org/binpkgs/x86-64 + priority = 2 + EOF + mkdir -p /etc/portage/package.use + printf '%s\n' 'dev-qt/qtwebengine bindist' 'net-libs/webkit-gtk keyring' > /etc/portage/package.use/ci + cat /etc/portage/make.conf + + - name: setup keyring for binpkgs + shell: bash + run: | + getuto + export GNUPGHOME=/etc/portage/gnupg + wget -qO - https://distfiles.gentoozh.org/gentoo-zh-binhost.asc | gpg --import + gpg --batch --yes --pinentry-mode loopback --passphrase-file "$GNUPGHOME/pass" --lsign-key 6A0726AF1476A2F382C6AC6638A0234EC16AD42E + gpg --batch --check-trustdb + + - name: setup distfiles permissions + shell: bash + run: | + install -dm775 -o root -g portage /var/cache/distfiles + install -dm775 -o portage -g portage /var/cache/distfiles/git3-src diff --git a/.github/workflows/emerge-on-pr.yml b/.github/workflows/emerge-on-pr.yml index d42a59a8ba..35eca42032 100644 --- a/.github/workflows/emerge-on-pr.yml +++ b/.github/workflows/emerge-on-pr.yml @@ -26,126 +26,11 @@ jobs: - name: scan changed ebuilds env: GH_TOKEN: ${{ github.token }} + PR: ${{ github.event.pull_request.number }} id: packages run: | - declare -a packages=() - # new or modifie - for file in $(gh pr view ${{ github.event.pull_request.number }} --json files --jq '.files[] | select(.additions > 0) | .path'); do - if [[ "$file" == *.ebuild ]]; then - packages+=(\=$(echo "$file" | awk -F'/' '{ sub(/\.ebuild$/, "", $3); print $1"/"$3 }')) - else - packages+=($(echo "$file" | awk -F'/' '{print $1"/"$2}')) - fi - done - echo "scan additions files: $(printf '%s\n' "${packages[@]}" | sort -u | jq -R . | jq -s .)" - - # treeclean, delete and modifie - for file in $(gh pr view ${{ github.event.pull_request.number }} --json files --jq '.files[] | select(.deletions > 0) | .path'); do - if [ ! -d "$(echo "$file" | awk -F'/' '{print $1"/"$2}')" ]; then - continue - elif [[ "$file" == *.ebuild ]]; then - if [ -f "$file" ]; then - packages+=(\=$(echo "$file" | awk -F'/' '{ sub(/\.ebuild$/, "", $3); print $1"/"$3 }')) - fi - else - packages+=($(echo "$file" | awk -F'/' '{print $1"/"$2}')) - fi - done - - echo "scan deletions files: $(printf '%s\n' "${packages[@]}" | sort -u | jq -R . | jq -s .)" - - # git mv (without modified) - for file in $(gh pr view ${{ github.event.pull_request.number }} --json files --jq '.files[] | select(.deletions == 0 and .additions == 0) | .path'); do - if [[ "$file" == *.ebuild ]]; then - packages+=(\=$(echo "$file" | awk -F'/' '{ sub(/\.ebuild$/, "", $3); print $1"/"$3 }')) - else - packages+=($(echo "$file" | awk -F'/' '{print $1"/"$2}')) - fi - done - - echo "scan non-modified files: $(printf '%s\n' "${packages[@]}" | sort -u | jq -R . | jq -s .)" - - declare -a ignore_list=( - .agents - .gitignore - AGENTS.md - AUTHORS - COPYING - MIGRATION.md - README.md - README.en.md - README.zh-TW.md - README.yue.md - repo.xml - skel.ChangeLog - skel.metadata.xml - .github - eclass - licenses - metadata - profiles - scripts - ) - for i in "${ignore_list[@]}"; do - packages=($(printf '%s\n' "${packages[@]}" | grep -v "^$i" || true)) - done - - # the ebuild gives "=cat/pn-ver" and its Manifest the bare "cat/pn": one build, two - # atoms. A package with no versioned atom (files/-only, treeclean) keeps its bare one. - declare -a deduped=() - for atom in "${packages[@]}"; do - if [[ "$atom" != =* ]] && printf '%s\n' "${packages[@]}" | grep -q "^=${atom}-"; then - continue - fi - deduped+=("$atom") - done - packages=("${deduped[@]}") - - echo "scan all files: $(printf '%s\n' "${packages[@]}" | sort -u | jq -R . | jq -s .)" - - # arm64 subset: keep only atoms whose ebuild keywords arm64 (stable or ~). - # -arm64 / no keyword -> dropped, so those packages only build on amd64. - declare -a arm64_packages=() - while IFS= read -r atom; do - [ -z "$atom" ] && continue - if [[ "$atom" == =* ]]; then - pf="${atom##*/}"; cat="${atom#=}"; cat="${cat%%/*}" - ebuilds=("$cat"/*/"$pf".ebuild) - else - ebuilds=("$atom"/*.ebuild) - fi - for eb in "${ebuilds[@]}"; do - [ -f "$eb" ] || continue - kw=$(sed -n 's/^KEYWORDS="\(.*\)"/\1/p' "$eb") - for tok in $kw; do - if [[ "$tok" == "arm64" || "$tok" == "~arm64" ]]; then - arm64_packages+=("$atom"); break 2 - fi - done - done - done < <(printf '%s\n' "${packages[@]}" | sort -u) - - echo "scan arm64 files: $(printf '%s\n' "${arm64_packages[@]}" | sort -u | jq -R . | jq -s .)" - - # emerge matrix: one entry per (package, profile, runner). every package builds on - # both amd64 profiles; arm64-keyworded ones also on arm64-desktop-systemd (arm64 has - # no desktop-openrc stage3). the build job fans out over this single list. - targets=$( - { - printf '%s\n' "${packages[@]}" | sort -u | while IFS= read -r p; do - [ -z "$p" ] && continue - printf '%s\t%s\t%s\n' "$p" amd64-desktop-openrc ubuntu-latest - printf '%s\t%s\t%s\n' "$p" amd64-desktop-systemd ubuntu-latest - done - printf '%s\n' "${arm64_packages[@]}" | sort -u | while IFS= read -r p; do - [ -z "$p" ] && continue - printf '%s\t%s\t%s\n' "$p" arm64-desktop-systemd ubuntu-24.04-arm - done - } | jq -R 'select(length>0)|split("\t")|{package:.[0],profile:.[1],runner:.[2]}' | jq -sc . - ) - echo "scan targets: $targets" - echo "targets=${targets}" >> "$GITHUB_OUTPUT" - + targets=$(scripts/emerge-targets.sh "$PR") + echo "targets=$targets" >> "$GITHUB_OUTPUT" build: name: emerge ${{ matrix.target.package }} (${{ matrix.target.profile }}) @@ -162,63 +47,15 @@ jobs: options: --privileged steps: - - name: sync gentoo main tree - run: emerge-webrsync --no-pgp-verify - - name: fetch repo uses: actions/checkout@v7 with: repository: ${{ github.event.pull_request.head.repo.full_name }} ref: ${{ github.event.pull_request.head.sha }} - - name: setup repo - run: | - mkdir -p /etc/portage/repos.conf - cat > /etc/portage/repos.conf/ci.conf << EOF - [$(cat profiles/repo_name)] - location = $(realpath .) - priority = 0 - EOF - - name: setup portage config - run: | - cat >> /etc/portage/make.conf << EOF - MAKEOPTS="\${MAKEOPTS} -j$(nproc)" - PORTAGE_ELOG_CLASSES="qa warn error" - PORTAGE_ELOG_SYSTEM="save" - FETCHCOMMAND="\${FETCHCOMMAND} --no-verbose" - RESUMECOMMAND="\${RESUMECOMMAND} --no-verbose" - EOF + uses: ./.github/actions/setup-gentoo - cat > /etc/portage/binrepos.conf/ci.conf << EOF - [$(cat profiles/repo_name)-binhost] - sync-uri = https://distfiles.gentoozh.org/binpkgs/x86-64 - priority = 2 - EOF - - mkdir -p /etc/portage/package.use - cat > /etc/portage/package.use/ci << EOF - dev-qt/qtwebengine bindist - net-libs/webkit-gtk keyring - EOF - - cat /etc/portage/make.conf - - - name: setup keyring for binpkgs - run: | - getuto - export GNUPGHOME=/etc/portage/gnupg - wget -qO - https://distfiles.gentoozh.org/gentoo-zh-binhost.asc | gpg --import - gpg --batch --yes --pinentry-mode loopback --passphrase-file "${GNUPGHOME}/pass" --lsign-key 6A0726AF1476A2F382C6AC6638A0234EC16AD42E - gpg --batch --check-trustdb - - - name: setup distfiles permissions - run: | - install -dm775 -o root -g portage /var/cache/distfiles - install -dm775 -o portage -g portage /var/cache/distfiles/git3-src - - # only a target whose REQUIRED_USE the baseline cannot meet gets the runner's CPU flags; - # other targets and every dependency keep the profile's baseline - name: setup cpu flags env: ATOM: ${{ matrix.target.package }} @@ -230,18 +67,22 @@ jobs: fi - name: emerge --onlydeps packages + env: + ATOM: ${{ matrix.target.package }} run: | - FEATURES="getbinpkg" emerge --onlydeps --jobs 2 --quiet --verbose --autounmask=y --autounmask-write=y --autounmask-continue=y ${{ matrix.target.package }} + FEATURES="getbinpkg" emerge --onlydeps --jobs 2 --quiet --verbose --autounmask=y --autounmask-write=y --autounmask-continue=y "$ATOM" rm -rf /var/log/portage/elog/* - name: emerge packages - run: emerge --verbose --autounmask=y --autounmask-write=y --autounmask-continue=y ${{ matrix.target.package }} + env: + ATOM: ${{ matrix.target.package }} + run: emerge --verbose --autounmask=y --autounmask-write=y --autounmask-continue=y "$ATOM" - name: check Portage elog (fail if exists) run: | if ls /var/log/portage/elog/* 1> /dev/null 2>&1; then - echo "❌ Found Portage elog messages:" + echo "Found Portage elog messages:" cat /var/log/portage/elog/* exit 1 fi - echo "✅ No elog messages found." + echo "No elog messages found." diff --git a/.github/workflows/tatt.yml b/.github/workflows/tatt.yml index fbf24972ae..1ac8d54acb 100644 --- a/.github/workflows/tatt.yml +++ b/.github/workflows/tatt.yml @@ -1,9 +1,5 @@ name: tatt -# USE-combination testing with app-portage/tatt on amd64. A changed ebuild is tested when the -# PR carries the `tatt` label, or when it has USE flags to vary and is new or changes IUSE or -# REQUIRED_USE; emerge-on-pr already builds every other one with its default flags. - on: pull_request: branches: @@ -41,73 +37,9 @@ jobs: PR: ${{ github.event.pull_request.number }} LABELED: ${{ contains(github.event.pull_request.labels.*.name, 'tatt') }} run: | - git fetch --quiet --depth=1 "https://github.com/$GITHUB_REPOSITORY" "$BASE" - # the checkout is the fork's, so name the repository; gh pr view lists only 100 files - gh api --paginate "repos/$GITHUB_REPOSITORY/pulls/$PR/files" \ - --jq '.[] | select(.additions > 0) | [.filename, .previous_filename // ""] | @tsv' > files.tsv - - # the IUSE and REQUIRED_USE assignments, one line each, double-quoted - use_vars() { - awk '!on && match($0, /^(IUSE|REQUIRED_USE)\+?=["\047]/) { on = 1; n = 0; q = substr($0, RLENGTH, 1) } - on { printf "%s ", $0; n += gsub(q, q); if (n % 2 == 0) { on = 0; print "" } }' | - tr "'" '"' | tr -s ' \t' ' ' - } - # the IUSE flags tatt varies, without the prefixes it ignores; an expansion counts as one - flags() { - use_vars | sed -n 's/^IUSE+\?="\([^"]*\)".*/\1/p' | tr ' ' '\n' | sed 's/^[+-]//' | - grep -vE '^$|^(test|debug|kdeenablefinal|elibc_|video_cards_|linguas_|python_targets_|python_single_target_|cpu_flags_)' || true - } - live='-9{4,}(-r[0-9]+)?\.ebuild$' - - printf '| ebuild | tatt |\n|---|---|\n' >> "$GITHUB_STEP_SUMMARY" - while IFS=$'\t' read -r ebuild previous; do - [[ "$ebuild" =~ ^[A-Za-z0-9+_.-]+/[A-Za-z0-9+_.-]+/[A-Za-z0-9+_.-]+\.ebuild$ && -f "$ebuild" ]] || continue - pkg=${ebuild%/*} - keywords=$(sed -n "s/^KEYWORDS=[\"']\(.*\)[\"'].*/\1/p" "$ebuild") - if [[ "$ebuild" =~ $live ]]; then - keyword='**' - elif [[ " $keywords " == *" ~amd64 "* || " $keywords " == *" amd64 "* ]]; then - keyword='~amd64' - else - keyword= - fi - - if [ -z "$keyword" ]; then - reason="skipped: not keyworded ~amd64" - elif [ "$LABELED" = true ]; then - reason="tested: tatt label" - elif [ -z "$(flags < "$ebuild")" ]; then - reason="skipped: no USE flag to vary" - elif [ -z "$(git ls-tree "$BASE" -- "$pkg/")" ]; then - reason="tested: new package" - else - # compare with the file it replaces, or with any release ebuild when it adds one - vars=$(use_vars < "$ebuild") - if [ -n "$previous" ]; then - old=("$previous") - elif git cat-file -e "$BASE:$ebuild" 2> /dev/null; then - old=("$ebuild") - else - mapfile -t old < <(git ls-tree --name-only "$BASE" -- "$pkg/" | grep '\.ebuild$' | grep -vE -- "$live") - fi - reason="tested: IUSE or REQUIRED_USE changed" - for f in "${old[@]}"; do - if [ "$(git show "$BASE:$f" | use_vars)" = "$vars" ]; then - reason="skipped: add the tatt label to test" - break - fi - done - fi - echo "| \`$ebuild\` | $reason |" >> "$GITHUB_STEP_SUMMARY" - if [[ "$reason" == tested:* ]]; then - IFS=/ read -r cat _ pf <<< "${ebuild%.ebuild}" - printf '%s\t%s\n' "=$cat/$pf" "$keyword" - fi - done < files.tsv > targets.tsv - - targets=$(jq -Rc 'split("\t") | {atom: .[0], keyword: .[1]}' targets.tsv | jq -sc .) + targets=$(scripts/tatt-targets.sh "$PR" "$BASE" "$LABELED") echo "targets: $targets" - echo "targets=${targets}" >> "$GITHUB_OUTPUT" + echo "targets=$targets" >> "$GITHUB_OUTPUT" tatt: name: tatt ${{ matrix.target.atom }} @@ -127,9 +59,6 @@ jobs: KEYWORD: ${{ matrix.target.keyword }} steps: - - name: sync gentoo main tree - run: emerge-webrsync --no-pgp-verify - - name: fetch repo uses: actions/checkout@v7 with: @@ -137,42 +66,13 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} - name: setup portage config + uses: ./.github/actions/setup-gentoo + + - name: setup repo run: | - mkdir -p /etc/portage/repos.conf /etc/portage/package.use /etc/portage/package.accept_keywords - cat > /etc/portage/repos.conf/ci.conf << EOF - [$(cat profiles/repo_name)] - location = $(realpath .) - priority = 0 - EOF - - cat >> /etc/portage/make.conf << EOF - MAKEOPTS="\${MAKEOPTS} -j$(nproc)" - FETCHCOMMAND="\${FETCHCOMMAND} --no-verbose" - RESUMECOMMAND="\${RESUMECOMMAND} --no-verbose" - EOF - - cat > /etc/portage/binrepos.conf/ci.conf << EOF - [$(cat profiles/repo_name)-binhost] - sync-uri = https://distfiles.gentoozh.org/binpkgs/x86-64 - priority = 2 - EOF - - printf '%s\n' 'dev-qt/qtwebengine bindist' 'net-libs/webkit-gtk keyring' > /etc/portage/package.use/ci + mkdir -p /etc/portage/package.accept_keywords echo "$ATOM $KEYWORD" > /etc/portage/package.accept_keywords/ci - - name: setup keyring for binpkgs - run: | - getuto - export GNUPGHOME=/etc/portage/gnupg - wget -qO - https://distfiles.gentoozh.org/gentoo-zh-binhost.asc | gpg --import - gpg --batch --yes --pinentry-mode loopback --passphrase-file "${GNUPGHOME}/pass" --lsign-key 6A0726AF1476A2F382C6AC6638A0234EC16AD42E - gpg --batch --check-trustdb - - - name: setup distfiles permissions - run: | - install -dm775 -o root -g portage /var/cache/distfiles - install -dm775 -o portage -g portage /var/cache/distfiles/git3-src - - name: setup tatt and cpu flags run: | FEATURES="getbinpkg" emerge --oneshot --quiet --autounmask=y --autounmask-write=y --autounmask-continue=y \ @@ -186,7 +86,7 @@ jobs: arch=amd64 usecombis=4 emergeopts="--autounmask=y --autounmask-write=y --autounmask-continue=y" - ignoreprefix="elibc_","video_cards_","linguas_","python_targets_","python_single_target_","kdeenablefinal","test","debug","cpu_flags_" + ignoreprefix=$(scripts/tatt-targets.sh --ignore-prefixes) EOF - name: emerge --onlydeps diff --git a/scripts/emerge-targets.sh b/scripts/emerge-targets.sh new file mode 100755 index 0000000000..ce1132172e --- /dev/null +++ b/scripts/emerge-targets.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash +# usage: emerge-targets.sh PR +set -euo pipefail + +pr=${1:?PR number} +files=$(gh api --paginate "repos/$GITHUB_REPOSITORY/pulls/$pr/files" \ + --jq '.[] | [.filename, .additions, .deletions] | @tsv') +ignore_list=( + .agents .gitignore AGENTS.md AUTHORS COPYING MIGRATION.md + README.md README.en.md README.zh-TW.md README.yue.md + repo.xml skel.ChangeLog skel.metadata.xml .github + eclass licenses metadata profiles scripts +) +packages=() +while IFS=$'\t' read -r file additions deletions; do + [ -n "$file" ] || continue + ignored=false + for prefix in "${ignore_list[@]}"; do + if [[ "$file" == "$prefix"* ]]; then + ignored=true + break + fi + done + "$ignored" && continue + + IFS=/ read -r category package filename <<< "$file" + package="$category/$package" + if (( additions == 0 && deletions > 0 )); then + [ -d "$package" ] || continue + if [[ "$file" == *.ebuild && ! -f "$file" ]]; then + continue + fi + fi + if [[ "$file" == *.ebuild ]]; then + packages+=("=$category/${filename%.ebuild}") + else + packages+=("$package") + fi +done <<< "$files" + +atoms=$( + for atom in "${packages[@]}"; do + if [[ "$atom" != =* ]]; then + versioned=false + for candidate in "${packages[@]}"; do + if [[ "$candidate" == "=$atom-"* ]]; then + versioned=true + break + fi + done + "$versioned" && continue + fi + printf '%s\n' "$atom" + done | sort -u +) + +{ + arm64_packages=() + while IFS= read -r atom; do + [ -n "$atom" ] || continue + printf '%s\t%s\t%s\n' "$atom" amd64-desktop-openrc ubuntu-latest + printf '%s\t%s\t%s\n' "$atom" amd64-desktop-systemd ubuntu-latest + + if [[ "$atom" == =* ]]; then + category=${atom#=} + category=${category%%/*} + filename=${atom##*/} + ebuilds=("$category"/*/"$filename.ebuild") + else + ebuilds=("$atom"/*.ebuild) + fi + for ebuild in "${ebuilds[@]}"; do + [ -f "$ebuild" ] || continue + keywords=$(sed -n 's/^KEYWORDS="\(.*\)"/\1/p' "$ebuild") + for keyword in $keywords; do + if [[ "$keyword" == arm64 || "$keyword" == "~arm64" ]]; then + arm64_packages+=("$atom") + break 2 + fi + done + done + done <<< "$atoms" + for atom in "${arm64_packages[@]}"; do + printf '%s\t%s\t%s\n' "$atom" arm64-desktop-systemd ubuntu-24.04-arm + done +} | jq -R 'split("\t") | {package: .[0], profile: .[1], runner: .[2]}' | jq -sc . diff --git a/scripts/tatt-targets.sh b/scripts/tatt-targets.sh new file mode 100755 index 0000000000..ce1d63799b --- /dev/null +++ b/scripts/tatt-targets.sh @@ -0,0 +1,100 @@ +#!/usr/bin/env bash +# usage: tatt-targets.sh PR BASE LABELED, or tatt-targets.sh --ignore-prefixes +set -euo pipefail + +ignore_prefixes=( + elibc_ video_cards_ linguas_ python_targets_ python_single_target_ + kdeenablefinal test debug cpu_flags_ +) +if [ "${1:-}" = --ignore-prefixes ]; then + printf -v prefixes '"%s",' "${ignore_prefixes[@]}" + printf '%s\n' "${prefixes%,}" + exit 0 +fi + +pr=${1:?PR number} +base=${2:?base commit} +labeled=${3:?tatt label} +git fetch --quiet --depth=1 "https://github.com/$GITHUB_REPOSITORY" "$base" +files=$(gh api --paginate "repos/$GITHUB_REPOSITORY/pulls/$pr/files" \ + --jq '.[] | select(.additions > 0) | [.filename, .previous_filename // ""] | @tsv') + +use_vars() { + awk ' + !collecting && match($0, /^(IUSE|REQUIRED_USE)\+?=["\047]/) { + collecting = 1 + quotes = 0 + quote = substr($0, RLENGTH, 1) + } + collecting { + printf "%s ", $0 + quotes += gsub(quote, quote) + if (quotes % 2 == 0) { + collecting = 0 + print "" + } + } + ' | tr "'" '"' | tr -s ' \t' ' ' +} +flags() { + local values flag prefix ignored + values=$(use_vars | sed -n 's/^IUSE+\?="\([^"]*\)".*/\1/p') + for flag in $values; do + flag=${flag#[-+]} + ignored=false + for prefix in "${ignore_prefixes[@]}"; do + if [[ "$flag" == "$prefix"* ]]; then + ignored=true + break + fi + done + "$ignored" || printf '%s\n' "$flag" + done +} +live='-9{4,}(-r[0-9]+)?\.ebuild$' + +printf '| ebuild | tatt |\n|---|---|\n' >> "$GITHUB_STEP_SUMMARY" +while IFS=$'\t' read -r ebuild previous; do + [[ "$ebuild" =~ ^[A-Za-z0-9+_.-]+/[A-Za-z0-9+_.-]+/[A-Za-z0-9+_.-]+\.ebuild$ && -f "$ebuild" ]] || continue + package=${ebuild%/*} + filename=${ebuild##*/} + atom="=${package%%/*}/${filename%.ebuild}" + keywords=$(sed -n "s/^KEYWORDS=[\"']\(.*\)[\"'].*/\1/p" "$ebuild") + if [[ "$ebuild" =~ $live ]]; then + keyword='**' + elif [[ " $keywords " == *" ~amd64 "* || " $keywords " == *" amd64 "* ]]; then + keyword='~amd64' + else + keyword= + fi + + if [ -z "$keyword" ]; then + reason="skipped: not keyworded ~amd64" + elif [ "$labeled" = true ]; then + reason="tested: tatt label" + elif [ -z "$(flags < "$ebuild")" ]; then + reason="skipped: no USE flag to vary" + elif [ -z "$(git ls-tree "$base" -- "$package/")" ]; then + reason="tested: new package" + else + vars=$(use_vars < "$ebuild") + if [ -n "$previous" ]; then + old=("$previous") + elif git cat-file -e "$base:$ebuild" 2> /dev/null; then + old=("$ebuild") + else + mapfile -t old < <(git ls-tree --name-only "$base" -- "$package/" | grep '\.ebuild$' | grep -vE -- "$live") + fi + reason="tested: IUSE or REQUIRED_USE changed" + for file in "${old[@]}"; do + if [ "$(git show "$base:$file" | use_vars)" = "$vars" ]; then + reason="skipped: add the tatt label to test" + break + fi + done + fi + echo "| \`$ebuild\` | $reason |" >> "$GITHUB_STEP_SUMMARY" + if [[ "$reason" == tested:* ]]; then + printf '%s\t%s\n' "$atom" "$keyword" + fi +done <<< "$files" | jq -Rc 'split("\t") | {atom: .[0], keyword: .[1]}' | jq -sc .