From 2de90e615bb7251460e119378bc4808db6ab7972 Mon Sep 17 00:00:00 2001 From: Nicole Cordes Date: Sun, 4 Aug 2024 22:58:55 +0200 Subject: [PATCH] [FEATURE] Add major version processing --- .github/workflows/compute.yml | 22 +++++++++++++++++++--- .github/workflows/test.yml | 9 ++++++--- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/.github/workflows/compute.yml b/.github/workflows/compute.yml index 566f366..79d2121 100644 --- a/.github/workflows/compute.yml +++ b/.github/workflows/compute.yml @@ -7,6 +7,8 @@ on: value: ${{ jobs.compute.outputs.os }} coverage: value: ${{ jobs.compute.outputs.coverage }} + major: + value: ${{ jobs.compute.outputs.major }} php: value: ${{ jobs.compute.outputs.php }} exclude: @@ -31,6 +33,20 @@ jobs: exclude: ${{ env.EXCLUDE }} steps: - - name: Pseudo step - if: false - run: echo + - name: Compute major versions + run: | + echo -e "COVERAGE\n" + echo $COVERAGE + echo -e "\n\nSplit by comma\n" + echo $COVERAGE | tr "," "\n" + echo -e "\n\nParse numbers\n" + echo $COVERAGE | tr "," "\n" | tr -cd "\n0-9" + echo -e "\n\nCut last 2 characters\n" + echo $COVERAGE | tr "," "\n" | tr -cd "\n0-9" | sed "s/.\{2\}$//" + echo -e "\n\nSort by version\n" + echo $COVERAGE | tr "," "\n" | tr -cd "\n0-9" | sed "s/.\{2\}$//" | sort -V + echo -e "\n\nUnique values only\n" + echo $COVERAGE | tr "," "\n" | tr -cd "\n0-9" | sed "s/.\{2\}$//" | sort -V | uniq + echo -e "\n\nCovert to JSON\n" + echo $COVERAGE | tr "," "\n" | tr -cd "\n0-9" | sed "s/.\{2\}$//" | sort -V | uniq | jq --compact-output --raw-input --slurp 'split("\n") | map(select(. != ""))' + echo "major=$(echo $COVERAGE | tr "," "\n" | tr -cd "\n0-9" | sed "s/.\{2\}$//" | sort -V | uniq | jq --compact-output --raw-input --slurp 'split("\n") | map(select(. != ""))')" >> $GITHUB_OUTPUT diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ce094c2..959dfb8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,14 +33,17 @@ jobs: id: version-cache env: COVERAGE: ${{ matrix.coverage }} - run: echo "version=$(echo $COVERAGE | tr -d -c 0-9)" >> $GITHUB_OUTPUT + run: | + echo "version=$(echo $COVERAGE | tr -d -c 0-9)" >> $GITHUB_OUTPUT + echo "major=$(echo $COVERAGE | tr -d -c 0-9 | sed 's/.\{2\}$//')" >> $GITHUB_OUTPUT - uses: actions/cache/restore@v4 id: restore-composer-cache with: path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-${{ matrix.php }}-${{ matrix.coverage }} + key: ${{ runner.os }}-${{ matrix.php }}-${{ steps.version-cache.outputs.major }}-${{ matrix.coverage }} restore-keys: | + ${{ runner.os }}-${{ matrix.php }}-${{ steps.version-cache.outputs.major }}- ${{ runner.os }}-${{ matrix.php }}- ${{ runner.os }}- @@ -79,6 +82,6 @@ jobs: - name: Archive PHPUnit logs uses: actions/upload-artifact@v4 with: - name: phpunit-logs-${{ runner.os }}-${{ matrix.php }}-${{ matrix.coverage }} + name: phpunit-logs-${{ runner.os }}-${{ matrix.php }}-${{ steps.version-cache.outputs.major }}-${{ matrix.coverage }} path: .Log/* retention-days: 1