From 73ab9621e4dac1a24fb76c4f2f4de24c742e28f6 Mon Sep 17 00:00:00 2001 From: M Starch Date: Thu, 25 Sep 2025 13:29:58 -0700 Subject: [PATCH] Ci zephyr (#4141) * Add reusable action and workflow for CI and set up * Add branch for testing * Call correct workflow * Remove superfluous input (tmp) * Switch to fprime-actions * Add with * Actions typo * Add plugin package installation * Add build stage * Fix container * Remove container * Trial of West * Add custom setup * Add push event * Fix event data mining for push * Fix push payload usage * Fix branch detection * Fix bash-foo * Fix resuable project CI * Add custom runner set up * Typo * Add intgration step * Fix archive download * Debug commands * Download after setup * Fix download path * adding workflow for pico2 zephyr * updated reusable workflow to clean up when done, otherwise garbase is left and it causes issues with subsequent runs * fixing formatting because it matters * Remove erroneous clean-up * sp * Add make space step * Fix review requests --------- Co-authored-by: Kevin F. Ortega --- .github/actions/spelling/expect.txt | 1 + .../ext-fprime-zephyr-reference-pico2.yml | 36 ++++++++ .../ext-fprime-zephyr-reference-teensy41.yml | 36 ++++++++ .github/workflows/reusable-get-pr-branch.yml | 10 ++- .github/workflows/reusable-project-ci.yml | 85 +++++++++++++++++++ 5 files changed, 164 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/ext-fprime-zephyr-reference-pico2.yml create mode 100644 .github/workflows/ext-fprime-zephyr-reference-teensy41.yml create mode 100644 .github/workflows/reusable-project-ci.yml diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index 8dd558b79e..c170a36734 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -61,6 +61,7 @@ Campuzano carg CBF CBLOCK +CCACHE CCB CComponent ccsds diff --git a/.github/workflows/ext-fprime-zephyr-reference-pico2.yml b/.github/workflows/ext-fprime-zephyr-reference-pico2.yml new file mode 100644 index 0000000000..6c42023867 --- /dev/null +++ b/.github/workflows/ext-fprime-zephyr-reference-pico2.yml @@ -0,0 +1,36 @@ +# Cross-compile https://github.com/fprime-community/fprime-zephyr-reference + +name: "External Repo: Zephyr Reference (Pico 2)" + +on: + push: + branches: [ devel, release/** ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ devel, release/** ] + paths-ignore: + - 'docs/**' + - '**.md' + - '.github/actions/spelling/**' + - '.github/ISSUE_TEMPLATE/**' +# Cancel in-progress runs if a newer run is started on a given PR +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ !contains(github.ref, 'devel') && !contains(github.ref, 'release/')}} +jobs: + get-branch: + name: "Get target branch" + uses: ./.github/workflows/reusable-get-pr-branch.yml + with: + target_repository: fprime-community/fprime-zephyr-reference + + build: + name: "Zephyr Build" + needs: get-branch + uses: ./.github/workflows/reusable-project-ci.yml + with: + target_repository: fprime-community/fprime-zephyr-reference + target_ref: ${{ needs.get-branch.outputs.target-branch }} + ci_config_file: ./lib/fprime-zephyr/ci/sample-configs/pico2.yml + + diff --git a/.github/workflows/ext-fprime-zephyr-reference-teensy41.yml b/.github/workflows/ext-fprime-zephyr-reference-teensy41.yml new file mode 100644 index 0000000000..4aead67558 --- /dev/null +++ b/.github/workflows/ext-fprime-zephyr-reference-teensy41.yml @@ -0,0 +1,36 @@ +# Cross-compile https://github.com/fprime-community/fprime-zephyr-reference + +name: "External Repo: Zephyr Reference (Teensy 4.1)" + +on: + push: + branches: [ devel, release/** ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ devel, release/** ] + paths-ignore: + - 'docs/**' + - '**.md' + - '.github/actions/spelling/**' + - '.github/ISSUE_TEMPLATE/**' +# Cancel in-progress runs if a newer run is started on a given PR +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ !contains(github.ref, 'devel') && !contains(github.ref, 'release/')}} +jobs: + get-branch: + name: "Get target branch" + uses: ./.github/workflows/reusable-get-pr-branch.yml + with: + target_repository: fprime-community/fprime-zephyr-reference + + build: + name: "Zephyr Build" + needs: get-branch + uses: ./.github/workflows/reusable-project-ci.yml + with: + target_repository: fprime-community/fprime-zephyr-reference + target_ref: ${{ needs.get-branch.outputs.target-branch }} + ci_config_file: ./lib/fprime-zephyr/ci/sample-configs/teensy41.yml + + diff --git a/.github/workflows/reusable-get-pr-branch.yml b/.github/workflows/reusable-get-pr-branch.yml index b7cfb580c1..277d7959cb 100644 --- a/.github/workflows/reusable-get-pr-branch.yml +++ b/.github/workflows/reusable-get-pr-branch.yml @@ -34,14 +34,16 @@ jobs: - name: "Get target branch" id: get_target_branch run: | + BRANCH_NAME="${GITHUB_REF#refs/heads/}" + echo "Looking for 'pr-${{ github.event.number }}'/'${BRANCH_NAME}'" response_code_pr=`curl -w '%{response_code}' https://api.github.com/repos/${{ inputs.target_repository }}/branches/pr-${{ github.event.number }} -o /dev/null` - response_code_base=`curl -w '%{response_code}' https://api.github.com/repos/${{ inputs.target_repository }}/branches/${{ github.event.pull_request.base.ref }} -o /dev/null` + response_code_branch=`curl -w '%{response_code}' https://api.github.com/repos/${{ inputs.target_repository }}/branches/${BRANCH_NAME} -o /dev/null` if [[ "${{ github.event_name }}" == "pull_request" && "$response_code_pr" == "200" ]]; then echo "TARGET_BRANCH=pr-${{ github.event.number }}" >> $GITHUB_OUTPUT echo "PR branch found, using pr-${{ github.event.number }}" - elif [[ "${{ github.event_name }}" == "pull_request" && "$response_code_base" == "200" ]]; then - echo "TARGET_BRANCH=${{ github.event.pull_request.base.ref }}" >> $GITHUB_OUTPUT - echo "Base branch found, using ${{ github.event.pull_request.base.ref }}" + elif [[ "$response_code_branch" == "200" ]]; then + echo "TARGET_BRANCH=${BRANCH_NAME}" >> $GITHUB_OUTPUT + echo "Base branch found, using ${BRANCH_NAME}" else echo "TARGET_BRANCH=${{ inputs.default_target_ref }}" >> $GITHUB_OUTPUT echo "PR branch not found, using ${{ inputs.default_target_ref }}" diff --git a/.github/workflows/reusable-project-ci.yml b/.github/workflows/reusable-project-ci.yml new file mode 100644 index 0000000000..715d6ca951 --- /dev/null +++ b/.github/workflows/reusable-project-ci.yml @@ -0,0 +1,85 @@ +# This workflow is intended for reuse by other workflows and will not run directly (no triggers). +# The behavior is to run the steps of fprime-ci. +name: "F´ CI - Reusable Workflow" + +on: + workflow_call: + inputs: + target_repository: + description: "Additional external repository to checkout (/)" + required: true + type: string + fprime_location: + description: "Relative path from the external project root to its F´ submodule" + required: false + type: string + default: "./lib/fprime" + target_ref: + description: "Branch on target to checkout" + required: false + type: string + default: "devel" + ci_config_file: + required: true + type: string + run_unit_tests: + description: "Run an additional job in parallel to run unit tests." + required: false + type: boolean + default: true + runs_on: + description: "Platform to run on. Defaults to ubuntu-22.04" + required: false + type: string + default: "ubuntu-22.04" + runs_on_int: + description: "Platform to run integration tests on. Defaults to: apple-ci" + required: false + type: string + default: "apple-ci" + runs_on_ut: + description: "Platform to run UTs on. Defaults to ubuntu-22.04" + required: false + type: string + default: "ubuntu-22.04" +jobs: + build: + runs-on: ${{ inputs.runs_on }} + name: "Build" + steps: + - name: "Make Space" + uses: nasa/fprime-actions/make-space@devel + - name: "Set up target repository" + uses: nasa/fprime-actions/external-repository-setup@devel + with: + target_repository: ${{ inputs.target_repository }} + fprime_location: ${{ inputs.fprime_location }} + target_ref: ${{ inputs.target_ref }} + stage: build + - name: "Build Binary" + run: | + CCACHE_DISABLE=1 fprime-ci -c ${{ inputs.ci_config_file }} --add-stage build + - name: Archive Results + uses: actions/upload-artifact@v4 + with: + name: archive.tar.gz + path: ./archive.tar.gz + integration-tests: + needs: build + name: "Integration Tests" + runs-on: ${{ inputs.runs_on_int }} + steps: + - name: "Set up target repository" + uses: nasa/fprime-actions/external-repository-setup@devel + with: + target_repository: ${{ inputs.target_repository }} + fprime_location: ${{ inputs.fprime_location }} + target_ref: ${{ inputs.target_ref }} + stage: int + - name: Pull Archive Results + uses: actions/download-artifact@v4 + with: + name: archive.tar.gz + - name: "Integration tests" + run: | + fprime-ci -c ${{ inputs.ci_config_file }} --skip-stage build