Skip to content

philippdiethelm/action-build-stm32cubeide-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Demo for action-build-stm32cubeide

The demo project

Target version for this action is STM32CubeIde 1.12.1.
The demo project is an "empty" STM32 "C" project generated by the IDE using File/New/STM32 Project in STM32CubeIDE and NUCLEO-L412KB as the board in Board selector.

How to add the workflow to your project

  • Copy the file autobild.yml file into your project under .github/workflows.
  • Edit the artifact name in the generate-name step.
  • Set project-path: variable to point to the path of the .project file to import. In the example its '.' e.g. the repository root.
  • Set project-target: variable to the project name as displayed in the IDE. In the example it is 'demo_project'.
  • You may want to customize when the action runs.
    For example if you only want to run the action when something in the projects subdirectory changes:
    on:
      push:
        paths: "projects/**"
  • Add the yml file to git, commit and push to github
  • Test

Brief workflow description

  1. Derive artifact file name from github.sha and github.ref_name variables.
    Artifact will be named demo_project.REF_NAME.SHORT_SHA.zip
    e.g. demo_project.main.dc8af4b8.zip for main builds
    or demo_project.v1.0.0.f00dface.zip for the tag v1.0.0

  2. Checkout the source

  3. Prepare git in container.
    This is required for generating the gitid.h from the STM32 build environment else it complains with kind of safe_directory error.

  4. Import and build the project using the action-build-stm32cubeide action

  5. Create and upload artifact demo_project.REF_NAME.SHORT_SHA.zip containing:
    gitid.h
    Debug/demo_project.elf
    Debug/demo_project.list
    Release/demo_project.elf
    Release/demo_project.list

Where to find the artifacts

The uploaded build artifacts can then be found here

image

image

image

Run the workflow locally

The github workflow can be run locally by using act and docker.
The following setup worked for me under Ubuntu 22.04.

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.2 LTS
Release:	22.04
Codename:	jammy

Install the tools

# Start in home directory
$ cd
$ pwd
/home/user

# Install act into ~/bin
$ curl -s https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash

# Install docker
$ sudo apt-get install docker.io

And then fix some issues...

# Fix docker permissions
$ sudo addgroup --system docker
$ sudo adduser $USER docker

# Restart docker
$ sudo systemctl restart docker

logout and back in to apply the changes.

# Check that docker is running
$ sudo systemctl status docker
● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2023-07-25 20:38:50 CEST; 52s ago
...
# Run docker hello world
$ docker run hello-world
...
Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Run the workflow

