Skip to content

Commit

Permalink
Add CI (#20)
Browse files Browse the repository at this point in the history
Add CI, including supporting shell scripts
  • Loading branch information
MichaelStubbings authored Sep 16, 2021
1 parent 0ee916e commit b1b70a6
Show file tree
Hide file tree
Showing 8 changed files with 289 additions and 3 deletions.
19 changes: 19 additions & 0 deletions .github/scripts/GNU-toolchain.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
# Installs and extracts a GNU toolchain based on the systems architecture

PLATFORM=$1

# ARM GNU Toolchain
# Determine which toolchain to use
if [ "$PLATFORM" == "zynq" ]; then
TOOLCHAIN=https://developer.arm.com/-/media/Files/downloads/gnu-a/10.2-2020.11/binrel/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf.tar.xz
elif [ "$PLATFORM" == "zynqmp" ]; then
TOOLCHAIN=https://developer.arm.com/-/media/Files/downloads/gnu-a/10.2-2020.11/binrel/gcc-arm-10.2-2020.11-x86_64-aarch64-none-linux-gnu.tar.xz
else >&2 echo "Error: Argument $PLATFORM must be either zynq or zynqmp"
exit 1
fi

# Download and extract toolchain
curl -o toolchain.tar.xz -L $TOOLCHAIN
tar -xf toolchain.tar.xz
rm toolchain.tar.xz
34 changes: 34 additions & 0 deletions .github/scripts/config-file-pbrootfs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
# Generates and populates CONFIG file for PandABlocks-rootfs repo.

PLATFORM=$1

# Determine the toolchain to use
if [ "$PLATFORM" == "zynq" ]; then
TOOLCHAIN=gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf
elif [ "$PLATFORM" == "zynqmp" ]; then
TOOLCHAIN=gcc-arm-10.2-2020.11-x86_64-aarch64-none-linux-gnu
else >&2 echo "Error: Argument $PLATFORM must be either zynq or zynqmp"
exit 1
fi

cat >> PandABlocks-rootfs/CONFIG << 'EOL'
# Location of rootfs builder
ROOTFS_TOP = $(GITHUB_WORKSPACE)/rootfs
# Where to find source files
TAR_FILES = $(GITHUB_WORKSPACE)/tar-files
# Target location for build
PANDA_ROOT = $(GITHUB_WORKSPACE)/build
EOL

cat >> PandABlocks-rootfs/CONFIG << EOL
# Toolchain used to build the target
TOOLCHAIN_ROOT = \$(GITHUB_WORKSPACE)/$TOOLCHAIN
# Whether the platform is zynq or zyqnmp
PLATFORM = $PLATFORM
EOL
12 changes: 12 additions & 0 deletions .github/scripts/config-file-rootfs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
# Generates and populates CONFIG file for rootfs repo.

cat >> rootfs/CONFIG.local << 'EOL'
TARGET = minimal
# This is the location where source and build files will be placed.
ROOTFS_ROOT = $(GITHUB_WORKSPACE)/build
# This is where all of the source tar files will be found.
TAR_DIRS = $(GITHUB_WORKSPACE)/tar-files
EOL
43 changes: 43 additions & 0 deletions .github/scripts/tar-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
# Installs all sources relevant to the rootfs build as tar files

# Create the tar-files directory
mkdir tar-files
cd tar-files

# If no argument is given
if [[ -z $1 ]]; then
# Install tar file dependencies
curl -OL https://github.com/libffi/libffi/releases/download/v3.3-rc2/libffi-3.3-rc2.tar.gz \
-OL https://ftp.gnu.org/gnu/nano/nano-2.4.1.tar.gz \
-o cothread-2-18.tar.gz -L https://github.com/dls-controls/cothread/archive/refs/tags/2-18.tar.gz \
-OL https://zlib.net/fossils/zlib-1.2.8.tar.gz \
-o ethtool-2.6.36.tar.gz -L https://sourceforge.net/projects/gkernel/files/ethtool/2.6.36/ethtool-2.6.36.tar.gz/download \
-OL https://infraroot.at/pub/mtd/mtd-utils-2.1.2.tar.bz2 \
-OL https://busybox.net/downloads/busybox-1.23.2.tar.bz2 \
-OL https://github.com/ralphlange/procServ/releases/download/V2.6.1-rc1/procServ-2.6.1-rc1.tar.gz \
-o procServ-2.6.0.tar.gz -L https://sourceforge.net/projects/procserv/files/2.6.0/procServ-2.6.0.tar.gz/download \
-OL https://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz \
-o e2fsprogs-1.46.2.tar.gz -L https://sourceforge.net/projects/e2fsprogs/files/e2fsprogs/v1.46.2/e2fsprogs-1.46.2.tar.gz/download \
-OL https://github.com/numpy/numpy/releases/download/v1.17.5/numpy-1.17.5.tar.gz \
-OL http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-4.2.8p15.tar.gz \
-OL https://matt.ucc.asn.au/dropbear/releases/dropbear-2015.67.tar.bz2 \
-OL https://ftp.gnu.org/gnu/readline/readline-6.3.tar.gz \
-OL https://busybox.net/downloads/busybox-1.33.1.tar.bz2 \
-o tornado-6.0.3.tar.gz -L https://github.com/tornadoweb/tornado/archive/refs/tags/v6.0.3.tar.gz \
-OL https://ftp.gnu.org/gnu/automake/automake-1.15.1.tar.gz \
-OL https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz \
-OL https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.0.2.tar.gz \
-OL https://ftp.gnu.org/gnu/m4/m4-1.4.19.tar.gz \
-OL https://files.pythonhosted.org/packages/11/0a/7f13ef5cd932a107cd4c0f3ebc9d831d9b78e1a0e8c98a098ca17b1d7d97/setuptools-41.6.0.zip \
-OL http://jdelvare.nerim.net/mirror/i2c-tools/i2c-tools-3.1.1.tar.bz2 \
-OL https://ftp.gnu.org/gnu/screen/screen-4.2.1.tar.gz \
-OL https://ftpmirror.gnu.org/libtool/libtool-2.4.6.tar.gz \
-OL https://ftp.gnu.org/gnu/ncurses/ncurses-6.1.tar.gz \
-OL https://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz

fi

# Install linux tar file dependencies
curl -o u-boot-xlnx-xilinx-v2020.2.2-k26.tar.gz -L https://github.com/Xilinx/u-boot-xlnx/archive/refs/tags/xilinx-v2020.2.2-k26.tar.gz \
-o linux-xlnx-xilinx-v2020.2.2-k26.tar.gz -L https://github.com/Xilinx/linux-xlnx/archive/refs/tags/xilinx-v2020.2.2-k26.tar.gz
104 changes: 104 additions & 0 deletions .github/workflows/code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Code CI

on:
push:
pull_request:

jobs:
build:
strategy:
matrix:
platform: ["zynq", "zynqmp"]

runs-on: ubuntu-latest
steps:

# Git repositories
- name: Checkout Source
uses: actions/checkout@v2
with:
path: PandABlocks-rootfs
# require history to get back to last tag for version number of branches
fetch-depth: 0

- name: Checkout rootfs builder
uses: actions/checkout@v2
with:
repository: dls-controls/rootfs
path: rootfs

# ARM GNU Toolchain
- name: Download Arm GNU toolchain - ${{ matrix.platform }}
run: bash PandABlocks-rootfs/.github/scripts/GNU-toolchain.sh ${{ matrix.platform }}

# Tar dependancies
- name: Download tar file dependencies
run: bash PandABlocks-rootfs/.github/scripts/tar-files.sh

# System dependencies
- name: Install system dependencies
run: |
sudo apt-get install -y libncurses5-dev expat
sudo pip install rst2pdf
#CONFIG files
- name: Generate CONFIG files - ${{ matrix.platform }}
run: |
bash PandABlocks-rootfs/.github/scripts/config-file-pbrootfs.sh ${{ matrix.platform }}
bash PandABlocks-rootfs/.github/scripts/config-file-rootfs.sh
# Verification of files/file structure
#- name: List workspace files
# run: |
# ls ${{ github.workspace }}
# echo " "
# ls PandABlocks-rootfs
# echo " "
# ls rootfs
# echo " "
# ls tar-files
# echo " "
# cat PandABlocks-rootfs/CONFIG
# echo " "
# cat rootfs/CONFIG.local

# Build
- name: Make zips
run: |
cd PandABlocks-rootfs
make zips
# Verification of build files
#- name: List build files
# run: ls build

# Artifacts
- name: Upload deps and boot build files
uses: actions/upload-artifact@v2
with:
name: deps&boot-${{ matrix.platform }}
path: |
build/deps*.zip
build/boot*.zip
release:
needs: [build]
runs-on: ubuntu-latest
# make a release on every tag
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
steps:
- uses: actions/download-artifact@v2
with:
name: deps&boot*
path: artifacts

- name: Github Release
# We pin to the SHA, not the tag, for security reasons.
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
uses: softprops/action-gh-release@2d72d869af3bf23602f9593a1e3fd739b80ac1eb # v0.1.12
with:
files: artifacts/*
body: See [Changelog](CHANGELOG.rst) for more details
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58 changes: 58 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Docs CI

on:
push:
pull_request:

jobs:
build:
runs-on: ubuntu-latest

steps:
# Git repositories
- name: Checkout Source
uses: actions/checkout@v2
with:
path: PandABlocks-rootfs
# require history to get back to last tag for version number of branches
fetch-depth: 0

# System dependencies (required for build)
- name: Install system dependencies
run: |
sudo pip install rst2pdf sphinx sphinx-rtd-theme --upgrade docutils==0.16
# CONFIG files
- name: Generate CONFIG files - zynq
run: |
sudo bash PandABlocks-rootfs/.github/scripts/config-file-pbrootfs.sh zynq
# Build
- name: Build Docs
run: |
cd PandABlocks-rootfs
make docs
- uses: rishabhgupta/split-by@v1
id: split
with:
string: ${{ github.ref }}
split-by: /

# Publish docs
- name: Move to versioned directory
# e.g. master or 0.1.2
run: |
mkdir PandABlocks-rootfs/.github/pages
mv build/build/html "PandABlocks-rootfs/.github/pages/${{ steps.split.outputs._2 }}"
- name: Publish Docs to gh-pages
# Only master and tags are published
if: "${{ github.repository_owner == 'dls-controls' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')) }}"
# We pin to the SHA, not the tag, for security reasons.
# https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
uses: peaceiris/actions-gh-pages@bbdfb200618d235585ad98e965f4aafc39b4c501 # v3.7.3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: PandABlocks-rootfs/.github/pages
keep_files: true
16 changes: 16 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Changelog
=========

All notable changes to this project will be documented in this file.

The format is based on `Keep a Changelog <https://keepachangelog.com/en/1.0.0/>`_,
and this project adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0.html>`_.


2.1_ - 2021-04-27
-----------------

- Start keeping a changelog


.. _2.1: https://github.com/PandABlocks/PandABlocks-rootfs/releases/tag/2.1
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@
try:
# Something like 1.5.0-3-g3ab26eb
release = subprocess.check_output([
"git", "describe", "--abbrev=7", "--dirty","--always", "--tags"])
"git", "describe", "--abbrev=7", "--dirty","--always", "--tags"], text=True)
except:
# No git, or not under a git repo
release = "0.0"

# The short X.Y version.
# The short X.Y version
version = ".".join(release.split(".")[:2])

# The language for content autogenerated by Sphinx. Refer to documentation
Expand Down Expand Up @@ -127,7 +127,7 @@
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
except ImportError:
# If theme not found, still go ahead with build.
print 'sphinx_rtd_theme not found, using default'
print('sphinx_rtd_theme not found, using default')

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand Down

0 comments on commit b1b70a6

Please sign in to comment.