Browse Source

workflows: build all packages, test rustsbi and sbi-spec

Signed-off-by: Zhouqi Jiang <[email protected]>
Zhouqi Jiang 1 year ago
parent
commit
da9c88cf29
2 changed files with 161 additions and 203 deletions
  1. 161 0
      .github/workflows/ci.yml
  2. 0 203
      .github/workflows/rust.yml

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

@@ -0,0 +1,161 @@
+name: CI
+
+on:
+  push:
+    branches: [ "main" ]
+  pull_request:
+    branches: [ "main" ]
+  workflow_dispatch:
+
+env:
+  CARGO_UNSTABLE_SPARSE_REGISTRY: true
+  CARGO_TERM_COLOR: always
+
+jobs:
+  fmt:
+    name: Rustfmt all packages
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v4
+      - uses: actions-rust-lang/setup-rust-toolchain@v1
+        with:
+          components: rustfmt
+      - name: Cache Dependencies
+        uses: Swatinem/rust-cache@v2
+      - name: Rustfmt Check
+        uses: actions-rust-lang/rustfmt@v1
+
+  build-rustsbi:
+    name: Build rustsbi
+    runs-on: ubuntu-latest
+    needs: fmt
+    strategy:
+      matrix:
+        TARGET: [riscv64imac-unknown-none-elf, riscv32imac-unknown-none-elf]
+        TOOLCHAIN: [stable, nightly]
+    steps:
+      - uses: actions/checkout@v4
+      - uses: actions-rust-lang/setup-rust-toolchain@v1
+        with:
+          target: ${{ matrix.TARGET }}
+          toolchain: ${{ matrix.TOOLCHAIN }}
+      - uses: Swatinem/rust-cache@v2
+        with:
+          key: ${{ matrix.TARGET }}
+      - name: Build (no default features)
+        run: |
+          cargo build --target ${{ matrix.TARGET }} --verbose
+      - name: Build (machine)
+        run: |
+          cargo build --target ${{ matrix.TARGET }} --verbose --features "machine"
+      - name: Build (forward)
+        run: |
+          cargo build --target ${{ matrix.TARGET }} --verbose --features "forward"
+      - name: Build (machine + forward)
+        run: |
+          cargo build --target ${{ matrix.TARGET }} --verbose --features "machine, forward"
+
+  test-rustsbi:
+    name: Test rustsbi
+    needs: fmt
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v4
+      - uses: actions-rust-lang/setup-rust-toolchain@v1
+        with:
+          toolchain: stable
+      - uses: Swatinem/rust-cache@v2
+      - name: Run tests (no default features)
+        run: |
+          cargo test -p rustsbi --verbose
+      - name: Run tests (machine)
+        run: |
+          cargo test -p rustsbi --verbose --features "machine"
+      # Don't run tests with rustsbi `forward` features on here: it requires RISC-V targets to build.
+
+  test-sbi-spec:
+    name: Test sbi-spec
+    needs: fmt
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v4
+      - uses: actions-rust-lang/setup-rust-toolchain@v1
+        with:
+          toolchain: stable
+      - uses: Swatinem/rust-cache@v2
+      # - name: Check clippy
+      #   run: cargo clippy -- -D warnings
+      - name: Run tests
+        run: cargo test -p sbi-spec --verbose
+  
+  build-sbi-rt:
+    name: Build sbi-rt
+    needs: fmt
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        TARGET: [riscv64imac-unknown-none-elf, riscv32imac-unknown-none-elf]
+    steps:
+      - uses: actions/checkout@v4
+      - uses: actions-rust-lang/setup-rust-toolchain@v1
+        with:
+          toolchain: stable
+      - uses: Swatinem/rust-cache@v2
+      - name: Build
+        run: |
+          cargo build --target ${{ matrix.TARGET }} --verbose -p sbi-rt
+
+  build-sbi-testing:
+    name: Build sbi-testing
+    needs: fmt
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        TARGET: [riscv64imac-unknown-none-elf, riscv32imac-unknown-none-elf]
+    steps:
+      - uses: actions/checkout@v4
+      - uses: actions-rust-lang/setup-rust-toolchain@v1
+        with:
+          toolchain: stable
+      - uses: Swatinem/rust-cache@v2
+      - name: Build
+        run: |
+          cargo build --target ${{ matrix.TARGET }} --verbose -p sbi-testing
+
+# sbi-testing:
+#     name: Run rust-clippy analyzing
+#     runs-on: ubuntu-latest
+#     permissions:
+#       security-events: write
+#     steps:
+#       - name: Checkout code
+#         uses: actions/checkout@v4
+
+#       - name: Check format
+#         run: cargo fmt --check
+
+#       - name: Install clippy-sarif
+#         uses: actions-rs/[email protected]
+#         with:
+#           crate: clippy-sarif
+#           version: latest
+
+#       - name: Install sarif-fmt
+#         uses: actions-rs/[email protected]
+#         with:
+#           crate: sarif-fmt
+#           version: latest
+
+#       - name: Run rust-clippy
+#         run:
+#           cargo clippy
+#           --all-featuers
+#           --package fast-trap
+#           --message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
+#         continue-on-error: true
+
+#       - name: Upload analysis results to GitHub
+#         uses: github/codeql-action/upload-sarif@v2
+#         with:
+#           sarif_file: rust-clippy-results.sarif
+#           wait-for-processing: true

