From d1bd5489681f8858f3590e388f06b3d01fe77366 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Thu, 24 Jun 2021 14:37:01 +0200 Subject: [PATCH 1/4] Rework CI --- .github/workflows/format.yml | 35 +++---- .github/workflows/kvm.yml | 44 --------- .github/workflows/kvm_test.yml | 43 +++++++++ .github/workflows/publish.yml | 61 ------------ .github/workflows/publish_docs.yml | 44 +++++++++ .github/workflows/test.yml | 147 +++++++++++------------------ bors.toml | 8 +- 7 files changed, 159 insertions(+), 223 deletions(-) delete mode 100644 .github/workflows/kvm.yml create mode 100644 .github/workflows/kvm_test.yml delete mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/publish_docs.yml diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index a57e6a4ce..88c7105af 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -1,36 +1,23 @@ -name: Format check +name: Format on: - pull_request: push: branches: - master - staging - trying + pull_request: + +env: + CARGO_TERM_COLOR: always jobs: - check: - name: Format check + format: + name: Format runs-on: ubuntu-latest - - strategy: - matrix: - os: [ubuntu-latest] - rust: [nightly] - include: - - os: ubuntu-latest - rust: 'nightly' - components: 'rustfmt' - targets: 'x86_64-unknown-linux-gnu' - - steps: - - uses: hecrj/setup-rust-action@v1 - with: - rust-version: ${{ matrix.rust }} - components: ${{ matrix.components || '' }} - targets: ${{ matrix.targets || '' }} - - name: Checkout - uses: actions/checkout@v2 - - name: Check Formatting + - uses: actions/checkout@v2 + - name: Rustup (apply rust-toolchain.toml) + run: rustup show + - name: Format run: cargo fmt -- --check diff --git a/.github/workflows/kvm.yml b/.github/workflows/kvm.yml deleted file mode 100644 index dffee9dcc..000000000 --- a/.github/workflows/kvm.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: KVM Tests - -on: - pull_request: - push: - branches: - - master - - staging - - trying - -jobs: - kvm: - name: KVM Tests - runs-on: [self-hosted] - - steps: - - uses: hecrj/setup-rust-action@v1 - with: - rust-version: nightly - components: 'rust-src, llvm-tools-preview' - targets: 'x86_64-unknown-linux-gnu' - - uses: actions/checkout@v2.3.4 - with: - submodules: true - - name: Check Cargo availability - run: cargo --version - - name: Build (debug) - run: - cargo build -p rusty_demo - - name: Build (release) - run: - cargo build -p rusty_demo --release - - name: Check test environment - shell: bash - run: | - lscpu - kvm-ok - cargo install --git https://github.com/hermitcore/uhyve.git - - name: Test debug version - run: - RUST_LOG=debug uhyve -v -c 1 target/x86_64-unknown-hermit/release/rusty_demo - - name: Test release version - run: - RUST_LOG=debug uhyve -v -c 1 target/x86_64-unknown-hermit/release/rusty_demo diff --git a/.github/workflows/kvm_test.yml b/.github/workflows/kvm_test.yml new file mode 100644 index 000000000..b67b809a4 --- /dev/null +++ b/.github/workflows/kvm_test.yml @@ -0,0 +1,43 @@ +name: KVM Test + +on: + push: + branches: + - master + - staging + - trying + pull_request: + +env: + CARGO_TERM_COLOR: always + +jobs: + kvm_test: + name: KVM Test + runs-on: [self-hosted] + + steps: + - uses: actions/checkout@v2 + with: + submodules: true + - name: Rustup (apply rust-toolchain.toml) + run: rustup show + - name: Build dev profile + run: cargo build --package rusty_demo + - name: Install uhyve + run: cargo install uhyve --locked + - name: Check KVM availability + shell: bash + run: | + lscpu + kvm-ok + - name: Test debug version + run: uhyve --verbose --cpus 1 target/x86_64-unknown-hermit/debug/rusty_demo + env: + RUST_LOG: debug + - name: Build release profile + run: cargo build --package rusty_demo --release + - name: Test release version + run: uhyve --verbose --cpus 1 target/x86_64-unknown-hermit/release/rusty_demo + env: + RUST_LOG: debug diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 2ea416454..000000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,61 +0,0 @@ -name: Build docs - -on: - push: - branches: - - master - -jobs: - publish: - runs-on: ${{ matrix.os }} - - strategy: - matrix: - os: [ubuntu-latest] - rust: [nightly] - include: - - os: ubuntu-latest - rust: 'nightly' - components: 'rust-src, llvm-tools-preview' - targets: 'x86_64-unknown-linux-gnu' - - steps: - - uses: hecrj/setup-rust-action@v1 - with: - rust-version: ${{ matrix.rust }} - components: ${{ matrix.components || '' }} - targets: ${{ matrix.targets || '' }} - - uses: actions/checkout@v2 - with: - submodules: true - - name: Check Cargo availability - run: cargo --version - - name: Install nasm - run: sudo apt-get update --fix-missing && sudo apt-get install nasm - - name: Generate documentation - uses: actions-rs/cargo@v1 - with: - command: doc - args: --workspace -Z build-std=std,core,alloc,panic_abort --target x86_64-unknown-hermit - - name: Generate index.html - run: | - cat > target/x86_64-unknown-hermit/doc/index.html < - - - Redirect! - - - -

