From 323160dd385199ce39629583e771b1356bb525bb Mon Sep 17 00:00:00 2001 From: Paul-Henry Kajfasz <42912740+phklive@users.noreply.github.com> Date: Thu, 18 Jul 2024 19:53:47 +0200 Subject: [PATCH] chore: add `changelog.yml` file (#1406) --- .github/workflows/changelog.yml | 23 +++++++++++++++++++++++ .github/workflows/lint.yml | 20 -------------------- CHANGELOG.md | 3 ++- scripts/check-changelog.sh | 21 +++++++++++++++++++++ 4 files changed, 46 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/changelog.yml create mode 100755 scripts/check-changelog.sh diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml new file mode 100644 index 0000000000..5fde0d8d0f --- /dev/null +++ b/.github/workflows/changelog.yml @@ -0,0 +1,23 @@ +# Runs changelog related jobs. +# CI job heavily inspired by: https://github.com/tarides/changelog-check-action + +name: changelog + +on: + pull_request: + types: [opened, reopened, synchronize] + +jobs: + changelog: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@main + with: + fetch-depth: 0 + - name: Check for changes in changelog + env: + BASE_REF: ${{ github.event.pull_request.base.ref }} + NO_CHANGELOG_LABEL: ${{ contains(github.event.pull_request.labels.*.name, 'no changelog') }} + run: ./scripts/check-changelog.sh "${{ inputs.changelog }}" + shell: bash diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 7c5d443946..b06425c54e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -51,23 +51,3 @@ jobs: override: true - name: check rust versions run: ./scripts/check-rust-version.sh - - changelog: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@main - with: - fetch-depth: 0 - - name: Check if CHANGELOG.md is modified - run: | - # Get the list of changed files in the PR - changed_files=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }}...${{ github.sha }}) - - # Check if CHANGELOG.md is in the list of changed files - if echo "$changed_files" | grep -q '^CHANGELOG.md$'; then - echo "CHANGELOG.md has been modified." - else - echo $'::warning file=CHANGELOG.md::CHANGELOG.md has not been modified.\n This warning can be ignored if is has been explicitely decided not to log changes.\n Except in this situation, make sure to add log changes.' - exit 1 - fi diff --git a/CHANGELOG.md b/CHANGELOG.md index 89c5cd9821..a33b178741 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,6 @@ #### Enhancements -- Updated CI and Makefile to standardise it accross Miden repositories (#1342). - Added error codes support for the `mtree_verify` instruction (#1328). - Added support for immediate values for `lt`, `lte`, `gt`, `gte` comparison instructions (#1346). - Change MAST to a table-based representation (#1349) @@ -16,7 +15,9 @@ - Relaxed the parser to allow one branch of an `if.(true|false)` to be empty - Added support for immediate values for `u32and`, `u32or`, `u32xor` and `u32not` bitwise instructions (#1362). - Optimized `std::sys::truncate_stuck` procedure (#1384). +- Updated CI and Makefile to standardise it accross Miden repositories (#1342). - Add serialization/deserialization for `MastForest` (#1370) +- Updated CI to support `CHANGELOG.md` modification checking and `no changelog` label (#1406) #### Changed diff --git a/scripts/check-changelog.sh b/scripts/check-changelog.sh new file mode 100755 index 0000000000..dbf14cdbb0 --- /dev/null +++ b/scripts/check-changelog.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -uo pipefail + +CHANGELOG_FILE="${1:-CHANGELOG.md}" + +if [ "${NO_CHANGELOG_LABEL}" = "true" ]; then + # 'no changelog' set, so finish successfully + echo "\"no changelog\" label has been set" + exit 0 +else + # a changelog check is required + # fail if the diff is empty + if git diff --exit-code "origin/${BASE_REF}" -- "${CHANGELOG_FILE}"; then + >&2 echo "Changes should come with an entry in the \"CHANGELOG.md\" file. This behavior +can be overridden by using the \"no changelog\" label, which is used for changes +that are trivial / explicitely stated not to require a changelog entry." + exit 1 + fi + + echo "The \"CHANGELOG.md\" file has been updated." +fi