Skip to content
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

Adding SDK Recursive Build Tool #15

Closed
wants to merge 10 commits into from

Conversation

IvanRuzavin
Copy link
Contributor

@IvanRuzavin IvanRuzavin commented Jul 25, 2024

Automated MCU Setup Building Tool with mikroSDK Support in NECTOStudio

Overview

This tool automates recursive setup builds for all MCUs, MCU cards, and Boards affected by changes to mikroSDK files. It ensures changes don't cause build failures, allowing safe merging to the master branch and live release.

Workflow Steps

1. Prepare Your Branch

  • Ensure your branch is up-to-date and all changes are pushed.

2. Draft a New Release

  • Go to mikrosdk_v2 Releases and draft a new release.
  • Set the target branch and create a new tag and release name (naming logic to be discussed).
  • Mark as pre-release and publish.

3. Update Release

  • Wait for the Release Asset Upload workflow to finish.
  • Edit the release and set it as the latest release instead of pre-release.

4. Index Latest Release

  • Go to actions, choose the "Index Latest Release" action, and run the workflow on the master branch with "Test" indexing.

5. If Adding MCU Card/Board

  • Update necto_db.db in your branch in the core_packages repo.
  • Repeat the release and indexing steps for the core_packages repo.

6. Run SDK Recursive Build

  • It should be triggered the moment you create a PR to main branch
  • If you want to trigger it manually, go to actions, choose "SDK Recursive Build," and run the workflow on your branch for changed files.

Results

  • The setup build results are printed during the "Run Recursive Build" job.
  • Artifacts (test-results archive) are available after job completion.

Detailed Workflow

1. Dependency Installation

  • Install all necessary dependencies and NECTO dev/live build to download indexed Test releases.

2. File Changes Detection

  • Fetch differences between the latest Test release and the previous Live release.
  • Classify changes by affected files: Boards (bsp/board/include/boards), MCU Cards (bsp/board/include/mcu_cards), MCUs (target), or general SDK files (other folders).

3. Classification Logic

  • Boards: Extract _MSDK_BOARD_NAME_ from board.cmake for SQL queries.
  • MCU Cards: Use folder name for SQL queries.
  • MCUs:
    • CMake: Extract regex for variables containing "MCU_".
    • Source Files: Search for nearest CMake and extract regex.
    • Header Files:
      • Common headers: Extract MCU name from folder structure.
      • Implementation headers: Check corresponding source folder’s CMake for usage.

4. Data Retrieval via SQL Queries

  • Fetch data for building using board names, card names, and MCU regexes.
  • If no data, retrieve all supported Boards, MCU Cards, and MCUs for the latest SDK.
  • Store unfound data as unused.

5. Build Execution

  • Determine necessary compilers and run SDK builds:
    • MCUs: Build with GENERIC Board.
    • MCU Cards: Build with all boards.
    • Boards: Build with all MCU cards.
  • Fail the job if any build fails.

6. Artifacts Collection

  • Collect and store JSON data with changes and build logs for any failed builds.

Additional Option

  • Build All: Option to disregard changes and run builds for everything, ensuring comprehensive verification.
  • Option to choose either Live or Dev NECTOStudio build for the workflow.

@IvanRuzavin IvanRuzavin added good first issue Good for newcomers enhancement New feature or request and removed good first issue Good for newcomers labels Jul 25, 2024
@IvanRuzavin IvanRuzavin changed the title Added install_necto.py and recursive_build.py scripts for recursiveBu… Adding SDK Recursive Build Tool Jul 25, 2024
sudo apt-get install libxcb-keysyms1-dev
sudo apt-get install libxkbcommon-x11-dev

- name: Install NECTO
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the workflow so that NECTO is installed after checking for changed files.

In other words install it only if there is a need to run the automated builds.

I assume you will need to split the recursive_build into two scripts.


for file in changes_dict['changed_files']:
# Ensure we handle paths correctly.
file = file.replace('\\', '/')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use pythons os.sep(), so there is no need to correct this for defferent OS'es

export BUILD_ALL=0
echo "Building only changed files."
fi
python -u scripts/recursive_build.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the option to skip the build entirely. Maybe a script parameter which checks a commit message variable or branch name.

@StrahinjaJacimovic
Copy link
Contributor

Moved to other repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants