Skip to content

fix: better error message when the cluster is unknown or missing #154

fix: better error message when the cluster is unknown or missing

fix: better error message when the cluster is unknown or missing #154

Workflow file for this run

name: Semver checks
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
RUSTFLAGS: "-D warnings"
RUSTDOCFLAGS: '--deny warnings'
MINIMUM_SUPPORTED_RUST_VERSION: 1.80.1
permissions:
packages: write
contents: write
on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review]
branches:
- main
paths-ignore:
- CHANGELOG.md
workflow_dispatch:
workflow_run:
workflows: ['Prepare a release']
types:
- completed
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check-branches:
runs-on: ubuntu-latest
steps:
- name: you can't run this action on 'main' branch
run: |
if [[ "${{ github.ref_name }}" = "main" ]]; then
exit 1
fi
setup:
needs: check-branches
outputs:
currentVersion: ${{ steps.current.outputs.version }}
nextVersion: ${{ steps.next.outputs.version }}
nextStep: ${{ steps.nextStep.outputs.nextStep }}
permissions:
pull-requests: write
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Delete old cargo-semver-checks comments
continue-on-error: true
run: |
gh pr view "${{ github.event.number }}" --json comments --jq '.comments[] | select(.author.login == "github-actions") | .url' | grep -E 'issuecomment-(.+)' | cut -d '-' -f2 > comments.txt
xargs -I {} gh api -X DELETE "/repos/MAIF/yozefu/issues/comments/{}" < comments.txt
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: List the releases on GitHub
id: current
run: echo "version=$(git tag --sort=-creatordate | head -n 1)" >> "$GITHUB_OUTPUT"
- name: Get next version
id: next
run: echo "version=v$(cargo pkgid --manifest-path crates/bin/Cargo.toml | cut -d '@' -f2)" >> "$GITHUB_OUTPUT"
- name: Compute next step
id: nextStep
if: ${{ steps.current.outputs.version == steps.next.outputs.version }}
run: |
if [[ "${{ steps.current.outputs.version }}" == "${{ steps.next.outputs.version }}" ]]; then
echo "nextStep=compute" >> "$GITHUB_OUTPUT"
else
echo "nextStep=nope" >> "$GITHUB_OUTPUT"
fi
cargo-semver-checks:
needs: setup
permissions:
pull-requests: write
contents: write
runs-on: ubuntu-latest
if: ${{ needs.setup.outputs.nextStep != 'compute' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Install cargo-semver-checks
run: cargo install cargo-semver-checks
- name: Show release type
id: semver
run: |
chmod u+x ./.github/workflows/semver.sh
echo "release=$(./.github/workflows/semver.sh diff ${{ needs.setup.outputs.currentVersion }} ${{ needs.setup.outputs.nextVersion }})" >> "$GITHUB_OUTPUT"
- name: Prepare report.md
if: ${{ needs.setup.outputs.nextVersion == '' }}
run: |
{
printf "> [!WARNING]"
printf "> According to \`cargo-semver-checks\`, the next release version doesn\'t respect semantic versioning."
printf '```bash'
} > ./report.md
- name: Run cargo semver-checks
if: ${{ needs.setup.outputs.nextVersion != '' && steps.semver.outputs.release != '' }}
id: check
run: |
printf "\`cargo-semver-checks\` has detected some issues: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\n" > report.md
printf '```bash' >> report.md
cargo semver-checks --color never --package yozefu-lib --package yozefu-app --package yozefu-wasm-types --package yozefu-command --baseline-rev "${{ needs.setup.outputs.currentVersion }}" --release-type "${{ steps.semver.outputs.release }}" 2>&1 | tee -a report.md
if [[ "${PIPESTATUS[0]}" != "0" ]]; then
printf '```' >> report.md
exit 1
fi
continue-on-error: true
- name: Publish semver-checks report
if: ${{ steps.check.outcome != 'success' }}
run: |
gh pr comment ${{ github.event.number }} --body-file ./report.md
exit 1
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish semver-checks report
if: ${{ steps.check.outcome != 'success' }}
run: |
gh pr comment ${{ github.event.number }} --body-file ./report.md
exit 1
compute-next-version:
needs: setup
permissions:
pull-requests: write
contents: write
if: ${{ needs.setup.outputs.nextStep == 'compute' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Install cargo-semver-checks
run: cargo install cargo-semver-checks
id: bump
continue-on-error: true
- run: |
for bump in patch minor; do
if cargo semver-checks --color never --package yozefu-lib --package yozefu-app --package yozefu-wasm-types --package yozefu-command --baseline-rev "${{ needs.setup.outputs.currentVersion }}" --release-type "$bump"; then
echo "bump=$bump" >> "$GITHUB_OUTPUT"
exit 0
fi
done
echo "bump=major" >> "$GITHUB_OUTPUT"
- name: Comment the pull request
run: |
echo "::info title=Next version:: Last public version is '${{ needs.setup.outputs.currentVersion }}' but version of this branch is '${{ needs.setup.outputs.nextVersion }}'."
{
echo "This pull request is not ready because the crate version is equals to the latest git tag version \`"
echo "${{ needs.setup.outputs.currentVersion }}"
echo "\`. I think you forgot to bump the version. More details at https://github.com/MAIF/yozefu/blob/main/docs/release/README.md"
echo "\nAccording to \`cargo-semver-checks`, you should increase the **"
echo "${{ steps.bump.outputs.bump }}** number."
} >> report.md
gh pr comment ${{ github.event.number }} --body-file ./report.md
env:
GH_TOKEN: ${{ github.token }}