From cc9f7708c910ed9fa2a2d7d1db97fdb1b182f8a4 Mon Sep 17 00:00:00 2001 From: Andre Richter Date: Wed, 1 Jan 2020 23:38:27 +0100 Subject: [PATCH] Add testing to workflows --- .github/workflows/test_integration.yml | 40 ++++++++++++++++++++++++++ .github/workflows/test_unit.yml | 40 ++++++++++++++++++++++++++ README.md | 4 +-- utils/helpers/tutorial_folders.rb | 10 +++++-- utils/ready_for_publish.rb | 8 ++++-- utils/test_integration_all.rb | 30 +++++++++++++++++++ utils/test_unit_all.rb | 23 +++++++++++++++ 7 files changed, 149 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/test_integration.yml create mode 100644 .github/workflows/test_unit.yml create mode 100755 utils/test_integration_all.rb create mode 100755 utils/test_unit_all.rb diff --git a/.github/workflows/test_integration.yml b/.github/workflows/test_integration.yml new file mode 100644 index 00000000..84d4b858 --- /dev/null +++ b/.github/workflows/test_integration.yml @@ -0,0 +1,40 @@ +name: Integration-Tests + +on: + push: + branches: + - master + paths-ignore: + - 'utils/**' + - 'doc/**' + - 'docker/**' + pull_request: + branches: + - master + paths-ignore: + - 'utils/**' + - 'doc/**' + - 'docker/**' + schedule: + - cron: '0 5 * * *' + +jobs: + build: + name: Run integration tests + runs-on: ubuntu-18.04 + + steps: + - uses: actions/checkout@v1 + - name: Set up Ruby 2.x + uses: actions/setup-ruby@v1 + with: + ruby-version: 2.x + - name: Set up Rust nightly + run: | + rustup self update + rustup toolchain install nightly --component rust-src llvm-tools-preview + rustup default nightly + cargo install cargo-xbuild cargo-binutils + - name: Make all + run: | + ruby utils/test_integration_all.rb diff --git a/.github/workflows/test_unit.yml b/.github/workflows/test_unit.yml new file mode 100644 index 00000000..cd912565 --- /dev/null +++ b/.github/workflows/test_unit.yml @@ -0,0 +1,40 @@ +name: Unit-Tests + +on: + push: + branches: + - master + paths-ignore: + - 'utils/**' + - 'doc/**' + - 'docker/**' + pull_request: + branches: + - master + paths-ignore: + - 'utils/**' + - 'doc/**' + - 'docker/**' + schedule: + - cron: '0 5 * * *' + +jobs: + build: + name: Run unit tests + runs-on: ubuntu-18.04 + + steps: + - uses: actions/checkout@v1 + - name: Set up Ruby 2.x + uses: actions/setup-ruby@v1 + with: + ruby-version: 2.x + - name: Set up Rust nightly + run: | + rustup self update + rustup toolchain install nightly --component rust-src llvm-tools-preview + rustup default nightly + cargo install cargo-xbuild cargo-binutils + - name: Make all + run: | + ruby utils/test_unit_all.rb diff --git a/README.md b/README.md index 30439119..0931a2de 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Operating System development tutorials in Rust on the Raspberry Pi -![](https://github.com/rust-embedded/rust-raspi3-OS-tutorials/workflows/BSP-RPi3/badge.svg) ![](https://github.com/rust-embedded/rust-raspi3-OS-tutorials/workflows/BSP-RPi4/badge.svg) +![](https://github.com/rust-embedded/rust-raspi3-OS-tutorials/workflows/BSP-RPi3/badge.svg) ![](https://github.com/rust-embedded/rust-raspi3-OS-tutorials/workflows/BSP-RPi4/badge.svg) ![](https://github.com/rust-embedded/rust-raspi3-OS-tutorials/workflows/Unit-Tests/badge.svg) ![](https://github.com/rust-embedded/rust-raspi3-OS-tutorials/workflows/Integration-Tests/badge.svg) ## ℹ️ Introduction @@ -100,7 +100,7 @@ power over the dedicated power-USB. Raspberry is getting _really_ comfortable. In this tutorial, a so-called `chainloader` is developed, which will be the last file you need to manually copy on the SD card for a while. It will enable you to load the tutorial - kernels during boot on demand over `UART`. + kernels during boot on demand over `UART`. ![UART wiring diagram](doc/wiring.png) diff --git a/utils/helpers/tutorial_folders.rb b/utils/helpers/tutorial_folders.rb index 7adaa612..05020101 100755 --- a/utils/helpers/tutorial_folders.rb +++ b/utils/helpers/tutorial_folders.rb @@ -3,14 +3,14 @@ # SPDX-License-Identifier: MIT OR Apache-2.0 # -# Copyright (c) 2018-2019 Andre Richter +# Copyright (c) 2018-2020 Andre Richter require 'fileutils' WITH_EXTRA = '[X0-9]' NO_EXTRA = '[0-9]' -def tutorial_folders(with_extra = true) +def tutorial_folders(with_extra = true, testable = false) crates = Dir['*/Cargo.toml'] crates.delete_if do |x| @@ -19,6 +19,12 @@ def tutorial_folders(with_extra = true) !/[#{s}][0-9]/.match?(x[0..1]) end + if testable + crates.delete_if do |x| + x[0..1].to_i < 13 + end + end + crates.sort! end diff --git a/utils/ready_for_publish.rb b/utils/ready_for_publish.rb index 91184ef8..5de71f5e 100755 --- a/utils/ready_for_publish.rb +++ b/utils/ready_for_publish.rb @@ -3,14 +3,16 @@ # SPDX-License-Identifier: MIT OR Apache-2.0 # -# Copyright (c) 2018-2019 Andre Richter +# Copyright (c) 2018-2020 Andre Richter require_relative 'clean_all' require_relative 'clippy_all' +require_relative 'diff_all' require_relative 'fmt_all' require_relative 'make_all' require_relative 'sanity_checks' -require_relative 'diff_all' +require_relative 'test_integration_all' +require_relative 'test_unit_all' clean_all fmt_all @@ -20,6 +22,8 @@ clippy_all clean_all make_all +test_unit_all +test_integration_all system('cd X1_JTAG_boot && bash update.sh') diff_all clean_all diff --git a/utils/test_integration_all.rb b/utils/test_integration_all.rb new file mode 100755 index 00000000..798a1b1a --- /dev/null +++ b/utils/test_integration_all.rb @@ -0,0 +1,30 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# SPDX-License-Identifier: MIT OR Apache-2.0 +# +# Copyright (c) 2018-2020 Andre Richter + +require 'fileutils' +require_relative 'helpers/tutorial_folders.rb' + +def run_tests + Dir['tests/*.rs'].sort.each do |int_test| + int_test = int_test.delete_prefix!('tests/').delete_suffix('.rs') + exit(1) unless system("TEST=#{int_test} make test") + end +end + +def test_integration_all + crates = tutorial_folders(false, true) + + crates.each do |x| + tut = File.dirname(x) + Dir.chdir(tut) do + puts "\n\n" + tut.to_s + "\n\n" + run_tests + end + end +end + +test_integration_all if $PROGRAM_NAME == __FILE__ diff --git a/utils/test_unit_all.rb b/utils/test_unit_all.rb new file mode 100755 index 00000000..3f77d2e5 --- /dev/null +++ b/utils/test_unit_all.rb @@ -0,0 +1,23 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# SPDX-License-Identifier: MIT OR Apache-2.0 +# +# Copyright (c) 2018-2020 Andre Richter + +require 'fileutils' +require_relative 'helpers/tutorial_folders.rb' + +def test_unit_all + crates = tutorial_folders(false, true) + + crates.each do |x| + x = File.dirname(x) + Dir.chdir(x) do + puts "\n\n" + x.to_s + "\n\n" + exit(1) unless system('TEST=unit make test') + end + end +end + +test_unit_all if $PROGRAM_NAME == __FILE__