Merge pull request #210 from alistair23/alistair/artifacts

.github: Build artifacts as part of workflow
diff --git a/.github/workflows/artifacts.yml b/.github/workflows/artifacts.yml
new file mode 100644
index 0000000..3617c11
--- /dev/null
+++ b/.github/workflows/artifacts.yml
@@ -0,0 +1,53 @@
+name: Artifacts
+on: [push]
+
+jobs:
+  build:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout repository
+        uses: actions/checkout@v2
+
+      - name: Install Rust toolchain
+        uses: actions-rs/toolchain@v1.0.6
+        with:
+          profile: minimal
+
+      - name: Install dependencies
+        run: |
+          rustup target add thumbv7em-none-eabi
+          rustup target add riscv32imac-unknown-none-elf
+          rustup target add riscv32imc-unknown-none-elf
+          cargo install elf2tab --version 0.4.0
+
+      - name: Build Hello World
+        run: |
+          FEATURES="alloc" make flash-apollo3  EXAMPLE=hello_world -j2
+          FEATURES="alloc" make flash-hail  EXAMPLE=hello_world -j2
+          FEATURES="alloc" make flash-nucleo_f429zi  EXAMPLE=hello_world -j2
+          FEATURES="alloc" make flash-nucleo_f446re  EXAMPLE=hello_world -j2
+          FEATURES="alloc" make flash-nrf52840  EXAMPLE=hello_world -j2
+          FEATURES="alloc" make flash-opentitan  EXAMPLE=hello_world -j2
+          FEATURES="alloc" make flash-hifive1  EXAMPLE=hello_world -j2
+          FEATURES="alloc" make flash-nrf52  EXAMPLE=hello_world -j2
+
+      - name: Build libtock-test
+        run: |
+          FEATURES="alloc" make flash-apollo3  EXAMPLE=libtock_test -j2
+          FEATURES="alloc" make flash-hail  EXAMPLE=libtock_test -j2
+          FEATURES="alloc" make flash-nucleo_f429zi  EXAMPLE=libtock_test -j2
+          FEATURES="alloc" make flash-nucleo_f446re  EXAMPLE=libtock_test -j2
+          FEATURES="alloc" make flash-nrf52840  EXAMPLE=libtock_test -j2
+          FEATURES="alloc" make flash-opentitan  EXAMPLE=libtock_test -j2
+          FEATURES="alloc" make flash-hifive1  EXAMPLE=libtock_test -j2
+          FEATURES="alloc" make flash-nrf52  EXAMPLE=libtock_test -j2
+
+      - name: Build extra tests
+        run: |
+          FEATURES="alloc" make flash-opentitan  EXAMPLE=hmac -j2
+
+      - name: Archive artifacts
+        uses: actions/upload-artifact@v2
+        with:
+          name: libtock-rs examples
+          path: target/*/tab/*/*/*.tbf
diff --git a/test_runner/src/main.rs b/test_runner/src/main.rs
index e297e8e..0bea1cf 100644
--- a/test_runner/src/main.rs
+++ b/test_runner/src/main.rs
@@ -14,7 +14,7 @@
 async fn perform_tests() -> Result<(), Box<dyn std::error::Error>> {
     let mut failed_tests = Vec::new();
 
-    let tests = Command::new("tock/tools/qemu/riscv32-softmmu/qemu-system-riscv32")
+    let tests = Command::new("tock/tools/qemu-build/riscv32-softmmu/qemu-system-riscv32")
         .arg("-M")
         .arg("sifive_e,revb=true")
         .arg("-kernel")
diff --git a/tock b/tock
index 957a890..3218d5b 160000
--- a/tock
+++ b/tock
@@ -1 +1 @@
-Subproject commit 957a890e97550db00ca38407d93d2896d2724ec5
+Subproject commit 3218d5baa8459537b5fcfdbe8b5bc967a0f4a41e
diff --git a/tools/flash.sh b/tools/flash.sh
index cee7571..56ffb88 100755
--- a/tools/flash.sh
+++ b/tools/flash.sh
@@ -70,5 +70,10 @@
 	exit 0
 fi
 
+if ! [ -x "$(command -v tockloader)" ]; then
+    echo "Skipping flashing as tockloader isn't installed"
+    exit 0
+fi
+
 tockloader uninstall ${tockloader_flags} || true
 tockloader install ${tockloader_flags} "${tab_file_name}"