Skip to content

Commit

Permalink
Final content for live course
Browse files Browse the repository at this point in the history
- Added Docker image documentation
- `course` script now includes guard warning about files present in project expansion directory and offers optional deletion to clear expansion directory
- Latest course project archive
  • Loading branch information
mkarlesky committed Dec 18, 2019
1 parent e6aece2 commit a070c4c
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 12 deletions.
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Dr. Surly’s School for Mad Scientists: Interaction Tests, Mocks & Refactoring in Embedded Software Docker Image
Unit testing environment with ARM cross compiler, Unity, CMock, Ceedling, and Qemu emulator

## Contents
* Testing tools
* Ceedling 0.29.1
* CMock 2.5.1
* Unity 2.5.0
* Environment
* arm-none-eabi-gcc 6.3.1
* Ruby 2.4.9
* QEMU 1.1.2 (modified)
* Course project

## Build

The project image is layered atop a base image. The project image contains the potentially changeable content of the testing tools and the project materials. If future content updates are necessary this produces a slim `docker pull` operation for students.

The base docker image contains the heavyweight, unchanging tools — gcc toolchain, Ruby, and our customized Qemu. All these are built from scratch or installed by package manager during image build. To limit the download size for students, this image should be squashed.

If the base image changes, it must be rebuilt first and then the project image must be rebuilt. If only the project image changes, only it must be rebuilt.

### Base Docker Image

Because of the Docker `--squash` option, this image must be built locally, manually tagged, and pushed to Docker Hub. Automated Docker Hub builds do not support the `--squash` option.

1. Update Dockerfile and/or assets.
1. Build locally… `./build/base/run.sh`
1. Tag locally `docker image tag throwtheswitch/drsurly-course2-base throwtheswitch/drsurly-course2-base:[tag]`
1. `docker push throwtheswitch/drsurly-course2-base:[tag]`

### Project Docker Image

1. Update Dockerfile and/or assets. If base image has changed, be sure to update the tagged version of the base image at the top of build/release/Dockerfile before building the project image.
1. For a local build… `./build/release/run.sh`. Local builds are optional or for development work. Ultimately, this build is automated at Docker Hub for tagging and release, triggered by Github commits.

## Usage

`docker run -it --rm -v <local project path>:/lab throwtheswitch/drsurly-course2[:tag]`

Binary file modified assets/awesomesauce2.zip
Binary file not shown.
45 changes: 33 additions & 12 deletions assets/course
Original file line number Diff line number Diff line change
@@ -1,40 +1,61 @@
#!/bin/bash

TMP="/tmp/project"
PROJECT_HOME="/lab"

# If no command line parameters given, provide usage banner
if [ $# -eq 0 ]
then
cat <<-____HERE
Usage: setup
setup Extract project to file system
setup Extract project to $PROJECT_HOME
... Future utility options TBD
____HERE
exit
fi


# Parameter check
if [ "$1" != "setup" ]; then
echo "Unrecognized parameter. Run with no parameters for help."
exit
fi

# Clear temporary directory just to be sure
rm -rf "$TMP"

# Check if expansion target directory has anything in it
if [ "$(ls -A $PROJECT_HOME)" ]; then
# Confirm deletion of contents of project folder
read -p "> $PROJECT_HOME is not empty (includes hidden files). Delete contents before extracting project [y/n]? " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo "> Clearing $PROJECT_HOME ..."
rm -rf "$PROJECT_HOME"/*
else
echo "> Project extraction cancelled."
exit
fi
fi

# Extract archive listing and regex to determine base directory of files
basedir=`unzip -l /home/drsurly/awesomesauce2.zip | grep -E -o 'mvandervoord[^/]+' | head -1`
BASEDIR=`unzip -l /home/drsurly/awesomesauce2.zip | grep -E -o 'mvandervoord[^/]+' | head -1`

# Extract the archive
echo "Extracting project"
unzip -q /home/drsurly/awesomesauce2.zip -d /tmp
echo "> Extracting project..."
unzip -q /home/drsurly/awesomesauce2.zip -d $TMP

# Delete any git junk -- first files and then directories
find /tmp -type f -iname ".git*" -delete
find /tmp -type d -name ".git" -exec rm -rf "{}" \;
find $TMP -type f -iname ".git*" -delete
find $TMP -type d -name ".git" -exec rm -rf "{}" \;

# Move extracted contents below $basedir to new base directory of /lab
mv /tmp/$basedir/* /lab
mv "$TMP/$BASEDIR"/* "$PROJECT_HOME"

chmod +x "$PROJECT_HOME"/start_lab

# Clean up /tmp
rm -rf /tmp/*
# Clean up temporary directory
rm -rf "$TMP"

echo "Done"
echo "See project contents in /lab"
echo "> Done."
echo "> See project contents in $PROJECT_HOME"

0 comments on commit a070c4c

Please sign in to comment.