Skip to content

Commit

Permalink
[FEATURE] Add major version processing
Browse files Browse the repository at this point in the history
  • Loading branch information
IchHabRecht committed Aug 4, 2024
1 parent 6ee2a5e commit 2de90e6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
22 changes: 19 additions & 3 deletions .github/workflows/compute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
9 changes: 6 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}-
Expand Down Expand Up @@ -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

0 comments on commit 2de90e6

Please sign in to comment.