Skip to content

Commit

Permalink
linux: run tests on all files
Browse files Browse the repository at this point in the history
  • Loading branch information
gdams committed Apr 27, 2024
1 parent c6d7b64 commit dbb0aff
Showing 1 changed file with 45 additions and 41 deletions.
86 changes: 45 additions & 41 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,17 @@ jobs:
# Map a step output to a job output
outputs:
matrix: ${{ steps.generate-matrix.outputs.matrix }}
cacerts: ${{ steps.changes.outputs.cacerts }}
cacerts: ${{ steps.cacerts.outputs.cacerts }}
steps:
- name: Checkout
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
fetch-depth: 0

- name: Get changed files
id: changes
- name: Check if cacerts changed
id: cacerts
# Set outputs using the command.
run: |
changed_files=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | xargs)
echo $changed_files
echo "all=$changed_files" >> $GITHUB_OUTPUT
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
Expand All @@ -50,23 +47,13 @@ jobs:
# 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
# Set test versions if version cannot be determined from the path
versions_to_test=(
"8"
"11"
"17"
"20"
)
# If this job is being run on a pull request, only run the matrix for the changed files
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
changed_files="${{ steps.changes.outputs.all }}"
else
changed_files=$(git ls-files linux)
fi
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 ${changed_files} | tr " " "\n")
for file in $(echo ${all_files} | tr " " "\n")
do
# capitalize distro unless it's redhat (set as RedHat)
capitalize () {
Expand All @@ -86,22 +73,21 @@ jobs:
continue
fi
distro=$(capitalize $distro)
if [[ $distro != "Alpine" ]]; then
continue
fi
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)
# test if version is a number and otherwise use versions_to_test
if ! [[ $version =~ ^[0-9]+$ ]]; then
name="temurin"
for version in "${versions_to_test[@]}"
do
matrix+='{"image_type":"'"$type"'","distro":"'"$distro"'","product":{"name":"'"$name"'","version":"'"$version"'"}},'
done
else
matrix+='{"image_type":"'"$type"'","distro":"'"$distro"'","product":{"name":"'"$name"'","version":"'"$version"'"}},'
# 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
Expand All @@ -110,8 +96,8 @@ jobs:
matrix+=']'
# check if matrix is empty
if [[ $matrix == ']' ]]; then
echo "No jobs to run"
matrix='[]'
echo "error: No matrix generated"
exit 1
else
# remove any duplicate entries
matrix=$(echo $matrix | jq -S 'unique')
Expand All @@ -133,10 +119,9 @@ jobs:

- uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
java-version: '17'
java-version: 21
java-package: jdk
architecture: x64
distribution: 'temurin'
distribution: temurin

- name: Build
run: |
Expand All @@ -146,7 +131,7 @@ jobs:
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
if: always() # always run even if the previous step fails
with:
name: test-results
name: test-results-ca-certificates
path: '**/build/test-results/**/TEST-*.xml'

check-packages:
Expand All @@ -168,10 +153,9 @@ jobs:

- uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
java-version: '17'
java-version: 21
java-package: jdk
architecture: x64
distribution: 'temurin'
distribution: temurin

- name: Build # only simulate in Jenkins when select ARCH="all"
run: |
Expand All @@ -187,6 +171,26 @@ jobs:
- 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: github.event_name == 'pull_request' || github.repository_owner != 'adoptium'
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'
Expand All @@ -198,4 +202,4 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- uses: gradle/wrapper-validation-action@216d1ad2b3710bf005dc39237337b9673fd8fcd5 # v3.3.2
- uses: gradle/actions/wrapper-validation@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2

0 comments on commit dbb0aff

Please sign in to comment.