+ 0 - 203
.github/workflows/rust.yml

@@ -1,203 +0,0 @@
-name: CI
-
-on:
-  push:
-    branches: [ "main" ]
-  pull_request:
-    branches: [ "main" ]
-  workflow_dispatch:
-
-env:
-  CARGO_UNSTABLE_SPARSE_REGISTRY: true
-  CARGO_TERM_COLOR: always
-
-jobs:
-  fmt:
-    name: Rustfmt
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@v4
-      - uses: actions-rs/toolchain@v1
-        with:
-          profile: minimal
-          toolchain: stable
-          override: true
-          components: rustfmt
-      - name: Cache Dependencies
-        uses: Swatinem/rust-cache@v2
-      - uses: actions-rs/cargo@v1
-        with:
-          command: fmt
-          args: --all -- --check
-
-  check-stable:
-    name: Check rustsbi (stable)
-    runs-on: ubuntu-latest
-    needs: fmt
-    strategy:
-      matrix:
-        TARGET: [riscv64imac-unknown-none-elf, riscv32imac-unknown-none-elf]
-    steps:
-      - uses: actions/checkout@v4
-      - uses: actions-rs/toolchain@v1
-        with:
-          profile: minimal
-          toolchain: stable
-          override: true
-          target: ${{ matrix.TARGET }}
-      - name: Cache Dependencies
-        uses: Swatinem/rust-cache@v2
-        with:
-          key: ${{ matrix.TARGET }}
-      - name: Check (no default features)
-        uses: actions-rs/cargo@v1
-        with:
-          command: check 
-          args: --target ${{ matrix.TARGET }} --verbose -p rustsbi
-      - name: Check crate rustsbi (machine)
-        uses: actions-rs/cargo@v1
-        with:
-          command: check
-          args: --target ${{ matrix.TARGET }} --features "machine" --verbose -p rustsbi
-      - name: Check crate rustsbi (forward)
-        uses: actions-rs/cargo@v1
-        with:
-          command: check
-          args: --target ${{ matrix.TARGET }} --features "forward" --verbose -p rustsbi
-      - name: Check crate rustsbi (machine + forward)
-        uses: actions-rs/cargo@v1
-        with:
-          command: check
-          args: --target ${{ matrix.TARGET }} --features "machine, forward" --verbose -p rustsbi
-
-  check-nightly:
-    name: Check rustsbi (nightly)
-    runs-on: ubuntu-latest
-    needs: fmt
-    strategy:
-      matrix:
-        TARGET: [riscv64imac-unknown-none-elf, riscv32imac-unknown-none-elf]
-    steps:
-      - uses: actions/checkout@v4
-      - uses: actions-rs/toolchain@v1
-        with:
-          profile: minimal
-          toolchain: nightly
-          override: true
-          target: ${{ matrix.TARGET }}
-      - name: Cache Dependencies
-        uses: Swatinem/rust-cache@v2
-        with:
-          key: ${{ matrix.TARGET }}
-
-  tests:
-    name: Test rustsbi
-    needs: fmt
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@v4
-      - uses: actions-rs/toolchain@v1
-        with:
-          profile: minimal
-          toolchain: stable
-          components: clippy
-          override: true
-      - name: Cache Dependencies
-        uses: Swatinem/rust-cache@v2
-      # - name: Clippy
-      #   uses: actions-rs/cargo@v1
-      #   with:
-      #     command: clippy
-      - name: Run tests (no default features)
-        uses: actions-rs/cargo@v1
-        with:
-          command: test
-          args: --verbose -p rustsbi
-      - name: Run tests (machine)
-        uses: actions-rs/cargo@v1
-        with:
-          command: test
-          args: --features "machine" --verbose -p rustsbi
-
-  sbi-spec:
-    name: Test sbi-spec
-    needs: fmt
-    runs-on: ubuntu-latest
-    strategy:
-      fail-fast: false
-      matrix:
-        target:
-          [
-            riscv32imac-unknown-none-elf,
-            riscv64imac-unknown-none-elf,
-            x86_64-unknown-none,
-          ]
-    steps:
-      - uses: actions/checkout@v4
-      # Cache REF:
-      #   - https://github.com/actions/cache/blob/main/examples.md#rust---cargo
-      #   - https://github.com/actions-rs/toolchain/issues/54
-      - name: Cache Rust
-        uses: actions/cache@v3
-        with:
-          key: rust-toolchain-${{ matrix.target }}
-          path: |
-            ~/.rustup/settings.toml
-            ~/.rustup/toolchains/stable-*
-            ~/.rustup/update-hashes/stable-*
-            ~/.cargo/bin/
-            ~/.cargo/registry/index/
-            ~/.cargo/registry/cache/
-            ~/.cargo/git/db/
-            target/
-      - name: Setup Rust
-        run: |
-          rustup toolchain install stable --profile minimal
-          rustup component add rustfmt clippy
-          rustup target add ${{ matrix.target }}
-      - name: Check format
-        run: cargo fmt --all --check -p sbi-spec
-      # - name: Check clippy
-      #   run: cargo clippy -- -D warnings
-      - name: Check build
-        run: cargo build -p sbi-spec
-      - name: Check test
-        run: cargo test -p sbi-spec
-
-# sbi-testing:
-#     name: Run rust-clippy analyzing
-#     runs-on: ubuntu-latest
-#     permissions:
-#       security-events: write
-#     steps:
-#       - name: Checkout code
-#         uses: actions/checkout@v4
-
-#       - name: Check format
-#         run: cargo fmt --check
-
-#       - name: Install clippy-sarif
-#         uses: actions-rs/[email protected]
-#         with:
-#           crate: clippy-sarif
-#           version: latest
-
-#       - name: Install sarif-fmt
-#         uses: actions-rs/[email protected]
-#         with:
-#           crate: sarif-fmt
-#           version: latest
-
-#       - name: Run rust-clippy
-#         run:
-#           cargo clippy
-#           --all-featuers
-#           --package fast-trap
-#           --message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
-#         continue-on-error: true
-
-#       - name: Upload analysis results to GitHub
-#         uses: github/codeql-action/upload-sarif@v2
-#         with:
-#           sarif_file: rust-clippy-results.sarif
-#           wait-for-processing: true