Files
chromebrew/.github/workflows/Determine-Compatibility.yml

96 lines
5.7 KiB
YAML

---
name: Determine glibc and architecture package compatibility
on:
workflow_call:
inputs:
changed_packages:
required: true
type: string
branch:
required: false
type: string
outputs:
glibc_227_compat:
description: "The packages compatible with glibc 2.27"
value: ${{ jobs.get-compatibility.outputs.GLIBC_227_COMPATIBLE_PACKAGES }}
glibc_232_compat:
description: "The packages compatible with glibc 2.32"
value: ${{ jobs.get-compatibility.outputs.GLIBC_232_COMPATIBLE_PACKAGES }}
glibc_237_compat:
description: "The packages compatible with glibc 2.37"
value: ${{ jobs.get-compatibility.outputs.GLIBC_237_COMPATIBLE_PACKAGES }}
i686_packages:
description: "The packages compatible with i686"
value: ${{ jobs.get-compatibility.outputs.i686_PACKAGES }}
x86_64_packages:
description: "The packages compatible with x86_64"
value: ${{ jobs.get-compatibility.outputs.x86_64_PACKAGES }}
armv7l_packages:
description: "The packages compatible with armv7l"
value: ${{ jobs.get-compatibility.outputs.armv7l_PACKAGES }}
jobs:
get-compatibility:
runs-on: ubuntu-latest
outputs:
GLIBC_227_COMPATIBLE_PACKAGES: ${{ steps.get-compatibility.outputs.GLIBC_227_COMPATIBLE_PACKAGES }}
GLIBC_232_COMPATIBLE_PACKAGES: ${{ steps.get-compatibility.outputs.GLIBC_232_COMPATIBLE_PACKAGES }}
GLIBC_237_COMPATIBLE_PACKAGES: ${{ steps.get-compatibility.outputs.GLIBC_237_COMPATIBLE_PACKAGES }}
i686_PACKAGES: ${{ steps.get-compatibility.outputs.i686_PACKAGES }}
x86_64_PACKAGES: ${{ steps.get-compatibility.outputs.x86_64_PACKAGES }}
armv7l_PACKAGES: ${{ steps.get-compatibility.outputs.armv7l_PACKAGES }}
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.branch || github.ref }}
- name: Determine glibc and architecture package compatibility
id: get-compatibility
env:
CHANGED_PACKAGES: ${{ inputs.changed_packages }}
run: |
# If a package doesnt have a min_glibc value, or if its below 2.27, add it to GLIBC_227_COMPATIBLE_PACKAGES.
GLIBC_227_COMPATIBLE_PACKAGES="$(for i in ${CHANGED_PACKAGES} ; do if grep -q min_glibc packages/"${i}".rb; then grep min_glibc packages/"${i}".rb | tr -d \' | awk '{exit $2 <= 2.27}' || echo "${i}" ; else echo "${i}" ; fi ; done | xargs -r)"
if [[ -n ${GLIBC_227_COMPATIBLE_PACKAGES} ]]; then
echo "GLIBC_227_COMPATIBLE_PACKAGES=${GLIBC_227_COMPATIBLE_PACKAGES}" >> "$GITHUB_ENV"
echo "PR #${{ github.event.pull_request.number }} has these possibly Glibc 2.27 compatible packages: ${GLIBC_227_COMPATIBLE_PACKAGES}"
fi
# If a package has a min_glibc value below 2.32, add it to GLIBC_232_COMPATIBLE_PACKAGES.
GLIBC_232_COMPATIBLE_PACKAGES="$(for i in ${CHANGED_PACKAGES} ; do grep min_glibc packages/"${i}".rb | tr -d \' | awk '{exit $2 <= 2.32}' || echo "${i}" ; done | xargs)"
export GLIBC_232_COMPATIBLE_PACKAGES
if [[ -n ${GLIBC_232_COMPATIBLE_PACKAGES} ]]; then
echo "GLIBC_232_COMPATIBLE_PACKAGES=${GLIBC_232_COMPATIBLE_PACKAGES}" >> "$GITHUB_OUTPUT"
echo "Branch ${{ github.ref_name }} has these possibly Glibc 2.32 compatible packages: ${GLIBC_232_COMPATIBLE_PACKAGES}"
fi
# If a package has a min_glibc value below 2.37, add it to GLIBC_237_COMPATIBLE_PACKAGES.
GLIBC_237_COMPATIBLE_PACKAGES="$(for i in ${CHANGED_PACKAGES} ; do grep min_glibc packages/"${i}".rb | tr -d \' | awk '{exit $2 <= 2.37}' || echo "${i}" ; done | xargs)"
export GLIBC_237_COMPATIBLE_PACKAGES
if [[ -n ${GLIBC_237_COMPATIBLE_PACKAGES} ]]; then
echo "GLIBC_237_COMPATIBLE_PACKAGES=${GLIBC_237_COMPATIBLE_PACKAGES}" >> "$GITHUB_OUTPUT"
echo "Branch ${{ github.ref_name }} has these possibly Glibc 2.37 compatible packages: ${GLIBC_237_COMPATIBLE_PACKAGES}"
fi
# If a package has a compatibility of 'all' or one that includes 'x86_64', add it to x86_64_PACKAGES.
x86_64_PACKAGES="$(for i in ${CHANGED_PACKAGES}; do grep -q "[[:space:]]compatibility.*all\|[[:space:]]compatibility.*x86_64" packages/"${i}".rb && echo "${i}"; done | xargs)"
export x86_64_PACKAGES
if [[ -n ${x86_64_PACKAGES} ]]; then
echo "x86_64_PACKAGES=${x86_64_PACKAGES}" >> "$GITHUB_OUTPUT"
echo "Branch ${{ github.ref_name }} has these x86_64 compatible packages: ${x86_64_PACKAGES}"
fi
# If a package has a compatibility of 'all' or one that includes 'armv7l', add it to armv7l_PACKAGES.
armv7l_PACKAGES="$(for i in ${CHANGED_PACKAGES}; do grep -q "[[:space:]]compatibility.*all\|[[:space:]]compatibility.*armv7l" packages/"${i}".rb && echo "${i}"; done | xargs)"
export armv7l_PACKAGES
if [[ -n ${armv7l_PACKAGES} ]]; then
echo "armv7l_PACKAGES=${armv7l_PACKAGES}" >> "$GITHUB_OUTPUT"
echo "Branch ${{ github.ref_name }} has these armv7l compatible packages: ${armv7l_PACKAGES}"
fi
# If a package has a compatibility of 'all' or one that includes 'i686', add it to i686_PACKAGES.
i686_PACKAGES="$(for i in ${CHANGED_PACKAGES}; do grep -q "[[:space:]]compatibility.*all\|[[:space:]]compatibility.*i686" packages/"${i}".rb && echo "${i}"; done | xargs)"
export i686_PACKAGES
if [[ -n ${i686_PACKAGES} ]]; then
echo "i686_PACKAGES=${i686_PACKAGES}" >> "$GITHUB_OUTPUT"
echo "Branch ${{ github.ref_name }} has these i686 compatible packages: ${i686_PACKAGES}"
fi