Skip to content

Commit

Permalink
[build] Add main build to CI
Browse files Browse the repository at this point in the history
Cache the pre-build of the cross tools,
and reuse it for the main build.

Issue #298
  • Loading branch information
mfld-fr committed Feb 5, 2020
1 parent 6332929 commit a6ec3b1
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 15 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: cross

on:
push:
branches:
- master
paths:
- '.github/workflows/cross.yml'
- 'tools/*'
Expand All @@ -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
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -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
38 changes: 25 additions & 13 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/bash

# Quick and dirty build script for ELKS
# Arguments:
# - 'clean': full cleanup
# - 'auto' : continuous integration context

DELAY=7

Expand All @@ -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
}

Expand All @@ -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)"
Expand All @@ -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
Expand Down

0 comments on commit a6ec3b1

Please sign in to comment.