From 488b878673b3604ab1e553af5e3342f4be415893 Mon Sep 17 00:00:00 2001 From: George Adams Date: Sat, 27 Apr 2024 14:10:13 +0100 Subject: [PATCH] linux: run tests on all files --- .github/workflows/linux.yml | 77 +++++++++++++++---------------- .github/workflows/linuxTriage.yml | 2 +- 2 files changed, 38 insertions(+), 41 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 255aacce0..fc22db881 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -26,23 +26,12 @@ jobs: # Map a step output to a job output outputs: matrix: ${{ steps.generate-matrix.outputs.matrix }} - cacerts: ${{ steps.changes.outputs.cacerts }} steps: - name: Checkout uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 with: fetch-depth: 0 - - name: Get changed files - id: changes - # 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 - - name: Generate CI matrix id: generate-matrix run: | @@ -50,23 +39,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 () { @@ -92,16 +71,12 @@ jobs: 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 @@ -110,8 +85,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') @@ -121,7 +96,7 @@ jobs: 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' + if: github.event_name == 'pull_request' || github.repository_owner != 'adoptium' runs-on: ubuntu-latest defaults: run: @@ -188,9 +163,31 @@ 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-${{ 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: + # Fetch the uploaded artifacts from the check-packages jobs and merge them into a single artifact. + - name: Download Test Results + uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 + with: + name: test-results-* + + - name: Merge Test Results + run: | + mkdir -p build/test-results + find . -name 'TEST-*.xml' -exec cp {} build/test-results \; + + - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + with: + name: test-results + path: build/test-results + # Ensures we don't accept a Gradle Wrapper update that has been tampered with. validation: name: "Validate Gradle Wrapper" @@ -198,4 +195,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 diff --git a/.github/workflows/linuxTriage.yml b/.github/workflows/linuxTriage.yml index 333a68170..81736b568 100644 --- a/.github/workflows/linuxTriage.yml +++ b/.github/workflows/linuxTriage.yml @@ -1,7 +1,7 @@ name: Publish Test Reports on: workflow_run: - workflows: ['Check Linux Packages'] # runs after Check Linux Packages worflow + workflows: ['Merge Test Results'] # runs after Merge Test Results worflow types: - completed jobs: