Skip to content

Commit dbdbfba

Browse files
committed
Add GitHub actions workflow
1 parent 6aebafd commit dbdbfba

File tree

1 file changed

+176
-0
lines changed

1 file changed

+176
-0
lines changed

.github/workflows/build.yml

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
tags:
8+
- '*'
9+
schedule:
10+
- cron: '40 4 * * *' # every day at 4:40
11+
pull_request:
12+
13+
jobs:
14+
build:
15+
name: "Build"
16+
17+
strategy:
18+
matrix:
19+
platform: [
20+
ubuntu-latest,
21+
macos-latest,
22+
windows-latest
23+
]
24+
25+
runs-on: ${{ matrix.platform }}
26+
timeout-minutes: 15
27+
28+
steps:
29+
- name: "Checkout Repository"
30+
uses: actions/checkout@v1
31+
32+
- name: Install Rustup (macOS)
33+
run: |
34+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
35+
echo ::add-path::$HOME/.cargo/bin
36+
if: runner.os == 'macOS'
37+
38+
- name: Set Rustup profile to minimal
39+
run: rustup set profile minimal
40+
41+
- name: Install musl target on Linux
42+
run: |
43+
rustup target add x86_64-unknown-linux-musl
44+
sudo apt-get install musl-tools musl-dev
45+
if: runner.os == 'Linux'
46+
47+
- name: "Print Rust Version"
48+
run: |
49+
rustc -Vv
50+
cargo -Vv
51+
52+
- name: "Run cargo build"
53+
run: cargo build
54+
55+
- name: "Run cargo test"
56+
run: cargo test
57+
58+
- name: "Deny Warnings"
59+
run: cargo build
60+
env:
61+
RUSTFLAGS: "-D warnings"
62+
63+
- name: "Install it"
64+
run: cargo install --path . --debug
65+
66+
- name: "Upload Artifact"
67+
uses: actions/upload-artifact@v2
68+
with:
69+
name: ${{ env.name }}-bootimage
70+
path: ~/.cargo/bin/bootimage
71+
72+
test:
73+
name: "Test"
74+
75+
strategy:
76+
matrix:
77+
platform: [
78+
ubuntu-latest,
79+
macos-latest,
80+
windows-latest
81+
]
82+
83+
runs-on: ${{ matrix.platform }}
84+
timeout-minutes: 15
85+
86+
steps:
87+
- name: "Checkout Repository"
88+
uses: actions/checkout@v1
89+
90+
- name: "Download Bootimage Artifact"
91+
uses: actions/download-artifact@v2
92+
with:
93+
name: ${{ env.name }}-bootimage
94+
path: ~/.cargo/bin/bootimage
95+
96+
- name: Install Rustup (macOS)
97+
run: |
98+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
99+
echo ::add-path::$HOME/.cargo/bin
100+
if: runner.os == 'macOS'
101+
102+
- name: "Install Rustup Components"
103+
run: rustup component add rust-src llvm-tools-preview
104+
- name: "Install cargo-xbuild"
105+
run: cargo install cargo-xbuild --debug
106+
107+
# install QEMU
108+
- name: Install QEMU (Linux)
109+
run: |
110+
sudo apt update
111+
sudo apt install qemu-system-x86
112+
if: runner.os == 'Linux'
113+
- name: Install QEMU (macOS)
114+
run: brew install qemu
115+
if: runner.os == 'macOS'
116+
env:
117+
HOMEBREW_NO_AUTO_UPDATE: 1
118+
HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK: 1
119+
HOMEBREW_NO_INSTALL_CLEANUP: 1
120+
- name: Install Scoop (Windows)
121+
run: |
122+
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
123+
echo ::add-path::$HOME\scoop\shims
124+
if: runner.os == 'Windows'
125+
shell: pwsh
126+
- name: Install QEMU (Windows)
127+
run: scoop install qemu
128+
if: runner.os == 'Windows'
129+
shell: pwsh
130+
131+
- name: "Print QEMU Version"
132+
run: qemu-system-x86_64 --version
133+
134+
- name: 'Build "basic" Kernel'
135+
run: cargo bootimage --target ../x86_64-bootimage-example-kernels.json
136+
working-directory: example-kernels/basic
137+
138+
- name: 'Run QEMU with "basic" Kernel'
139+
run: |
140+
qemu-system-x86_64 -drive format=raw,file=target/x86_64-bootimage-example-kernels/debug/bootimage-basic.bin -device isa-debug-exit,iobase=0xf4,iosize=0x04 -display none
141+
if [ $? -eq 103 ]; then (exit 0); else (exit 1); fi
142+
shell: bash
143+
working-directory: example-kernels
144+
145+
- name: 'Run `cargo xrun` for "runner" kernel'
146+
run: |
147+
cargo xrun
148+
if [ $? -eq 109 ]; then (exit 0); else (exit 1); fi
149+
shell: bash
150+
working-directory: example-kernels/runner
151+
152+
- run: cargo xtest -Z doctest-xcompile
153+
working-directory: example-kernels/runner-doctest
154+
name: 'Run `cargo xtest -Z doctest-xcompile` for "runner-doctest" kernel'
155+
156+
- run: cargo xtest
157+
working-directory: example-kernels/runner-test
158+
name: 'Run `cargo xtest` for "runner-test" kernel'
159+
160+
check_formatting:
161+
name: "Check Formatting"
162+
runs-on: ubuntu-latest
163+
timeout-minutes: 2
164+
steps:
165+
- uses: actions/checkout@v1
166+
- run: rustup toolchain install nightly --profile minimal --component rustfmt
167+
- run: cargo +nightly fmt -- --check
168+
169+
clippy:
170+
name: "Clippy"
171+
runs-on: ubuntu-latest
172+
timeout-minutes: 10
173+
steps:
174+
- uses: actions/checkout@v1
175+
- run: rustup toolchain install nightly --profile minimal --component clippy
176+
- run: cargo +nightly clippy -- -D warnings

0 commit comments

Comments
 (0)