element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Code Exchange
  • Technologies
  • More
Code Exchange
Blog GitHub: automate Raspberry Pico project build verification with GitHub Actions
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Code Exchange to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 15 Jul 2024 11:52 AM Date Created
  • Views 616 views
  • Likes 6 likes
  • Comments 5 comments
  • doxygen
  • github.io
  • github
  • teseo_c++
Related
Recommended

GitHub: automate Raspberry Pico project build verification with GitHub Actions

Jan Cumps
Jan Cumps
15 Jul 2024

You can Make GitHub build your project. I'm using an Action to check out branches and build them, when a pull request is submitted.
I adapted an existing flow from the Raspberry organisation. Here's what it does

  • check out the branch that's the source for the pull request
  • check out Pico-SDK, the current development branch
  • install CMake
  • install the arm bare metal GNU toolchain
  • build the SDK
  • build the project
  • react on pull request creation on the main and develop branch.
  • make successful compilation a mandatory check for the pull request.

If the build fails, the pull request fails. That's what I try to achieve in this exercise:

  • developers can check in non-working code in their feature branches.
  • once ready to request merging it with one of the two protected branches (develop or main), code should meet quality requirements and should build.
    That's the moment that you deem your work done, and should be ready for a code review.
    If your code breaks the build at this point, you impact others - and maybe the production release. It's a fail.
  • Code reviewers don't have to spend time validating non-funcioning code.

The script I'm using is based on the Raspberrry MacOS build for Pico. I adapted it for Linux.

image

Script source of build.yml:

name: Build on ubuntu against pico-sdk develop
on:
  workflow_dispatch:
  #push:
  #  branches:
  #    - 'develop'
  #    - 'main'
  pull_request:
    types: [opened, reopened]
    branches:
      - 'develop'
      - 'main'

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    
      - name: Clean workspace
        run: |
          echo "Cleaning up previous run"
          rm -rf "${{ github.workspace }}"
          mkdir -p "${{ github.workspace }}"
      - name: Checkout pico_gps_teseo_i2c
        uses: actions/checkout@v4
        with:
          path: pico_gps_teseo

      - name: Checkout pico-sdk/develop
        uses: actions/checkout@v4
        with:
          repository: raspberrypi/pico-sdk
          ref: develop
          path: pico-sdk

      - name: Checkout pico-sdk submodules
      
        working-directory: ${{github.workspace}}/pico-sdk
        run: git submodule update --init
      - name: Install dependencies
        run: |
          sudo apt-get install cmake
          #curl -Lo gcc-arm-none-eabi.tar.bz2 "https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2?rev=78196d3461ba4c9089a67b5f33edf82a&hash=5631ACEF1F8F237389F14B41566964EC"
          #sudo mkdir /opt/gcc-arm-none-eabi
          #sudo tar xf gcc-arm-none-eabi.tar.bz2 --strip-components=1 -C /opt/gcc-arm-none-eabi
          #echo 'export PATH=$PATH:/opt/gcc-arm-none-eabi/bin' | sudo tee -a /etc/profile.d/gcc-arm-none-eabi.sh
          #export PATH=$PATH:/opt/gcc-arm-none-eabi/bin
          #export PICO_TOOLCHAIN_PATH=/opt/gcc-arm-none-eabi/bin
          #source /etc/profile
          #arm-none-eabi-gcc --version
          sudo apt install gcc-arm-none-eabi
          
      - name: Build Project

Excuses for the formatting. The code editor does not want to accept parts of the script. Click on this link for a better view.

When you create this script in the .github/workflows folder, it 'll kick off each time a pull request is opened for main or develop. But it will not impact the pull request.
If you want to make pull requests dependent on successful build, you 'll also have to create a ruleset for the branch.

On your repository's web page on GitHub, select settings -> Rules -> Rulesets.
If the branch(es) you want to protect don't have a ruleset yet, create one. Else you can update the existing one.

image

The first checkbox will take care that the branches you want to protect, can only accept commits via a pull request. When you work together as a team, it's good that branch owners can check code before it's merged in the code base.
The second check also adds the condition, that the build job must complete in good order.

A developer that submits a pull request, gets this page:

image

They don't have to wait for this to complete. They 'd get an email if it failed. Once the job is completed, the reviewer sees the screen capture I posted at the start of this blog. If the job was successful, code review and merge can happen.

How does it fit in my workflow:

I created another action earlier:  GitHub: automate project documentation with DoxyGen, and publish online after pushing commits . Together, the 2 automate a decent part of code management:

  • the build validation described here, when a pull request is made to development or main
  • when a pull request to main is accepted and merged by the branch manager (me :) ), the documentation is regenerated and published to github.io.

Future improvements:

I'm considering to let the job create a project release, when a new Version TAG is created in the repository. I'd have to make these changes:

  • add trigger on TAG creation event. Filter on tags that start with 'v'.
  • change the build type from Debug to Release
  • use a GitHub Action to create a release in the repository, and upload the .uf2 file as asset to that release.

Link to all posts.

  • Sign in to reply
  • Jan Cumps
    Jan Cumps 11 months ago in reply to Fred27

    I got the auto deploy working. All uf2s are automatically uploaded to nightly release, and an archive of the code generated, when a pull request to develop is done. Everything runs on gihub servers.

    github.com/.../nightly_development

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps 11 months ago

    I adapted the script, to install a newer GCC cross-platform compiler for ARM: /technologies/embedded/b/blog/posts/raspberry-pico-c-c-sdk---set-up-c-23-capable-toolchain?CommentId=cbbad4d0-3268-4255-b340-d908127abfbc

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 1 year ago in reply to colporteur

    It was above my head too until last weekend Slight smile

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • colporteur
    colporteur over 1 year ago

    JC it looks like you have been busy. Way above my head knowledge wise.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Fred27
    Fred27 over 1 year ago

    I think it's definitely worth creating an artifact with the uf2 file so it can be easily deployed to a device.

    If you want to go even further you could register your own self-hosted CI runner (maybe a Raspberry Pi) that downloads the uf2 file and deploys it to an attached Pico for testing on real hardware.
    docs.github.com/.../managing-self-hosted-runners

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube