From a6ec3b190a94e2dda1f4e00e4d65a6af31ab6fb0 Mon Sep 17 00:00:00 2001 From: mfld-fr Date: Wed, 5 Feb 2020 20:47:36 +0100 Subject: [PATCH] [build] Add main build to CI Cache the pre-build of the cross tools, and reuse it for the main build. Issue #298 --- .github/workflows/cross.yml | 13 +++++++++++-- .github/workflows/main.yml | 39 +++++++++++++++++++++++++++++++++++++ build.sh | 38 +++++++++++++++++++++++------------- 3 files changed, 75 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/cross.yml b/.github/workflows/cross.yml index 313847b15..39055c16c 100644 --- a/.github/workflows/cross.yml +++ b/.github/workflows/cross.yml @@ -2,8 +2,6 @@ name: cross on: push: - branches: - - master paths: - '.github/workflows/cross.yml' - 'tools/*' @@ -20,16 +18,27 @@ jobs: - name: checkout uses: actions/checkout@v2 + - name: cache + id: cache + uses: actions/cache@v1 + with: + path: cross + key: cross-${{ hashFiles('tools/*') }}-${{ runner.os }} + - name: prepare + if: steps.cache.outputs.cache-hit != 'true' run: 'mkdir cross' - name: build + if: steps.cache.outputs.cache-hit != 'true' run: tools/build.sh - name: packing + if: steps.cache.outputs.cache-hit != 'true' run: tools/pack.sh - name: upload + if: steps.cache.outputs.cache-hit != 'true' uses: actions/upload-artifact@v1 with: name: cross diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..ecf219fca --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,39 @@ +name: main + +on: + push: + paths: + - '.github/workflows/main.yml' + - '!tools/*' + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - name: setup + run: 'sudo apt install bison flex texinfo libncurses5-dev' + + - name: checkout + uses: actions/checkout@v2 + + - name: cache + id: cache + uses: actions/cache@v1 + with: + path: cross + key: cross-${{ hashFiles('tools/*') }}-${{ runner.os }} + + - name: cross + if: steps.cache.outputs.cache-hit != 'true' + run: tools/build.sh + + - name: build + run: ./build.sh auto + + - name: upload + uses: actions/upload-artifact@v1 + with: + name: fd1440.bin + path: image/fd1440.bin diff --git a/build.sh b/build.sh index 7f53a6c87..19ffa4e1a 100755 --- a/build.sh +++ b/build.sh @@ -1,6 +1,9 @@ #!/bin/bash # Quick and dirty build script for ELKS +# Arguments: +# - 'clean': full cleanup +# - 'auto' : continuous integration context DELAY=7 @@ -14,7 +17,7 @@ pause () { else echo -n "Press a key to continue... " read -n 1 -s 2>/dev/null || sleep $DELAY -fi + fi echo } @@ -32,9 +35,11 @@ clean_exit () { # TODO: check script status on return . tools/env.sh -# Check tools -mkdir -p "$CROSSDIR" -test -x "$CROSSDIR/bin/ia16-elf-gcc" || tools/build.sh || clean_exit 1 +# Build cross tools if not already +if [ "$1" != "auto" ]; then + mkdir -p "$CROSSDIR" + test -x "$CROSSDIR/bin/ia16-elf-gcc" || tools/build.sh || clean_exit 1 +fi # Working directory WD="$(pwd)" @@ -51,21 +56,28 @@ if [ "$1" = "clean" ] fi ### Configure all (kernel + user land) -echo -echo "Now invoking 'make menuconfig' for you to configure the system." -echo "The defaults should be OK for many systems, but you may want to review them." -pause -make menuconfig || clean_exit 2 +if [ "$1" = "auto" ]; then + echo "Invoking 'make defconfig'." + make defconfig || clean_exit 2 +else + echo + echo "Now invoking 'make menuconfig' for you to configure the system." + echo "The defaults should be OK for many systems, but you may want to review them." + pause + make menuconfig || clean_exit 2 +fi + test -e .config || clean_exit 3 ### Clean all -echo "Cleaning all..." -sleep 1 -make clean || clean_exit 4 +if [ "$1" != "auto" ]; then + echo "Cleaning all..." + sleep 1 + make clean || clean_exit 4 + fi ### Build all echo "Building all..." -sleep 1 # Forcing single threaded build because of dirty dependencies (see #273) make -j1 all || clean_exit 5 test -e elks/arch/i86/boot/Image || clean_exit 6