Bläddra i källkod

feat(ci): add 2 new features in `workflows`.

- Add `check-changlog` and `check-commit-signatures` in `workflows`.

Signed-off-by: Yu Chongbing <bd8ejk@foxmail.com>
Yu Chongbing 5 månader sedan
förälder
incheckning
26096f3d34
2 ändrade filer med 59 tillägg och 0 borttagningar
  1. 58 0
      .github/workflows/ci.yml
  2. 1 0
      CHANGELOG.md

+ 58 - 0
.github/workflows/ci.yml

@@ -127,6 +127,64 @@ jobs:
         run: |
           cargo build --target ${{ matrix.TARGET }} --verbose -p sbi-testing --features "log"
 
+  check-changelog:
+    name: Check if `CHANGELOG.md` is updated
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v4
+      - name: Get latest updated files
+        run: |
+          updated_files=$(git show --name-only --pretty=format: HEAD)
+      - name: Check if changlog is updated
+        run: |
+          if git show --name-only --pretty=format: HEAD | grep -q "CHANGELOG.md"; then
+            echo "Main CHANGELOG.md changed in the latest commit."
+          else
+            echo "Main CHANGELOG.md is not changed in the latest commit."
+            exit 1
+          fi
+          for file in $updated_files; do
+            first_path=$(dirname "$file")
+            if [[ "$first_path" == *"sbi-rt"* ]]; then
+              file_path = "./sbi-rt"
+            elif [[ "$first_path" == *"sbi-spec"* ]]; then
+              file_path = "./sbi-spec"
+            elif [[ "$first_path" == *"sbi-testing"* ]]; then
+              file_path = "./sbi-testing"
+            else
+              file_path = "./"
+            fi
+            changelog_path="$file_path/CHANGELOG.md"
+            # Check if changelog is updated
+            if git diff --name-only "$file_path" | grep -q "CHANGELOG.md"; then
+              echo "File $changelog_path changed in the latest commit."
+            else
+              echo "File $changelog_path is not changed in the latest commit."
+              exit 1
+            fi
+          done
+
+  check-commit-signatures:
+    name: Check commit signatures
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v4
+      - name: Check if commit is signed
+        run: |
+          COMMIT=$(git log -1)
+          if echo "$COMMIT" | grep -q "Author: "; then
+              echo "Commit is signed."
+          else
+              echo "Commit is NOT signed."
+              exit 1
+          fi
+      - name: Print author's information
+        run: |
+          AUTHOR_NAME=$(git log -1 --format='%an')
+          AUTHOR_EMAIL=$(git log -1 --format='%ae')
+          echo "Author's name: $AUTHOR_NAME"
+          echo "Author's email: $AUTHOR_EMAIL"
+
 # sbi-testing:
 #     name: Run rust-clippy analyzing
 #     runs-on: ubuntu-latest

+ 1 - 0
CHANGELOG.md

@@ -8,6 +8,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 ## Unreleased
 
 ### Added
+- ci: add `check-changlog` and `check-commit-signatures` in `workflows`.
 - pmu: add missing `snapshot_set_shmem` function and testcases in `Pmu` trait.
 
 ### Added