Skip to content

fix failing Alpine Linux builds #1580

fix failing Alpine Linux builds

fix failing Alpine Linux builds #1580

Workflow file for this run

name: Check Linux Packages
on:
workflow_dispatch:
push:
paths:
- 'linux/**'
- '.github/workflows/linux.yml'
pull_request:
branches: [ master ]
paths:
- 'linux/**'
- '.github/workflows/linux.yml'
# Cancel existing runs if user makes another push.
concurrency:
group: "${{ github.ref }}"
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
jobs:
generate-matrix:
if: github.event_name == 'pull_request' || github.repository_owner != 'adoptium'
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
matrix: ${{ steps.generate-matrix.outputs.matrix }}
cacerts: ${{ steps.cacerts.outputs.cacerts }}
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
- name: Check if cacerts changed
id: cacerts
# Set outputs using the command.
run: |
cacerts=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep ca-certificates | xargs)
echo "cacerts=$cacerts" >> $GITHUB_OUTPUT
- name: Generate CI matrix
id: generate-matrix
run: |
# Generate the matrix based on the changed files
# Loop through the changed files and generate a matrix of jobs to run
# The matrix is a JSON string that is used in the next step
all_files=$(git ls-files linux)
# Add versions here to be skipped from CI once they've reached EOL
skipped_versions='["19","20"]'
matrix='['
for file in $(echo ${all_files} | tr " " "\n")
do
# capitalize distro unless it's redhat (set as RedHat)
capitalize () {
if [[ $1 == "redhat" ]]; then
echo "RedHat"
else
echo $1 | awk '{print toupper(substr($0,0,1))tolower(substr($0,2))}'
fi
}
case $file in
linux/jdk/*|linux/jre/*)
# extract values from the path
type=$(echo $file | cut -d'/' -f 2 | tr '[a-z]' '[A-Z]')
distro=$(echo $file | cut -d'/' -f 3)
# if distro = build.gradle skip it
if [[ $distro == "build.gradle" ]]; then
continue
fi
distro=$(capitalize $distro)
name=$(echo $file | cut -d'/' -f 7)
# if name != temurin and !microsoft skip it
if [[ $name != "temurin" && $name != "microsoft" ]]; then
continue
fi
version=$(echo $file | cut -d'/' -f 8)
# if version in skipped_versions skip
if [[ $skipped_versions == *"$version"* ]]; then
continue
fi
matrix+='{"image_type":"'"$type"'","distro":"'"$distro"'","product":{"name":"'"$name"'","version":"'"$version"'"}},'
;;
esac
done
# remove trailing comma
matrix=${matrix%?}
matrix+=']'
# check if matrix is empty
if [[ $matrix == ']' ]]; then
echo "error: No matrix generated"
exit 1
else
# remove any duplicate entries
matrix=$(echo $matrix | jq -S 'unique')
fi
echo "matrix<<EOF"$'\n'"$matrix"$'\n'EOF >> $GITHUB_OUTPUT
check-ca-certificates:
name: "Check ca-certificates"
needs: generate-matrix
if: (github.event_name == 'pull_request' && needs.generate-matrix.outputs.cacerts) || github.repository_owner != 'adoptium'
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./linux
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
java-version: 17
java-package: jdk
distribution: temurin
- name: Build
run: |
export _JAVA_OPTIONS="-Xmx4G"
./gradlew --parallel :ca-certificates:check --stacktrace
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
if: always() # always run even if the previous step fails
with:
name: test-results-ca-certificates
path: '**/build/test-results/**/TEST-*.xml'
check-packages:
name: "Check ${{ matrix.image_type }} on ${{ matrix.product.name }} ${{ matrix.product.version }} ${{ matrix.distro }}"
if: github.event_name == 'pull_request' || github.repository_owner != 'adoptium'
needs: generate-matrix
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./linux
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
java-version: 17
java-package: jdk
distribution: temurin
- name: Build # only simulate in Jenkins when select ARCH="all"
run: |
export _JAVA_OPTIONS="-Xmx4G"
export DOCKER_BUILDKIT=1
./gradlew --parallel package$( echo "${{ matrix.image_type }}" | tr [DKRE] [dkre] )${{ matrix.distro }} check${{ matrix.image_type }}${{ matrix.distro }} -PPRODUCT=${{ matrix.product.name }} -PPRODUCT_VERSION=${{ matrix.product.version }} --stacktrace
- name: Relocate test results
if: always() # always run even if the previous step fails
run: |
mkdir ${{ matrix.product.version }}
mv $( echo "${{ matrix.image_type }}" | tr [:upper:] [:lower:] ) ${{ matrix.product.version }}
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
if: always() # always run even if the previous step fails
with:
name: test-results-${{ matrix.product.name }}-${{ matrix.product.version }}-${{ matrix.distro }}-${{ matrix.image_type }}
path: '**/build/test-results/**/TEST-*.xml'
merge-results:
name: Merge Test Results
needs: check-packages
if: always()
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
pattern: test-results-*
merge-multiple: true
- uses: geekyeggo/delete-artifact@24928e75e6e6590170563b8ddae9fac674508aa1 # v5.0.0
with:
name: test-results-*
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: test-results
path: '**/build/test-results/**/TEST-*.xml'
# Ensures we don't accept a Gradle Wrapper update that has been tampered with.
validation:
name: "Validate Gradle Wrapper"
if: github.event_name == 'pull_request' || github.repository_owner != 'adoptium'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: gradle/actions/wrapper-validation@d9336dac04dea2507a617466bc058a3def92b18b # v3.4.0