Skip to content

Test

Test #1116

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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
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@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
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@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.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@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
pattern: test-results-*
merge-multiple: true
- uses: geekyeggo/delete-artifact@f275313e70c08f6120db482d7a6b98377786765b # v5.1.0
with:
name: test-results-*
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: gradle/actions/wrapper-validation@d156388eb19639ec20ade50009f3d199ce1e2808 # v4.1.0