$ act
[Build/build] πŸš€  Start image=catthehacker/ubuntu:act-latest
[Build/build]   🐳  docker pull image=catthehacker/ubuntu:act-latest platform= username= forcePull=true
[Build/build]   🐳  docker create image=catthehacker/ubuntu:act-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[]
[Build/build]   🐳  docker run image=catthehacker/ubuntu:act-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[]
[Build/build]   ☁  git clone 'https://github.com/philippdiethelm/action-build-stm32cubeide' # ref=v9.1
[Build/build]   ☁  git clone 'https://github.com/actions/upload-artifact' # ref=v3
[Build/build] ⭐ Run Main Generate Short SHA name
[Build/build]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/generate-shortsha.sh] user= workdir=
[Build/build]   βœ…  Success - Main Generate Short SHA name
[Build/build]   βš™  ::set-env:: SHORT_SHA=908b4528
[Build/build]   βš™  ::set-env:: REF_NAME=v1.0.0
[Build/build] ⭐ Run Main Generate artifact name
[Build/build]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/generate-name.sh] user= workdir=
| Short SHA is: 908b4528
| REF_NAME is: 'v1.0.0'
[Build/build]   βœ…  Success - Main Generate artifact name
[Build/build]   βš™  ::set-env:: artifact=demo_project.v1.0.0.908b4528
[Build/build] ⭐ Run Main Checkout repository
[Build/build]   🐳  docker cp src=/home/user/projekte/action-build-stm32cubeide-demo/. dst=/home/user/projekte/action-build-stm32cubeide-demo
[Build/build]   βœ…  Success - Main Checkout repository
[Build/build] ⭐ Run Main Fix git safe.directory in container
[Build/build]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/3] user= workdir=
[Build/build]   βœ…  Success - Main Fix git safe.directory in container
[Build/build] ⭐ Run Main Build the project
[Build/build]   🐳  docker build -t act-philippdiethelm-action-build-stm32cubeide-v9-1-dockeraction:latest /home/user/.cache/act/[email protected]/
[Build/build]   🐳  docker pull image=act-philippdiethelm-action-build-stm32cubeide-v9-1-dockeraction:latest platform= username= forcePull=false
[Build/build]   🐳  docker create image=act-philippdiethelm-action-build-stm32cubeide-v9-1-dockeraction:latest platform= entrypoint=[] cmd=["." "demo_project"]
[Build/build]   🐳  docker run image=act-philippdiethelm-action-build-stm32cubeide-v9-1-dockeraction:latest platform= entrypoint=[] cmd=["." "demo_project"]
| Create.
| Opening 'demo_project'.
| 18:44:38 **** Build of configuration Debug for project demo_project ****
| make -j20 all 
| echo "// Warning: Automatically generated file!" > ../gitid.h
| echo "// DO NOT EDIT or check into git!" >> ../gitid.h
| arm-none-eabi-gcc "../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c" -mcpu=cortex-m4 -std=gnu11 -g3 -DDEBUG -DUSE_HAL_DRIVER -DSTM32L412xx -c -I../Core/Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32L4xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.d" -MT"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.o" --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -o "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.o"

...

| arm-none-eabi-gcc -o "demo_project.elf" @"objects.list"   -mcpu=cortex-m4 -T"/home/user/projekte/action-build-stm32cubeide-demo/STM32L412KBUX_FLASH.ld" --specs=nosys.specs -Wl,-Map="demo_project.map" -Wl,--gc-sections -static --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -Wl,--start-group -lc -lm -Wl,--end-group
| Finished building target: demo_project.elf
|  
| arm-none-eabi-size   demo_project.elf 
|    text          data     bss     dec     hex filename
|   10452            20    1700   12172    2f8c demo_project.elf
| Finished building: default.size.stdout
|  
| arm-none-eabi-objdump -h -S  demo_project.elf  > "demo_project.list"
| Finished building: demo_project.list
|  
| 
| 18:44:40 Build Finished. 0 errors, 0 warnings. (took 1s.919ms)
| 
| 18:44:41 **** Build of configuration Release for project demo_project ****
| make -j20 all 
| echo "// Warning: Automatically generated file!" > ../gitid.h
| echo "// DO NOT EDIT or check into git!" >> ../gitid.h
| arm-none-eabi-gcc "../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c" -mcpu=cortex-m4 -std=gnu11 -DUSE_HAL_DRIVER -DSTM32L412xx -c -I../Core/Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32L4xx/Include -I../Drivers/CMSIS/Include -Os -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.d" -MT"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.o" --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -o "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.o"

...

