Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance PR messaging for checks #259

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 56 additions & 11 deletions .github/workflows/check-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,70 @@ jobs:
check-version:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: New version
id: new_version
run: |
echo version=$(./gradlew properties --no-daemon --console=plain -q | grep "^version:" | awk '{printf $2}') >> $GITHUB_OUTPUT
- uses: reviewdog/action-setup@3f401fe1d58fe77e10d665ab713057375e39b887 # v1.3.0
with:
reviewdog_version: v0.17.2
- uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92
id: generate-token
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}


- name: Checkout repository
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
ref: master
- name: Master version
id: master_version
run: |
echo version=$(./gradlew properties --no-daemon --console=plain -q | grep "^version:" | awk '{printf $2}') >> $GITHUB_OUTPUT
#echo version=$(./gradlew properties --no-daemon --console=plain -q | grep "^version:" | awk '{printf $2}') >> $GITHUB_OUTPUT
echo version=$(grep -o 'version = ".*"' build.gradle.kts | grep -o '[0-9\.]*') >> $GITHUB_OUTPUT
- name: Checkout repository
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: New version
id: new_version
run: |
#echo version=$(./gradlew properties --no-daemon --console=plain -q | grep "^version:" | awk '{printf $2}') >> $GITHUB_OUTPUT
echo version=$(grep -o 'version = ".*"' build.gradle.kts | grep -o '[0-9\.]*') >> $GITHUB_OUTPUT

- name: test version
id: version_test
run: |
compare_versions() {
IFS='.' read -r -a new_arr <<< $1
IFS='.' read -r -a master_arr <<< $2
local i
for ((i = 0; i < 3; i++)); do
if [ ${new_arr[$i]} -gt ${master_arr[$i]} ]; then
return 0
elif [ ${new_arr[$i]} -lt ${master_arr[$i]} ]; then
return 1
fi
done
return 2
}
compare_versions "${{ steps.new_version.outputs.version }}" "${{ steps.master_version.outputs.version }}" && echo status="ok" >> $GITHUB_OUTPUT || echo status="notok" >> $GITHUB_OUTPUT

- name: version is correct
if: ${{ steps.new_version.outputs.version != steps.master_version.outputs.version }}
if: ${{ steps.version_test.outputs.status }} == "ok"
run: echo "New version ${{ steps.new_version.outputs.version }} is OK"
- name: version is inccorrect
if: ${{ steps.new_version.outputs.version == steps.master_version.outputs.version }}

- name: version is incorrect, creating suggestion
if: ${{ steps.version_test.outputs.status }} == "notok"
run: |
IFS='.' read -r -a array <<< "${{ steps.new_version.outputs.version }}"
new_version="${array[0]}.${array[1]}.$((array[2]+1))"
#sed -i "s/version = \".*\"/version = \"$new_version\"/" build.gradle.kts
sed -i "s/proba/proba2/g" .github/workflows/check-version.yml

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[diff] reported by reviewdog 🐶

Suggested change
sed -i "s/proba/proba2/g" .github/workflows/check-version.yml
sed -i "s/proba2/proba22/g" .github/workflows/check-version.yml

- name: version is incorrect, posting suggestion
if: ${{ steps.version_test.outputs.status }} == "notok"
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git diff | reviewdog -f=diff -f.diff.strip=1 -level=warning -filter-mode=nofilter -reporter=github-pr-review -tee -log-level=debug
- name: version is incorrect, reporting
if: ${{ steps.version_test.outputs.status }} == "notok"
run: |
echo "New version ${{ steps.new_version.outputs.version }} is NOT OK"
exit 1
exit 1
3 changes: 2 additions & 1 deletion .github/workflows/version-bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ jobs:

- name: Determine new version
run: |
version=$(./gradlew properties --no-daemon --console=plain -q | grep "^version:" | awk '{printf $2}')
#version=$(./gradlew properties --no-daemon --console=plain -q | grep "^version:" | awk '{printf $2}')
version=$(grep -o 'version = ".*"' build.gradle.kts | grep -o '[0-9\.]*')
IFS='.' read -r -a array <<< "$version"
echo "Previous version: $version"
case "${{ github.event.inputs.version_type }}" in
Expand Down
Loading