Browse Source

Test more things in CI (#33)

* Alloc is required for tests too.

* Try building and testing with no features.

* Don't build every PR twice.

* Use actions-rs for Clippy.

This lets it attach annotations to files.

* Build and run RISC-V example too.

* Need nightly toolchain for RISC-V example.

* Build aarch64 example too.

* Don't fail fast.

* aarch64 build apparently needs GCC.

* Disable QEMU display output in CI.

* Use newer version of Ubuntu for running examples.

ubuntu-latest is 20.04, which has an ancient version of QEMU which
doesn't work properly for RISC-V.

* apt update before install.
Andrew Walbran 2 năm trước cách đây
mục cha
commit
6787ffb9b0
4 tập tin đã thay đổi với 59 bổ sung6 xóa
  1. 55 5
      .github/workflows/main.yml
  2. 1 0
      examples/aarch64/Makefile
  3. 2 0
      examples/riscv/Makefile
  4. 1 1
      src/lib.rs

+ 55 - 5
.github/workflows/main.yml

@@ -1,6 +1,9 @@
 name: CI
 
-on: [push, pull_request]
+on:
+  push:
+    branches: [master]
+  pull_request:
 
 jobs:
   check:
@@ -18,9 +21,9 @@ jobs:
           command: fmt
           args: --all -- --check
       - name: Clippy
-        uses: actions-rs/cargo@v1
+        uses: actions-rs/clippy-check@v1
         with:
-          command: clippy
+          token: ${{ secrets.GITHUB_TOKEN }}
 
   build:
     runs-on: ubuntu-latest
@@ -30,7 +33,12 @@ jobs:
         with:
           profile: minimal
           toolchain: stable
-      - name: Build
+      - name: Build with no features
+        uses: actions-rs/cargo@v1
+        with:
+          command: build
+          args: --no-default-features
+      - name: Build with all features
         uses: actions-rs/cargo@v1
         with:
           command: build
@@ -39,8 +47,50 @@ jobs:
         uses: actions-rs/cargo@v1
         with:
           command: doc
-      - name: Test
+      - name: Test with no features
+        uses: actions-rs/cargo@v1
+        with:
+          command: test
+          args: --no-default-features
+      - name: Test with all features
         uses: actions-rs/cargo@v1
         with:
           command: test
           args: --all-features
+
+  examples:
+    runs-on: ubuntu-22.04
+    strategy:
+      fail-fast: false
+      matrix:
+        example:
+          - aarch64
+          - riscv
+        include:
+          - example: aarch64
+            toolchain: stable
+            target: aarch64-unknown-none
+            packages: qemu-system-arm gcc-aarch64-linux-gnu
+          - example: riscv
+            toolchain: nightly-2022-11-03
+            target: riscv64imac-unknown-none-elf
+            packages: qemu-system-misc
+    steps:
+      - uses: actions/checkout@v2
+      - name: Install QEMU
+        run: sudo apt update && sudo apt install ${{ matrix.packages }}
+      - uses: actions-rs/toolchain@v1
+        with:
+          profile: minimal
+          toolchain: ${{ matrix.toolchain }}
+          target: ${{ matrix.target }}
+          components: llvm-tools-preview, rustfmt
+      - name: Check code format
+        working-directory: examples/${{ matrix.example }}
+        run: cargo fmt --all -- --check
+      - name: Build
+        working-directory: examples/${{ matrix.example }}
+        run: make kernel
+      - name: Run
+        working-directory: examples/${{ matrix.example }}
+        run: QEMU_ARGS="-display none" make qemu

+ 1 - 0
examples/aarch64/Makefile

@@ -39,6 +39,7 @@ clean:
 
 qemu: $(kernel_bin) $(img)
 	qemu-system-aarch64 \
+	  $(QEMU_ARGS) \
 		-machine virt \
 		-cpu max \
 		-serial mon:stdio \

+ 2 - 0
examples/riscv/Makefile

@@ -38,6 +38,7 @@ clean:
 
 qemu-legacy: kernel $(img)
 	qemu-system-$(arch) \
+	  $(QEMU_ARGS) \
 		-machine virt \
 		-serial mon:stdio \
 		-bios default \
@@ -51,6 +52,7 @@ qemu-legacy: kernel $(img)
 
 qemu: kernel $(img)
 	qemu-system-$(arch) \
+	  $(QEMU_ARGS) \
 		-machine virt \
 		-serial mon:stdio \
 		-bios default \

+ 1 - 1
src/lib.rs

@@ -5,7 +5,7 @@
 #![allow(clippy::identity_op)]
 #![allow(dead_code)]
 
-#[cfg(feature = "alloc")]
+#[cfg(any(feature = "alloc", test))]
 extern crate alloc;
 
 mod blk;