| arm-none-eabi-gcc -o "demo_project.elf" @"objects.list"   -mcpu=cortex-m4 -T"/home/user/projekte/action-build-stm32cubeide-demo/STM32L412KBUX_FLASH.ld" --specs=nosys.specs -Wl,-Map="demo_project.map" -Wl,--gc-sections -static --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -Wl,--start-group -lc -lm -Wl,--end-group
| Finished building target: demo_project.elf
|  
| arm-none-eabi-size   demo_project.elf 
|    text          data     bss     dec     hex filename
|    6680            20    1700    8400    20d0 demo_project.elf
| Finished building: default.size.stdout
|  
| arm-none-eabi-objdump -h -S  demo_project.elf  > "demo_project.list"
| Finished building: demo_project.list
|  
| 
| 18:44:42 Build Finished. 0 errors, 0 warnings. (took 1s.509ms)
| 
[Build/build]   βœ…  Success - Main Build the project
[Build/build] ⭐ Run Main Upload Published Artifact
[Build/build]   🐳  docker cp src=/home/user/.cache/act/actions-upload-artifact@v3/ dst=/var/run/act/actions/actions-upload-artifact@v3/
[Build/build]   🐳  docker exec cmd=[node /var/run/act/actions/actions-upload-artifact@v3/dist/index.js] user= workdir=
[Build/build]   πŸ’¬  ::debug::followSymbolicLinks 'true'
[Build/build]   πŸ’¬  ::debug::implicitDescendants 'true'
[Build/build]   πŸ’¬  ::debug::omitBrokenSymbolicLinks 'true'
[Build/build]   πŸ’¬  ::debug::followSymbolicLinks 'true'
[Build/build]   πŸ’¬  ::debug::implicitDescendants 'true'
[Build/build]   πŸ’¬  ::debug::matchDirectories 'true'
[Build/build]   πŸ’¬  ::debug::omitBrokenSymbolicLinks 'true'
[Build/build]   πŸ’¬  ::debug::Search path '/home/user/projekte/action-build-stm32cubeide-demo/gitid.h'
[Build/build]   πŸ’¬  ::debug::Search path '/home/user/projekte/action-build-stm32cubeide-demo/Debug/demo_project.elf'
[Build/build]   πŸ’¬  ::debug::Search path '/home/user/projekte/action-build-stm32cubeide-demo/Debug/demo_project.list'
[Build/build]   πŸ’¬  ::debug::Search path '/home/user/projekte/action-build-stm32cubeide-demo/Release/demo_project.elf'
[Build/build]   πŸ’¬  ::debug::Search path '/home/user/projekte/action-build-stm32cubeide-demo/Release/demo_project.list'
[Build/build]   πŸ’¬  ::debug::File:/home/user/projekte/action-build-stm32cubeide-demo/gitid.h was found using the provided searchPath
[Build/build]   πŸ’¬  ::debug::File:/home/user/projekte/action-build-stm32cubeide-demo/Debug/demo_project.elf was found using the provided searchPath
[Build/build]   πŸ’¬  ::debug::File:/home/user/projekte/action-build-stm32cubeide-demo/Debug/demo_project.list was found using the provided searchPath
[Build/build]   πŸ’¬  ::debug::File:/home/user/projekte/action-build-stm32cubeide-demo/Release/demo_project.elf was found using the provided searchPath
[Build/build]   πŸ’¬  ::debug::File:/home/user/projekte/action-build-stm32cubeide-demo/Release/demo_project.list was found using the provided searchPath
| Multiple search paths detected. Calculating the least common ancestor of all paths
[Build/build]   πŸ’¬  ::debug::Using search path /home/user/projekte/action-build-stm32cubeide-demo/gitid.h
[Build/build]   πŸ’¬  ::debug::Using search path /home/user/projekte/action-build-stm32cubeide-demo/Debug/demo_project.elf
[Build/build]   πŸ’¬  ::debug::Using search path /home/user/projekte/action-build-stm32cubeide-demo/Debug/demo_project.list
[Build/build]   πŸ’¬  ::debug::Using search path /home/user/projekte/action-build-stm32cubeide-demo/Release/demo_project.elf
[Build/build]   πŸ’¬  ::debug::Using search path /home/user/projekte/action-build-stm32cubeide-demo/Release/demo_project.list
| The least common ancestor is /home/user/projekte/action-build-stm32cubeide-demo. This will be the root directory of the artifact
| With the provided path, there will be 5 files uploaded
[Build/build]   πŸ’¬  ::debug::Root artifact directory is /home/user/projekte/action-build-stm32cubeide-demo
| Starting artifact upload
| For more detailed logs during the artifact upload process, enable step-debugging: https://docs.github.com/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging#enabling-step-debug-logging
| Artifact name is valid!
[Build/build]   ❗  ::error::Unable to get ACTIONS_RUNTIME_TOKEN env variable
[Build/build]   ❌  Failure - Main Upload Published Artifact
[Build/build] exitcode '1': failure
[Build/build] 🏁  Job failed
Error: Job 'build' failed