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 261efdf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
24 changes: 21 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 @@ -27,10 +29,26 @@ jobs:
outputs:
os: ${{ env.OS }}
coverage: ${{ env.COVERAGE }}
major: ${{ steps.major-version.outputs.major }}
php: ${{ env.PHP }}
exclude: ${{ env.EXCLUDE }}

steps:
- name: Pseudo step
if: false
run: echo
- name: Compute major versions
id: major-version
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 261efdf

Please sign in to comment.