Redirect

- - - EOL - - name: Deploy documentation - if: success() - uses: crazy-max/ghaction-github-pages@v1 - with: - target_branch: gh-pages - build_dir: target/x86_64-unknown-hermit/doc - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/publish_docs.yml b/.github/workflows/publish_docs.yml new file mode 100644 index 000000000..ec5440d32 --- /dev/null +++ b/.github/workflows/publish_docs.yml @@ -0,0 +1,44 @@ +name: Publish Docs + +on: + push: + branches: + - master + +env: + CARGO_TERM_COLOR: always + +jobs: + publish_docs: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: true + - name: Rustup (apply rust-toolchain.toml) + run: rustup show + - name: Generate documentation + run: cargo doc + - name: Generate index.html + run: | + cat > target/x86_64-unknown-hermit/doc/index.html < + + + Redirect! + + + +

Redirect

+ + + EOL + - name: Deploy documentation + if: success() + uses: crazy-max/ghaction-github-pages@v1 + with: + target_branch: gh-pages + build_dir: target/x86_64-unknown-hermit/doc + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3ad872d10..371e5ed74 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,106 +1,73 @@ -name: Build and test +name: Test on: - pull_request: push: branches: - master - staging - trying - schedule: - - cron: '0 0 * * 6' + pull_request: + +env: + CARGO_TERM_COLOR: always + +defaults: + run: + shell: bash jobs: build: name: Test runs-on: ${{ matrix.os }} - # these tests based on the nightly compiler, which can be broken - # consequently, we continue on an error - #continue-on-error: true - strategy: matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] - rust: [nightly] - include: - - os: macOS-latest - rust: 'nightly' - components: 'rust-src, llvm-tools-preview' - targets: 'x86_64-apple-darwin' - - os: windows-latest - rust: 'nightly' - components: 'rust-src, llvm-tools-preview' - targets: 'x86_64-pc-windows-msvc' - - os: ubuntu-latest - rust: 'nightly' - components: 'rust-src, llvm-tools-preview' - targets: 'x86_64-unknown-linux-gnu' - + os: [ubuntu-latest, macos-latest, windows-latest] steps: - - uses: hecrj/setup-rust-action@v1 - with: - rust-version: ${{ matrix.rust }} - components: ${{ matrix.components || '' }} - targets: ${{ matrix.targets || '' }} - - uses: actions/checkout@v2 - with: - submodules: true - - name: Check Cargo availability - run: cargo --version - - name: Install qemu/nasm (apt) - run: sudo apt-get update --fix-missing && sudo apt-get install qemu-system-x86 nasm - if: ${{ matrix.os == 'ubuntu-latest' }} - - name: Install qemu/nasm (macos) - run: | + - uses: actions/checkout@v2 + with: + submodules: true + - name: Rustup (apply rust-toolchain.toml) + run: rustup show + - name: Build dev profile + run: cargo build --package rusty_demo + - name: Install QEMU, NASM (ubuntu) + if: ${{ matrix.os == 'ubuntu-latest' }} + run: | + sudo apt-get update + sudo apt-get install qemu-system-x86 nasm + - name: Install QEMU, NASM (macos) + if: ${{ matrix.os == 'macos-latest' }} + run: | + brew update brew install qemu nasm - if: ${{ matrix.os == 'macOS-latest' }} - - name: Install nasm (windows) - uses: crazy-max/ghaction-chocolatey@v1 - with: - args: install nasm - if: ${{ matrix.os == 'windows-latest' }} - - name: Install qemu (windows) - uses: crazy-max/ghaction-chocolatey@v1 - with: - args: install qemu --version=2020.08.14 - if: ${{ matrix.os == 'windows-latest' }} - - name: Set path to qemu/nasm (Windows) - run: | - echo "C:\Program Files\qemu" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - echo "C:\Program Files\nasm" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - if: ${{ matrix.os == 'windows-latest' }} - - name: Building dev version - run: - cargo build -p rusty_demo -Z build-std=std,core,alloc,panic_abort --target x86_64-unknown-hermit - - name: Building release version - run: - cargo build -p rusty_demo -Z build-std=std,core,alloc,panic_abort --target x86_64-unknown-hermit --release - #env: - # RUSTFLAGS: -Clinker-plugin-lto - - name: Build loader (unix) - working-directory: loader - run: make - if: ${{ ( matrix.os == 'macOS-latest' ) || ( matrix.os == 'ubuntu-latest' ) }} - # Workaround since makefile doesn't work when using powershell - - name: Build loader (windows) - working-directory: loader - run: | - cargo build -Z build-std=core,alloc --target x86_64-unknown-hermit-loader.json - $VAR_RUSTC_SYSROOT = (rustc --print sysroot) - echo "Sysroot - $VAR_RUSTC_SYSROOT" - $LLVM_OBJCOPY = ((Get-ChildItem -Path $VAR_RUSTC_SYSROOT -Include llvm-objcopy.exe -File -Recurse -ErrorAction SilentlyContinue)).Fullname - echo "LLVM Objcopy - $LLVM_OBJCOPY" - Invoke-Expression "$LLVM_OBJCOPY --strip-debug -O elf32-i386 target/x86_64-unknown-hermit-loader/debug/rusty-loader" - if: ${{ matrix.os == 'windows-latest' }} - - name: Test dev version - run: - qemu-system-x86_64 -display none -smp 1 -m 64M -serial stdio -kernel loader/target/x86_64-unknown-hermit-loader/debug/rusty-loader -initrd target/x86_64-unknown-hermit/debug/rusty_demo -cpu qemu64,apic,fsgsbase,rdtscp,xsave,fxsr,rdrand - - name: Test release version - run: - qemu-system-x86_64 -display none -smp 1 -m 64M -serial stdio -kernel loader/target/x86_64-unknown-hermit-loader/debug/rusty-loader -initrd target/x86_64-unknown-hermit/release/rusty_demo -cpu qemu64,apic,fsgsbase,rdtscp,xsave,fxsr,rdrand - - name: Build httpd with DHCP support - run: - cargo build --manifest-path examples/httpd/Cargo.toml --features dhcpv4 - - name: Build httpd without DHCP support - run: - cargo build --manifest-path examples/httpd/Cargo.toml + - name: Install QEMU, NASM, GNU make (windows) + if: ${{ matrix.os == 'windows-latest' }} + run: | + choco install qemu nasm make + echo "C:\Program Files\qemu" >> $GITHUB_PATH + echo "C:\Program Files\NASM" >> $GITHUB_PATH + - name: Build loader + run: | + sed -i.old 's/OBJCOPY := $(shell find $(SYSROOT) -name llvm-objcopy)/OBJCOPY := $(shell find $(SYSROOT) -name llvm-objcopy -o -name llvm-objcopy.exe)/g' loader/Makefile + make -C loader release=1 + - name: Test dev profile + run: | + qemu-system-x86_64 -display none -smp 1 -m 128M -serial stdio \ + -cpu qemu64,apic,fsgsbase,rdtscp,xsave,fxsr,rdrand \ + -kernel loader/target/x86_64-unknown-hermit-loader/release/rusty-loader \ + -initrd target/x86_64-unknown-hermit/debug/rusty_demo + - name: Build release profile + run: + cargo build --package rusty_demo --release + - name: Test release profile + run: | + qemu-system-x86_64 -display none -smp 1 -m 128M -serial stdio \ + -cpu qemu64,apic,fsgsbase,rdtscp,xsave,fxsr,rdrand \ + -kernel loader/target/x86_64-unknown-hermit-loader/release/rusty-loader \ + -initrd target/x86_64-unknown-hermit/release/rusty_demo + - name: Build httpd with DHCP support + run: + cargo build --package httpd --features dhcpv4 + - name: Build httpd without DHCP support + run: + cargo build --package httpd diff --git a/bors.toml b/bors.toml index 423392b4c..c1fbf3d1d 100644 --- a/bors.toml +++ b/bors.toml @@ -1,8 +1,8 @@ status = [ - "Test (macOS-latest, nightly)", - "Test (windows-latest, nightly)", - "Test (ubuntu-latest, nightly)", - "Format check (ubuntu-latest, nightly)", + "Test (ubuntu-latest)", + "Test (macOS-latest)", + "Test (windows-latest)", + "Format", "Clippy", "KVM Tests", ] From 7977c2108204493379f9814c7db4ee0a0ec3e941 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Fri, 25 Jun 2021 11:13:12 +0200 Subject: [PATCH 2/4] build.rs: Enable colored output --- hermit-sys/build.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hermit-sys/build.rs b/hermit-sys/build.rs index 770e2822a..70ce0a3f6 100644 --- a/hermit-sys/build.rs +++ b/hermit-sys/build.rs @@ -22,6 +22,8 @@ fn build_hermit(src_dir: &Path, target_dir_opt: Option<&Path>) { let profile = env::var("PROFILE").expect("PROFILE was not set"); let mut cmd = Command::new("cargo"); + cmd.env("CARGO_TERM_COLOR", "always"); + if target.target_arch() == "x86_64" { cmd.current_dir(src_dir) .arg("build") From 69b63d20b9b6be68cde0ddfae0f40ff7f4af7cb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Fri, 25 Jun 2021 11:13:43 +0200 Subject: [PATCH 3/4] Remove comment for resolved issue --- hermit-sys/build.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hermit-sys/build.rs b/hermit-sys/build.rs index 70ce0a3f6..e7eb643db 100644 --- a/hermit-sys/build.rs +++ b/hermit-sys/build.rs @@ -153,8 +153,7 @@ fn build_hermit(src_dir: &Path, target_dir_opt: Option<&Path>) { println!("cargo:rustc-link-search=native={}", lib_location.display()); println!("cargo:rustc-link-lib=static=hermit"); - //HERMIT_LOG_LEVEL_FILTER sets the log level filter at compile time - // Doesn't actually rebuild atm - see: https://github.com/rust-lang/cargo/issues/8306 + // HERMIT_LOG_LEVEL_FILTER sets the log level filter at compile time println!("cargo:rerun-if-env-changed=HERMIT_LOG_LEVEL_FILTER"); } From 6d4a61e2f4cdba35f4134b9a708a0261e109333b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Fri, 25 Jun 2021 11:16:17 +0200 Subject: [PATCH 4/4] build.rs: Use the same cargo binary --- hermit-sys/build.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hermit-sys/build.rs b/hermit-sys/build.rs index e7eb643db..7c9b487fe 100644 --- a/hermit-sys/build.rs +++ b/hermit-sys/build.rs @@ -20,7 +20,7 @@ fn build_hermit(src_dir: &Path, target_dir_opt: Option<&Path>) { ); let target = TargetInfo::new().expect("Could not get target info"); let profile = env::var("PROFILE").expect("PROFILE was not set"); - let mut cmd = Command::new("cargo"); + let mut cmd = Command::new(env!("CARGO")); cmd.env("CARGO_TERM_COLOR", "always"); @@ -203,7 +203,7 @@ fn build() { let src_dir = out_dir.join("rusty-hermit"); if !src_dir.as_path().exists() { - let status = Command::new("cargo") + let status = Command::new(env!("CARGO")) .current_dir(out_dir) .arg("download") .arg("--output")