浏览代码

feat(ci): split github workflow files into Rust, DCO and Changelog

Signed-off-by: Zhouqi Jiang <luojia@hust.edu.cn>
Zhouqi Jiang 5 月之前
父节点
当前提交
b47ef25c9b
共有 3 个文件被更改,包括 85 次插入59 次删除
  1. 50 0
      .github/workflows/Changelog.yml
  2. 34 0
      .github/workflows/DCO.yml
  3. 1 59
      .github/workflows/Rust.yml

+ 50 - 0
.github/workflows/Changelog.yml

@@ -0,0 +1,50 @@
+name: Changelog
+
+on:
+  push:
+    branches: [ "main" ]
+  pull_request:
+    branches: [ "main" ]
+  workflow_dispatch:
+
+env:
+  CARGO_UNSTABLE_SPARSE_REGISTRY: true
+  CARGO_TERM_COLOR: always
+
+jobs:
+  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

+ 34 - 0
.github/workflows/DCO.yml

@@ -0,0 +1,34 @@
+name: DCO
+
+on:
+  push:
+    branches: [ "main" ]
+  pull_request:
+    branches: [ "main" ]
+  workflow_dispatch:
+
+env:
+  CARGO_UNSTABLE_SPARSE_REGISTRY: true
+  CARGO_TERM_COLOR: always
+
+jobs:
+  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"

+ 1 - 59
.github/workflows/ci.yml → .github/workflows/Rust.yml

@@ -1,4 +1,4 @@
-name: CI
+name: Rust
 
 on:
   push:
@@ -127,64 +127,6 @@ 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