From cc79fcb4cff30be21f1c3512e6571587ae426e9c Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Mon, 23 Dec 2019 18:36:10 +1100 Subject: [PATCH] Rough pass at builder --- .gitattributes | 2 + .gitignore | 129 +++++++++++----------- Dockerfile | 27 +++++ ci/buildAll.sh | 13 +++ ci/secrets/decrypt.sh | 16 +++ ci/secrets/encrypted/deployment.encrypted | 2 + codeship-services.yml | 8 ++ codeship-steps.yml | 11 ++ docker-compose.yml | 11 ++ start_dev.sh | 2 + 10 files changed, 158 insertions(+), 63 deletions(-) create mode 100644 .gitattributes create mode 100644 Dockerfile create mode 100644 ci/buildAll.sh create mode 100644 ci/secrets/decrypt.sh create mode 100644 ci/secrets/encrypted/deployment.encrypted create mode 100644 codeship-services.yml create mode 100644 codeship-steps.yml create mode 100644 docker-compose.yml create mode 100644 start_dev.sh diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..91030712 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Ignore all differences in line endings +* -crlf \ No newline at end of file diff --git a/.gitignore b/.gitignore index 3130b067..912dd158 100644 --- a/.gitignore +++ b/.gitignore @@ -1,63 +1,66 @@ -# Object files -*.o -*.ko -*.obj -*.elf -*.d -*.DS_Store -# Precompiled Headers -*.gch -*.pch - -# Libraries -*.lib -*.a -*.la -*.lo - -# Shared objects (inc. Windows DLLs) -*.dll -*.so -*.so.* -*.dylib - -# Executables -*.exe -*.out -*.app -*.i*86 -*.x86_64 -workspace/*.hex - -# Debug files -*.dSYM/ -*.su -workspace/ts100/Debug/* -workspace/.metadata/* - -workspace/ts100/.settings/language.settings.xml -workspace/ts100/.cproject -TS100/KiCad/TS100.bak -Logo GUI/TS100 Logo Editor/TS100 Logo Editor/obj/ -Logo GUI/TS100 Logo Editor/TS100 Logo Editor/bin/ -workspace/ts100/ts100.xml -workspace/ts100_old/* -*.cache -workspace/TS100/.settings/language.settings.xml -workspace/TS100A/Release/TS100A.map -workspace/TS100A/Release/TS100A.list -workspace/TS100A/Release/TS100A.hex -workspace/TS100A/.settings/language.settings.xml -workspace/TS100A/.metadata/ -Translation Editor/.vscode/ -Translation Editor/__pycache__/ -*.pyc -workspace/TS100/src/Translation.cpp -*.lst -*.mk -*.list -workspace/TS100/Release/ -workspace/TS100/Hexfile/ -workspace/RemoteSystemsTempFiles/ -workspace/TS100/.settings/ -workspace/TS100/TS80/ +# Object files +*.o +*.ko +*.obj +*.elf +*.d +*.DS_Store +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +workspace/*.hex + +# Debug files +*.dSYM/ +*.su +workspace/ts100/Debug/* +workspace/.metadata/* + +workspace/ts100/.settings/language.settings.xml +workspace/ts100/.cproject +TS100/KiCad/TS100.bak +Logo GUI/TS100 Logo Editor/TS100 Logo Editor/obj/ +Logo GUI/TS100 Logo Editor/TS100 Logo Editor/bin/ +workspace/ts100/ts100.xml +workspace/ts100_old/* +*.cache +workspace/TS100/.settings/language.settings.xml +workspace/TS100A/Release/TS100A.map +workspace/TS100A/Release/TS100A.list +workspace/TS100A/Release/TS100A.hex +workspace/TS100A/.settings/language.settings.xml +workspace/TS100A/.metadata/ +Translation Editor/.vscode/ +Translation Editor/__pycache__/ +*.pyc +workspace/TS100/src/Translation.cpp +*.lst +*.mk +*.list +workspace/TS100/Release/ +workspace/TS100/Hexfile/ +workspace/RemoteSystemsTempFiles/ +workspace/TS100/.settings/ +workspace/TS100/TS80/ +ci/artefacts/ +ci/secrets/unencrypted/ +codeship.aes diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..67f0a4b4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM ubuntu:rolling +MAINTAINER Ben V. Brown + +WORKDIR /build +# Setup the ARM GCC toolchain + +# Install any needed packages specified in requirements.txt +RUN apt-get update && \ + apt-get upgrade -y && \ + apt-get install -y \ + make \ + git \ + bzip2 \ + git \ + golang \ + python3 \ + wget && \ + apt-get clean && \ + wget -qO- https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/RC2.1/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2 | tar -xj + +# Add compiler to the path + +ENV PATH "/build/gcc-arm-none-eabi-9-2019-q4-major/bin:$PATH" +# Get the github release tool +RUN go get -u github.com/aktau/github-release +COPY . /build/source +COPY ./ci /build/ci diff --git a/ci/buildAll.sh b/ci/buildAll.sh new file mode 100644 index 00000000..b6fc3dc8 --- /dev/null +++ b/ci/buildAll.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -e +set -u + +mkdir -p /build/ci/artefacts + +# Build STM code +cd /build/source/workspace/TS100/ +bash ./build.sh || exit 1 +echo "All Firmware built" +# Copy out all the final resulting files we would like to store for the next op +cp -r /build/source/workspace/TS100/Hexfile/*.hex /build/ci/artefacts/ +cp -r /build/source/workspace/TS100/Hexfile/*.bin /build/ci/artefacts/ diff --git a/ci/secrets/decrypt.sh b/ci/secrets/decrypt.sh new file mode 100644 index 00000000..804a4e99 --- /dev/null +++ b/ci/secrets/decrypt.sh @@ -0,0 +1,16 @@ +#!/bin/bash +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +SECRETS="$DIR/encrypted/*.encrypted" +KEY="$DIR/../../codeship.aes" + +mkdir -p $DIR/unencrypted + +for f in $SECRETS +do + out="${f/.encrypted/.secret}" + out="${out/encrypted/unencrypted}" + echo $out + jet decrypt $f $out --key-path $KEY +done + +echo "Done" diff --git a/ci/secrets/encrypted/deployment.encrypted b/ci/secrets/encrypted/deployment.encrypted new file mode 100644 index 00000000..5fe104f7 --- /dev/null +++ b/ci/secrets/encrypted/deployment.encrypted @@ -0,0 +1,2 @@ +codeship:v2 +DUgOERb8iPVn95/DKIw9M7sgNjJlIlsaeE4PFV58tmmBu2sD1ooR7Y0L23bimC9a \ No newline at end of file diff --git a/codeship-services.yml b/codeship-services.yml new file mode 100644 index 00000000..aafb9325 --- /dev/null +++ b/codeship-services.yml @@ -0,0 +1,8 @@ +builder: + build: + context: . + dockerfile: Dockerfile + cached: true + encrypted_env_file: ci/secrets/encrypted/deployment.encrypted + volumes: + - ./ci:/ci diff --git a/codeship-steps.yml b/codeship-steps.yml new file mode 100644 index 00000000..1d102171 --- /dev/null +++ b/codeship-steps.yml @@ -0,0 +1,11 @@ +- type: parallel + name: Build the firmware + steps: + - name: build + service: builder + command: /build/ci/buildAll.sh + +- name: deploy + service: builder + command: /ci/deployRelease.sh + tag: master diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..e147e5ec --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +version: '3' +services: + builder: + stdin_open: true + tty: true + build: + context: . + command: /bin/bash + volumes: + - ./ci:/build/ci + - ./:/build/source diff --git a/start_dev.sh b/start_dev.sh new file mode 100644 index 00000000..2f1dda40 --- /dev/null +++ b/start_dev.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +docker-compose run --rm builder \ No newline at end of file