From fc5c82be289e5e7211c7f3aabf4da6f13bfebef9 Mon Sep 17 00:00:00 2001 From: Runji Wang Date: Wed, 29 Jan 2020 16:28:52 +0800 Subject: [PATCH] ci: add GitHub Actions --- .github/workflows/main.yml | 71 ++++++++++++++++++++++++++++++++++++++ .travis.yml | 57 ------------------------------ kernel/Makefile | 7 ++-- 3 files changed, 76 insertions(+), 59 deletions(-) create mode 100644 .github/workflows/main.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..387f49be --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,71 @@ +name: CI + +on: [push, pull_request] + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: rm rust-toolchain + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + override: true + components: rustfmt, clippy + - name: Check code format + run: cd kernel && cargo fmt -- --check + + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + arch: [x86_64, riscv32, riscv64, aarch64, mipsel] + steps: + - uses: actions/checkout@v2 + - name: Checkout submodules + run: git submodule update --init --recursive + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly-2020-01-17 + components: rust-src, llvm-tools-preview + + - name: Cache QEMU + id: cache-qemu + if: runner.os == 'Linux' + uses: actions/cache@v1 + with: + path: qemu-4.2.0 + key: ${{ runner.os }}-qemu + - name: Install QEMU + if: runner.os == 'Linux' && steps.cache-qemu.outputs.cache-hit != 'true' + run: | + wget https://download.qemu.org/qemu-4.2.0.tar.xz + tar xJf qemu-4.2.0.tar.xz > /dev/null + cd qemu-4.2.0 && ./configure --target-list=${{ matrix.arch }}-softmmu && sudo make install -j && cd .. + - name: Install QEMU + if: runner.os == 'macOS' + run: brew install qemu + + - name: Install dependencies + if: runner.os == 'Linux' + run: sudo apt install -y device-tree-compiler + - name: Install dependencies + if: runner.os == 'macOS' + run: brew install dtc + + - name: Cache cargo bins + uses: actions/cache@v1 + with: + path: ~/.cargo/bin + key: ${{ runner.os }}-cargo-bin + - name: Install cargo-binutils + run: test -x $HOME/.cargo/bin/cargo-objdump || cargo install cargo-binutils + + - name: Download prebuilt user image + run: cd user && make sfsimg arch=${{ matrix.arch }} prebuilt=1 && cd .. + - name: Build kernel + run: cd kernel && make build arch=${{ matrix.arch }} && cd .. diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8cb6b9b8..00000000 --- a/.travis.yml +++ /dev/null @@ -1,57 +0,0 @@ -sudo: false - -language: rust - -rust: nightly-2019-11-28 - -os: - - linux - - osx - -dist: bionic - -osx_image: xcode11 - -cache: - cargo: true - directories: - - $HOME/Library/Caches/Homebrew - - $TRAVIS_BUILD_DIR/qemu-4.1.0 - -addons: - apt: - update: true - packages: - - device-tree-compiler - homebrew: - packages: - - qemu - - dtc - -env: - matrix: - - ARCH="riscv64" - - ARCH="riscv64" OPTS="board=u540" - - ARCH="riscv64" OPTS="board=k210" - - ARCH="riscv64" OPTS="board=rocket_chip" - - ARCH="riscv32" - - ARCH="x86_64" - - ARCH="x86_64" OPTS="board=pc" - - ARCH="aarch64" - - ARCH="mipsel" OPTS="board=malta" - -install: - - if [ $TRAVIS_OS_NAME = linux ]; then - [ ! -d qemu-4.1.0/$ARCH-softmmu ] && wget https://download.qemu.org/qemu-4.1.0.tar.xz && tar xJf qemu-4.1.0.tar.xz > /dev/null && cd qemu-4.1.0 && ./configure --target-list=$ARCH-softmmu && make && cd ..; - export PATH=$PATH:$PWD/qemu-4.1.0/$ARCH-softmmu:$PWD/qemu-4.1.0; - fi - -before_script: - - rustup component add rust-src llvm-tools-preview - - (test -x $HOME/.cargo/bin/cargo-objdump || cargo install cargo-binutils) - - (test -x $HOME/.cargo/bin/cargo-xbuild || cargo install cargo-xbuild) - -script: - - cd user && make sfsimg arch=$ARCH prebuilt=1 && cd .. - - cd kernel && make build arch=$ARCH $OPTS && cd .. - - cd kernel && make test arch=$ARCH $OPTS && cd .. diff --git a/kernel/Makefile b/kernel/Makefile index 0c0485e5..3a14583c 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -31,7 +31,6 @@ # . extra_features = profile | ... Add additional features arch ?= riscv64 -board ?= none mode ?= release LOG ?= graphic ?= off @@ -56,7 +55,11 @@ export USER_IMG = $(user_dir)/build/$(arch).img export USER_QCOW2 = $(user_dir)/build/$(arch).qcow2 ifeq ($(arch), aarch64) -board := raspi3 +board ?= raspi3 +else ifeq ($(arch), mipsel) +board ?= malta +else +board ?= none endif # currently only mipsel architecture and rocket-chip need DTB linked to the kernel