From f21f2b5d2a99458ac67c1555c9f1025071ddbc43 Mon Sep 17 00:00:00 2001 From: Paul-Henry Kajfasz Date: Thu, 18 Jul 2024 12:17:19 +0200 Subject: [PATCH 1/8] Added changelog.yml --- .github/workflows/changelog.yml | 27 +++++++++++++++++++++++++++ .github/workflows/lint.yml | 20 -------------------- 2 files changed, 27 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/changelog.yml diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml new file mode 100644 index 0000000000..86ee55cc7b --- /dev/null +++ b/.github/workflows/changelog.yml @@ -0,0 +1,27 @@ +# Runs changelog related jobs. + +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 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/.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 From 42782d6b563cf8103d8564e474bd654372adf3df Mon Sep 17 00:00:00 2001 From: Paul-Henry Kajfasz Date: Thu, 18 Jul 2024 12:37:39 +0200 Subject: [PATCH 2/8] Inspired from changelog-check-action --- .github/workflows/changelog.yml | 19 ++++++++----------- scripts/check-changelog.sh | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 11 deletions(-) create mode 100755 scripts/check-changelog.sh diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index 86ee55cc7b..ef463ef166 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -7,21 +7,18 @@ on: types: [opened, reopened, synchronize] jobs: + # CI job heavily inspired by: https://github.com/tarides/changelog-check-action changelog: runs-on: ubuntu-latest + using: "composite" 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 + - 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/scripts/check-changelog.sh b/scripts/check-changelog.sh new file mode 100755 index 0000000000..dfcf90ac14 --- /dev/null +++ b/scripts/check-changelog.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -uo pipefail + +CHANGELOG_FILE="${1:-CHANGES.md}" + +if [ "${NO_CHANGELOG_LABEL}" = "true" ]; then + # 'no changelog' set, so finish successfully + echo "::info 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 "::warning 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 trivial / explicitely decided not to need a changelog entry." + exit 1 + fi +fi From d6de3b6eab1b3ce8a0f385317d0f510636a72aa1 Mon Sep 17 00:00:00 2001 From: Paul-Henry Kajfasz Date: Thu, 18 Jul 2024 12:39:26 +0200 Subject: [PATCH 3/8] Fix comment --- .github/workflows/changelog.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index ef463ef166..5fde0d8d0f 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -1,4 +1,5 @@ # Runs changelog related jobs. +# CI job heavily inspired by: https://github.com/tarides/changelog-check-action name: changelog @@ -7,10 +8,8 @@ on: types: [opened, reopened, synchronize] jobs: - # CI job heavily inspired by: https://github.com/tarides/changelog-check-action changelog: runs-on: ubuntu-latest - using: "composite" steps: - name: Checkout code uses: actions/checkout@main From 8b458746e8c9a2060c94a5f5c9789be6301e3292 Mon Sep 17 00:00:00 2001 From: Paul-Henry Kajfasz Date: Thu, 18 Jul 2024 12:41:11 +0200 Subject: [PATCH 4/8] Improve messages --- scripts/check-changelog.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/check-changelog.sh b/scripts/check-changelog.sh index dfcf90ac14..0d08e46df8 100755 --- a/scripts/check-changelog.sh +++ b/scripts/check-changelog.sh @@ -5,15 +5,15 @@ CHANGELOG_FILE="${1:-CHANGES.md}" if [ "${NO_CHANGELOG_LABEL}" = "true" ]; then # 'no changelog' set, so finish successfully - echo "::info no changelog label has been set" + echo $'::info 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 "::warning Changes should come with an entry in the CHANGELOG.md file. This behavior + >&2 echo $'::warning 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 trivial / explicitely decided not to need a changelog entry." +that trivial / explicitely decided not to need a changelog entry.' exit 1 fi fi From a5ded6e7559f499bf675a58bf7d6202977eb1d75 Mon Sep 17 00:00:00 2001 From: Paul-Henry Kajfasz Date: Thu, 18 Jul 2024 12:45:29 +0200 Subject: [PATCH 5/8] Fix messaging --- scripts/check-changelog.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/check-changelog.sh b/scripts/check-changelog.sh index 0d08e46df8..6637d5bbe9 100755 --- a/scripts/check-changelog.sh +++ b/scripts/check-changelog.sh @@ -5,15 +5,15 @@ CHANGELOG_FILE="${1:-CHANGES.md}" if [ "${NO_CHANGELOG_LABEL}" = "true" ]; then # 'no changelog' set, so finish successfully - echo $'::info no changelog label has been set' + 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 $'::warning Changes should come with an entry in the CHANGELOG.md file. This behavior + >&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 trivial / explicitely decided not to need a changelog entry.' +that are trivial / explicitely stated not to require a changelog entry." exit 1 fi fi From 84b5348896b7eb86ba943ba9808e3fe103b9fba5 Mon Sep 17 00:00:00 2001 From: Paul-Henry Kajfasz Date: Thu, 18 Jul 2024 12:49:42 +0200 Subject: [PATCH 6/8] Fix support for no changelog label --- scripts/check-changelog.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check-changelog.sh b/scripts/check-changelog.sh index 6637d5bbe9..1e1e30ba7d 100755 --- a/scripts/check-changelog.sh +++ b/scripts/check-changelog.sh @@ -1,7 +1,7 @@ #!/bin/bash set -uo pipefail -CHANGELOG_FILE="${1:-CHANGES.md}" +CHANGELOG_FILE="${1:-CHANGELOG.md}" if [ "${NO_CHANGELOG_LABEL}" = "true" ]; then # 'no changelog' set, so finish successfully From 9ab2316aa3d8e45f3ffbc9e0c156656a54b5bf91 Mon Sep 17 00:00:00 2001 From: Paul-Henry Kajfasz Date: Thu, 18 Jul 2024 12:59:06 +0200 Subject: [PATCH 7/8] Removed no changelog label and made a modification to the changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 From 269caf9fd559b8774ac3effab13c7da057c1a024 Mon Sep 17 00:00:00 2001 From: Paul-Henry Kajfasz Date: Thu, 18 Jul 2024 13:01:41 +0200 Subject: [PATCH 8/8] Add success message --- scripts/check-changelog.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/check-changelog.sh b/scripts/check-changelog.sh index 1e1e30ba7d..dbf14cdbb0 100755 --- a/scripts/check-changelog.sh +++ b/scripts/check-changelog.sh @@ -11,9 +11,11 @@ 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 + >&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