Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI/CD basic implementation based on GitHub Actions #167

Merged
merged 68 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from 67 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
d2b1827
workflows/push.yml - add build action
ia Mar 22, 2024
08f7e99
workflow/push.yml - add sudo for apt
ia Mar 22, 2024
bd085c8
workflow/push.yml - remove libc:i386 from deps
ia Mar 22, 2024
ae75fc0
workflow/push.yml - fix git safe.directory paths
ia Mar 22, 2024
a0a7a6d
workflow/push.yml - debugging
ia Mar 22, 2024
f4c8063
workflow/push.yml - remove git exception since applied anyway
ia Mar 22, 2024
0c85199
workflow/push.yml - debugging hfw-rev.py on GH build server
ia Mar 22, 2024
264cea6
hydrafw-revision.py: adopt script for GitHub actions CI build env
ia Mar 22, 2024
071a6ce
hydrafw-revision.py: print default revision/0.0 if revision tag is no…
ia Mar 22, 2024
25f7953
workflow/push.yml - fix artifact path for hydrafw.dfu
ia Mar 22, 2024
aa9ef1f
workflow/push.yml - set ubuntu 18.04 as env since 22.04 includes tool…
ia Mar 22, 2024
6c09da2
workflow/push.yml - set ubuntu 18.04 as env since 22.04 includes tool…
ia Mar 22, 2024
55543db
workflow/push.yml - remove sudo for apt
ia Mar 22, 2024
2656fa4
workflow/push.yml - add apt repo configuration
ia Mar 22, 2024
3e54f15
workflow/push.yml - debugging apt
ia Mar 22, 2024
e58704f
workflow/push.yml - add yes to apt for non-interaction
ia Mar 22, 2024
4505071
workflow/push.yml - downgrade to checkoutV3 since V4 is not compatibl…
ia Mar 22, 2024
7f7b2c1
workflow/push.yml - add git
ia Mar 22, 2024
479098c
workflow/push.yml - remove submodule keyword
ia Mar 22, 2024
a8de287
hydrafw-revision.py: add exception
ia Mar 22, 2024
79c01cb
hydrafw-revision.py: fix exception
ia Mar 22, 2024
640262a
workflow/push.yml - add make
ia Mar 22, 2024
57085cf
workflow/push.yml - add git submodules
ia Mar 22, 2024
fcccefd
workflow/push.yml - use debian
ia Mar 22, 2024
d31b06b
workflow/push.yml - set ownership
ia Mar 22, 2024
ef1228f
workflow/push.yml - cleanup build steps
ia Mar 22, 2024
2316b65
workflow/push.yml - try build run without container
ia Mar 23, 2024
a2839cb
workflow/push.yml - revert run with container
ia Mar 23, 2024
78deddc
hydrafw-revision.py: testing build without exception
ia Mar 23, 2024
6bd7044
workflow/push.yml - revert revision output to test
ia Mar 23, 2024
837b18c
workflow/push.yml - remove git package from deps
ia Mar 23, 2024
37756d4
workflow/push.yml - revert git package to deps
ia Mar 23, 2024
8397b41
workflow/push.yml - test without apt package db update
ia Mar 23, 2024
e2244cc
workflow/push.yml - revert apt package db update
ia Mar 23, 2024
bca2196
workflow/push.yml - test reformatting
ia Mar 23, 2024
3dc8cc1
workflow/push.yml - fix model name for matrix strategy
ia Mar 23, 2024
75ecfc6
workflow/push.yml - try to set model in one line
ia Mar 23, 2024
72f33f0
workflow/push.yml - add python3 to deps
ia Mar 23, 2024
46cde8e
scripts/env.sh - add script to enroll reference toolchain
ia Mar 27, 2024
9b752c8
workflow/push.yml - remove host toolchain deps
ia Mar 27, 2024
c0932ca
workflow/push.yml - add reference toolchain install and configuration
ia Mar 27, 2024
c242382
workflow/push.yml - remove debian container
ia Mar 27, 2024
d527c73
workflow/push.yml - enable verbosity build by default
ia Mar 27, 2024
a94c477
workflow/push.yml - enable sudo mode for host packages operations
ia Mar 27, 2024
30a7fe2
workflow/push.yml - fix steps order to download toolchain only after …
ia Mar 27, 2024
f4e4e84
workflow/push.yml - remove ownership tweak (needed only for container)
ia Mar 27, 2024
d4ec89d
workflow/push.yml - add package deps explicitly
ia Mar 27, 2024
a0bf4d0
workflow/push.yml - output toolchain version and its dirs right befor…
ia Mar 27, 2024
6159c58
scripts/env.sh - add a couple of comments with clarifications
ia Mar 27, 2024
7118e55
workflow/push.yml - testing suggestion from Baldanos to pass tags for…
ia Mar 27, 2024
595a6e1
scripts/env.sh - debugging git meta on github builds
ia Mar 27, 2024
044e0bf
scripts/env.sh - experiments with git meta on github builds
ia Mar 27, 2024
45cfe1f
workflow/push.yml - Changing Stuff and Seeing What Happens
ia Mar 27, 2024
2744d28
workflow/push.yml - try to fetch meta about branches as well
ia Mar 27, 2024
9166842
scripts/env.sh - add dot to git command
ia Mar 27, 2024
c2fdf2b
scripts/env.sh - google driven development
ia Mar 27, 2024
53e5b48
scripts/env.sh - add more output of git meta
ia Mar 27, 2024
3a25617
workflow/push.yml - remove wrong option
ia Mar 27, 2024
50c1762
scripts/env.sh - trying extract git log to count 22
ia Mar 27, 2024
1e882a1
scripts/env.sh - keep trying
ia Mar 27, 2024
95fe104
scripts/env.sh - testing git tags and commit IDs on github again
ia Mar 29, 2024
116ec76
hydrafw-version.py - taking into consideration original sha id before…
ia Mar 29, 2024
b0f78b2
hydrafw-version.py - import missed re module
ia Mar 29, 2024
11c05b3
hydrafw-version.py: add brief comments not to forget whats going on here
ia Apr 2, 2024
4390579
scripts/env.sh: remove printf-like debugging for git meta info
ia Apr 2, 2024
e7a53f1
scripts/env.sh: add deletion of temp files
ia Apr 2, 2024
9d77d8c
scripts/env.sh: add self-explanatory output help for user if its loca…
ia Apr 2, 2024
df35e5b
workflow/push.yml - remove printf-like step to show revision during d…
ia Apr 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: CI


on:
push:
branches:
- master
pull_request:
branches:
- master


jobs:
build:
runs-on: ubuntu-22.04
strategy:
matrix:
model: [ "hydrafw" ]
fail-fast: true

steps:
- name: Update package cache
run: sudo apt update -y

- name: Install packages
run: sudo apt install -y --no-install-recommends --no-install-suggests bash coreutils tar bzip2 git make python3 python3-pip

- name: Install python modules
run: python3 -m pip install GitPython intelhex --upgrade

- uses: actions/checkout@v4
with:
submodules: true
ia marked this conversation as resolved.
Show resolved Hide resolved
fetch-tags: true
fetch-depth: 0

- name: Set git meta info
run: echo "GITHUB_CI_PR_SHA=${{github.event.pull_request.head.sha}}" >> "${GITHUB_ENV}"

- name: Install standalone reference GCC toolchain
run: bash scripts/env.sh

- name: Build ${{ matrix.model }}
run: source build.env && arm-none-eabi-gcc --version && arm-none-eabi-gcc -print-search-dirs && python3 src/build-scripts/hydrafw-revision.py && make V=1 -j$(nproc) -C src/
ia marked this conversation as resolved.
Show resolved Hide resolved

- name: Archive ${{ matrix.model }} artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.model }}
path: |
src/build/${{ matrix.model }}.dfu
if-no-files-found: error


33 changes: 33 additions & 0 deletions scripts/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
#set -x
set -e

# This script is used to enroll toolchain with GitHub Actions for CI/CD purposes
# But this script can be used as reference to install recommended toolchain for building hydrafw.dfu locally as well

MD5SUM=8a4a74872830f80c788c944877d3ad8c
TARBALL=gcc-arm-none-eabi-4_9-2015q3-20150921-linux.tar.bz2
TARDIR=gcc-arm-none-eabi-4_9-2015q3
LINK=https://launchpad.net/gcc-arm-embedded/4.9/4.9-2015-q3-update/+download/"${TARBALL}"
CURDIR="$(pwd)"

echo "${MD5SUM} ${TARBALL}" > md5.txt
wget "${LINK}"
md5sum -c md5.txt
rm md5.txt

tar xvjf "${TARBALL}"
rm "${TARBALL}"

if [ -n "${GITHUB_CI_PR_SHA}" ]; then
# This is for GitHub Actions CI/CD tooling only
echo "export PATH=\"${CURDIR}/${TARDIR}/bin\":\"\${PATH}\"" > build.env
else
# And this is for local install
echo ""
echo "Add a line like"
echo "export PATH=\"${CURDIR}/${TARDIR}/bin\":\"\${PATH}\""
echo "to your ~/.profile and/or ~/.bashrc and run the line to enable toolchain as default one for arm-none-eabi-* target"
echo ""
fi;

5 changes: 4 additions & 1 deletion src/build-scripts/hydrafw-revision.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@

git=Repo(search_parent_directories=True).git
version = git.describe(tags=True,always=True,dirty=True,long=True)
print(r.search(version).group(1))
if r.search(version):
print(r.search(version).group(1))
else:
print("0.0")
11 changes: 10 additions & 1 deletion src/build-scripts/hydrafw-version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env python3

import sys
import os
import re
from optparse import OptionParser
from datetime import *
from git import *
Expand All @@ -14,7 +16,14 @@
if len(args)==1:
sys.stdout = open(args[0], 'w')
git=Repo(search_parent_directories=True).git
print('#define HYDRAFW_GIT_TAG "' + git.describe(tags=True,always=True,dirty=True,long=True) + '"')
vermagic=git.describe(tags=True,always=True,dirty=True,long=True)
if os.environ.get("GITHUB_CI_PR_SHA", "") != "":
# if GITHUB_CI_PR_SHA is set, then it's GitHub Actions build, so workaround to set a valid tag is required
sha_id=os.environ["GITHUB_CI_PR_SHA"][:7]
print('#define HYDRAFW_GIT_TAG "' + re.sub('-g.*$', '-g' + sha_id, vermagic) + '"')
else:
# If it's local build, then set "normal" tag
print('#define HYDRAFW_GIT_TAG "' + vermagic + '"')
print('#define HYDRAFW_CHECKIN_DATE "' + git.show(['-s', '--pretty=format:%ai']).partition(' ')[0] + '"')
else:
parser.print_help()
Expand Down