|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - '*' |
| 7 | + - '!staging.tmp' |
| 8 | + tags: |
| 9 | + - '*' |
| 10 | + pull_request: |
| 11 | + |
| 12 | +jobs: |
| 13 | + test: |
| 14 | + name: "Test" |
| 15 | + |
| 16 | + strategy: |
| 17 | + matrix: |
| 18 | + platform: [ |
| 19 | + ubuntu-latest, |
| 20 | + macos-latest, |
| 21 | + windows-latest |
| 22 | + ] |
| 23 | + |
| 24 | + runs-on: ${{ matrix.platform }} |
| 25 | + timeout-minutes: 15 |
| 26 | + |
| 27 | + steps: |
| 28 | + - name: "Checkout Repository" |
| 29 | + uses: actions/checkout@v1 |
| 30 | + |
| 31 | + - name: Install Rustup |
| 32 | + run: | |
| 33 | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly |
| 34 | + echo ::add-path::$HOME/.cargo/bin |
| 35 | + if: runner.os == 'macOS' |
| 36 | + |
| 37 | + - name: "Print Rust Version" |
| 38 | + run: | |
| 39 | + rustc -Vv |
| 40 | + cargo -Vv |
| 41 | +
|
| 42 | + - name: "Install Rustup Components" |
| 43 | + run: rustup component add rust-src llvm-tools-preview |
| 44 | + - name: "Install cargo-xbuild" |
| 45 | + run: cargo install cargo-xbuild --debug |
| 46 | + - name: "Install cargo-binutils" |
| 47 | + run: cargo install cargo-binutils --debug |
| 48 | + |
| 49 | + - run: cargo xbuild |
| 50 | + working-directory: test-kernel |
| 51 | + name: 'Build Test Kernel' |
| 52 | + |
| 53 | + - name: 'Build Bootloader' |
| 54 | + run: cargo xbuild --bin bootloader --features binary --release |
| 55 | + env: |
| 56 | + KERNEL: "test-kernel/target/x86_64-test-kernel/debug/test-kernel" |
| 57 | + KERNEL_MANIFEST: "test-kernel/Cargo.toml" |
| 58 | + |
| 59 | + - name: 'Convert Bootloader ELF to Binary' |
| 60 | + run: cargo objcopy -- -I elf64-x86-64 -O binary --binary-architecture=i386:x86-64 target/x86_64-bootloader/release/bootloader target/x86_64-bootloader/release/bootloader.bin |
| 61 | + |
| 62 | + # install QEMU |
| 63 | + - name: Install QEMU (Linux) |
| 64 | + run: sudo apt update && sudo apt install qemu-system-x86 |
| 65 | + if: runner.os == 'Linux' |
| 66 | + - name: Install QEMU (macOS) |
| 67 | + run: brew install qemu |
| 68 | + if: runner.os == 'macOS' |
| 69 | + env: |
| 70 | + HOMEBREW_NO_AUTO_UPDATE: 1 |
| 71 | + HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK: 1 |
| 72 | + HOMEBREW_NO_INSTALL_CLEANUP: 1 |
| 73 | + - name: Install Scoop (Windows) |
| 74 | + run: | |
| 75 | + Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh') |
| 76 | + echo ::add-path::$HOME\scoop\shims |
| 77 | + if: runner.os == 'Windows' |
| 78 | + shell: pwsh |
| 79 | + - name: Install QEMU (Windows) |
| 80 | + run: scoop install qemu |
| 81 | + if: runner.os == 'Windows' |
| 82 | + shell: pwsh |
| 83 | + - name: "Print QEMU Version" |
| 84 | + run: qemu-system-x86_64 --version |
| 85 | + |
| 86 | + - name: 'Run Test Kernel with Bootloader' |
| 87 | + run: | |
| 88 | + qemu-system-x86_64 -drive format=raw,file=target/x86_64-bootloader/release/bootloader.bin -device isa-debug-exit,iobase=0xf4,iosize=0x04 -display none |
| 89 | + if [ $? -eq 123 ]; then (exit 0); else (exit 1); fi |
| 90 | + shell: 'bash {0}' |
| 91 | + |
| 92 | + |
| 93 | + build_example_kernel: |
| 94 | + name: "Build Example Kernel" |
| 95 | + strategy: |
| 96 | + matrix: |
| 97 | + platform: [ |
| 98 | + ubuntu-latest, |
| 99 | + macos-latest, |
| 100 | + windows-latest |
| 101 | + ] |
| 102 | + runs-on: ${{ matrix.platform }} |
| 103 | + timeout-minutes: 5 |
| 104 | + |
| 105 | + steps: |
| 106 | + - uses: actions/checkout@v1 |
| 107 | + - name: Install Rustup |
| 108 | + run: | |
| 109 | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly |
| 110 | + echo ::add-path::$HOME/.cargo/bin |
| 111 | + if: runner.os == 'macOS' |
| 112 | + - name: "Install Rustup Components" |
| 113 | + run: rustup component add rust-src llvm-tools-preview |
| 114 | + - name: "Install cargo-xbuild" |
| 115 | + run: cargo install cargo-xbuild --debug |
| 116 | + - name: 'Build Example Kernel' |
| 117 | + run: cargo xbuild |
| 118 | + working-directory: example-kernel |
| 119 | + |
| 120 | + |
| 121 | + check_formatting: |
| 122 | + name: "Check Formatting" |
| 123 | + runs-on: ubuntu-latest |
| 124 | + timeout-minutes: 2 |
| 125 | + steps: |
| 126 | + - uses: actions/checkout@v1 |
| 127 | + - name: "Find latest Nightly with rustfmt" |
| 128 | + id: component |
| 129 | + uses: actions-rs/components-nightly@v1 |
| 130 | + with: |
| 131 | + component: rustfmt |
| 132 | + - name: "Add a rustup override for rustfmt nightly" |
| 133 | + uses: actions-rs/toolchain@v1 |
| 134 | + with: |
| 135 | + toolchain: ${{ steps.component.outputs.toolchain }} |
| 136 | + override: true |
| 137 | + - run: rustup component add rustfmt |
| 138 | + - run: cargo fmt -- --check |
0 commit comments