Skip to content

Build libraries using Github Actions #78

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

AnthonyGrondin
Copy link
Collaborator

This PR adds a long-awaited feature; Build libraries using the CI.

When changes occur in esp-mbedtls-sys/, the gen xtask is triggered to rebuild the libraries, and then tests are executed against the current libraries. When pushing to main, the libraries are then committed and pushed to the main branch by the action.

Also, when labelling a PR with the rebuild-libs label, the CI is programmed to rebuild libraries and push them to the PR branch. When merging to main, since no changes will be detected, there won't be a second commit.

This enables rebuilding the libraries without needing to setup the build environment locally on a computer, allows contributors to bring changes to the underlying libraries, while we ensure they are rebuilt in a safe environment, and also allows users to pull back the build libraries to test them locally, if they don't want to set up the environment to build them locally.

Due to the current architecture, executing CI on a push outside of main is now disabled. Also, to make the action push the libraries, either the trigger has to be a push to main, or adding the label rebuild-libs to the PR, since GitHub doesn't support labels on branches directly, so we can't conditionally decide when to push or not, that way.

@AnthonyGrondin AnthonyGrondin added the rebuild-libs This label will force rebuilding the libraries and push them onto the current PR label Jun 23, 2025
@AnthonyGrondin AnthonyGrondin force-pushed the ci/build-libraries branch 2 times, most recently from ebb0c4d to c3f0d16 Compare June 23, 2025 20:03
@AnthonyGrondin
Copy link
Collaborator Author

This seems to need a little tweaking still; It used to work on my fork but when doing PRs across multiple repos, it hits permission issues.

@ivmarkov
Copy link
Collaborator

I'm not really very proficient in CI actions, but with that said, I did not notice anything outstanding. Once you resolve the permission issues, I suggest you push it.

One request I have, but that could definitely wait for the future is to also provide builds for the thumbv7em-none-eabi (NRF52XX) and thumbv6m-none-eabi (RP2040). This I would need if we are to use (esp-)mbedtls into openthread which I very much would like to (currently, openthread builds and ships its own copy of mbedtls which is a bit suboptimal if the user wants to depend on both esp-mbedtls and openthread, as certain rs-matter builds might).

But this can wait a bit. For that, the CI would need to download and install the ARM GCC toolchain.

Also, I would soon open a PR which is streamlining a bit the xtasks-based build of esp-mbedtls-sys, similar to how it is done in openthread. There, it is done per target triple, rather than per MCU.

@bjoernQ
Copy link
Collaborator

bjoernQ commented Jun 24, 2025

Anything we can change in regards to the permission problems?

- Add the possiblity to build the libraries using Github Actions, and
programatically push them to master or a branch
- Enable `rebuild-libs` label to force rebuild and push libraries to a
PR branch
@AnthonyGrondin
Copy link
Collaborator Author

Anything we can change in regards to the permission problems?

I've tried all possibilities and there isn't really a bypass due to how GitHub handles permissions for security.

So what I did, is add a condition to check if the PR CI is executed on the same base repo. If the PR is from a fork to an upstream, it'll still publish the artifacts in the job artifacts (if label is enabled), but it won't commit them.

So contributors have 2 possibilities:

  1. Download the artifacts, commit them on their branch then push them back
  2. Create a mirror PR from their feature branch to their main, and add the label on their PR. This will make the action push it there, and it will be reflected in the PR to upstream. I tested it and it works.

Nevertheless, pushing to master still works when we merge because we are doing the push on the same repo

@AnthonyGrondin AnthonyGrondin removed the rebuild-libs This label will force rebuilding the libraries and push them onto the current PR label Jun 24, 2025
@AnthonyGrondin
Copy link
Collaborator Author

I'm not really very proficient in CI actions, but with that said, I did not notice anything outstanding. Once you resolve the permission issues, I suggest you push it.

One request I have, but that could definitely wait for the future is to also provide builds for the thumbv7em-none-eabi (NRF52XX) and thumbv6m-none-eabi (RP2040). This I would need if we are to use (esp-)mbedtls into openthread which I very much would like to (currently, openthread builds and ships its own copy of mbedtls which is a bit suboptimal if the user wants to depend on both esp-mbedtls and openthread, as certain rs-matter builds might).

But this can wait a bit. For that, the CI would need to download and install the ARM GCC toolchain.

Also, I would soon open a PR which is streamlining a bit the xtasks-based build of esp-mbedtls-sys, similar to how it is done in openthread. There, it is done per target triple, rather than per MCU.

I don't have those boards and I don't have experience in building for them. I believe most of the CI is architecture agnostic so as you said, once we provide the builder for them, we just need the toolchain installed in CI and it should work.

@AnthonyGrondin AnthonyGrondin added the rebuild-libs This label will force rebuilding the libraries and push them onto the current PR label Jun 25, 2025
@AnthonyGrondin
Copy link
Collaborator Author

I updated the CI to include the new feature added in: esp-rs/xtensa-toolchain#41

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rebuild-libs This label will force rebuilding the libraries and push them onto the current PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants