Skip to content

Commit

Permalink
removed common docker dependency and added version and changelog (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
dogusyuksel authored Dec 20, 2024
1 parent 57881e1 commit 09caffb
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 35 deletions.
50 changes: 16 additions & 34 deletions .github/workflows/build-and-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: build-and-test
name: general-tests

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand All @@ -7,46 +7,28 @@ concurrency:
on: [pull_request]

jobs:
build-and-test-build-job:
general-tests-job:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v4
with:
github-server-url: https://github.com/dogusyuksel/cc2640r2f_ble.git
lfs: true

- name: clone docker and linting
run: |
git clone https://github.com/dogusyuksel/embedded_docker.git docker
cp -rf docker/* .
git clone https://github.com/dogusyuksel/embedded_linting.git linting
- name: free space
run: |
./free_space.sh

- name: Login to Docker Hub
uses: docker/login-action@v3
- uses: dorny/paths-filter@v3
id: changes
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Project Docker
uses: docker/build-push-action@v5
with:
load: true
tags: |
${{ secrets.DOCKER_REPO }}:master
context: .
file: docker/Dockerfile
pull: true
push: false
provenance: false
filters: |
version:
- 'VERSION'
changelog:
- 'CHANGELOG.md'
- name: check version and changelog
if: steps.changes.outputs.version == 'false' || steps.changes.outputs.changelog == 'false'
run: |
exit 1
- name: Build Check
- name: build
run: |
./docker/sudo_run_docker.sh ${{ secrets.DOCKER_REPO }}:master "cd /workspace && source environment && cd firmware/ble5_simple_peripheral_cc2640r2lp_app && make -C ./FlashROM_StackLibrary/ clean && make -C ./FlashROM_StackLibrary/ all"
./local_actions.sh
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## 1.0.0

- CHANGELOG.md and VERSION added
- Break THE BIG docker dependency and new tiny Dockerfile created for this project specifically
- Fixed github actions
- Added some helper scripts

40 changes: 40 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM ubuntu:22.04
ARG DEBIAN_FRONTEND=noninteractive

USER root

RUN apt-get update && \
apt-get -y upgrade && \
apt-get -y --no-install-recommends install \
build-essential \
git \
git-core \
git-lfs \
python3-dbg \
python3-dev \
python3-pip \
python3-pexpect \
python3-git \
python3-jinja2 \
python3-subunit \
vim \
cmake \
gcc-multilib \
g++-multilib \
software-properties-common \
language-pack-en-base \
wget \
clang-format \
unzip && \
apt-get -y clean

RUN git config --global --add safe.directory /workspace

RUN cd / && mkdir thirdparty && \
git clone https://github.com/dogusyuksel/embedded_linting.git /thirdparty/linting && \
git clone https://github.com/STMicroelectronics/OpenOCD.git /thirdparty/openocd && \
git clone https://github.com/dogusyuksel/ti_cc2640r2f_sdk.git /thirdparty/ti_cc2640r2f_sdk

CMD ["/bin/bash"]

WORKDIR /workspace/
2 changes: 2 additions & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1.0.0

67 changes: 67 additions & 0 deletions docker_ctl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash

if [ "$#" -eq 1 ]; then
if [ "$1" = "-h" ]; then
echo "USAGE:"
echo " '-b' to build new docker (optional)"
echo " '-c <command>' to run command (optional)"
echo " '-s' to execute docker in root (optional)"
exit 0
fi
fi

PWD=`pwd`
BASENAME=`basename "$PWD"`
preferred_name=$BASENAME":latest"

# Default values:
build_docker=false
is_sudo=false
command=""

# It's the : after d that signifies that it takes an option argument.

while getopts bsc: opt; do
case $opt in
b) build_docker=true ;;
s) is_sudo=true ;;
c) command=$OPTARG ;;
*) echo 'error in command line parsing' >&2
exit 1
esac
done

shift "$(( OPTIND - 1 ))"

"$build_docker" && echo 'Got the -b option'
"$is_sudo" && echo 'Got the -s option'
printf 'Option -c: %s\n' "$command"

if [ "$build_docker" = "true" ]; then
docker build -t $preferred_name .
fi

docker images | grep $BASENAME
if [ "$?" -ne 0 ]; then
echo "it means there is no built docker, cannot proceed"
exit 1
fi

# here, we probably have the docker, then run it

if [ "$command" != "" ]; then
echo "command running"
if [ "$is_sudo" = "true" ]; then
docker run --rm -t --net=host -v $(pwd):/workspace --entrypoint=/bin/bash $preferred_name -c "$command"
else
docker run --rm -t --net=host -v $(pwd):/workspace -v /etc/passwd:/etc/passwd:ro -v /etc/group:/etc/group:ro -u $(id -u ${USER}):$(id -g ${USER}) --entrypoint=/bin/bash $preferred_name -c "$command"
fi
exit 0
fi

# if no command run, lets start the docker for personal use
if [ "$is_sudo" = "true" ]; then
docker run --rm -it --net=host -v $(pwd):/workspace --entrypoint=/bin/bash $preferred_name
else
docker run --rm -it --net=host -v $(pwd):/workspace -v /etc/passwd:/etc/passwd:ro -v /etc/group:/etc/group:ro -u $(id -u ${USER}):$(id -g ${USER}) --entrypoint=/bin/bash $preferred_name
fi
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ clean:
-@echo ' '

linting:
../../../linting/format_check.sh ../
/thirdparty/linting/format_check.sh /workspace/ble5_simple_peripheral_cc2640r2lp_app/Application
-@echo 'Finished linting'
-@echo ' '

Expand Down
4 changes: 4 additions & 0 deletions local_actions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

# important!! first call must have '-b' option
./docker_ctl.sh -b -s -c 'cd /workspace && source environment && cd firmware/ble5_simple_peripheral_cc2640r2lp_app && make -C ./FlashROM_StackLibrary/ clean && make -C ./FlashROM_StackLibrary/ all'

0 comments on commit 09caffb

Please sign in to comment.