diff --git a/.github/workflows/build-and-tests.yml b/.github/workflows/build-and-tests.yml index ba13511..e1f2e92 100644 --- a/.github/workflows/build-and-tests.yml +++ b/.github/workflows/build-and-tests.yml @@ -1,4 +1,4 @@ -name: build-and-test +name: general-tests concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..ed8a775 --- /dev/null +++ b/CHANGELOG.md @@ -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 + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e014ef8 --- /dev/null +++ b/Dockerfile @@ -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/ diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..5bc4571 --- /dev/null +++ b/VERSION @@ -0,0 +1,2 @@ +1.0.0 + diff --git a/docker_ctl.sh b/docker_ctl.sh new file mode 100755 index 0000000..56e5bbf --- /dev/null +++ b/docker_ctl.sh @@ -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 ' 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 diff --git a/firmware/ble5_simple_peripheral_cc2640r2lp_app/FlashROM_StackLibrary/makefile b/firmware/ble5_simple_peripheral_cc2640r2lp_app/FlashROM_StackLibrary/makefile index 09149f1..01a6183 100644 --- a/firmware/ble5_simple_peripheral_cc2640r2lp_app/FlashROM_StackLibrary/makefile +++ b/firmware/ble5_simple_peripheral_cc2640r2lp_app/FlashROM_StackLibrary/makefile @@ -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 ' ' diff --git a/local_actions.sh b/local_actions.sh new file mode 100755 index 0000000..6b3702c --- /dev/null +++ b/local_actions.sh @@ -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'