Skip to content
219 changes: 82 additions & 137 deletions .github/workflows/package_core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ jobs:
# Tag (if found) or hash identifying this core build, should be used for
# user-friendly strings and file names
CORE_TAG: ${{ env.CORE_TAG }}
# Target branch referred to by this workflow (HEAD_REF for branch pushes,
# or closest branch that contains the tag), used for ci-builds tracking
CORE_BRANCH: ${{ env.CORE_BRANCH }}
# Hash identifying this core build, should be used for exact version match
CORE_HASH: ${{ env.CORE_HASH }}
# JSON describing all boards to build, collected by get_board_details.sh
Expand Down Expand Up @@ -76,6 +79,13 @@ jobs:
run: |
echo "## Building \`$CORE_VER\`" >> "$GITHUB_STEP_SUMMARY"
echo "CORE_TAG=$(git describe --tags --exact-match --exclude '*/*' 2>/dev/null || echo $CORE_HASH)" >> "$GITHUB_ENV"
if [[ "${{ github.ref_type }}" == "tag" ]]; then
BRANCH=$(git branch -r --contains HEAD --sort=-committerdate --format='%(refname:short)' | sed 's|origin/||' | grep -v HEAD | head -1)
[[ -n "$BRANCH" ]] || { echo "::error::No branch found containing tag ${{ github.ref_name }}"; exit 1; }
echo "CORE_BRANCH=${BRANCH}" >> "$GITHUB_ENV"
else
echo "CORE_BRANCH=${{ github.head_ref || github.ref_name }}" >> "$GITHUB_ENV"
fi
echo "ALL_BOARD_FQBNS=$(jq -c 'map((. + {link_mode: "static"}), (. + {link_mode: "dynamic"}))' <<< ${ALL_BOARD_DATA})" >> "$GITHUB_ENV"
echo "ARTIFACTS=$(jq -c '["zephyr"] + (map(.artifact) | unique)' <<< ${ALL_BOARD_DATA})" >> "$GITHUB_ENV"
echo "SUB_ARCHES=$(jq -c 'map(.subarch) | unique' <<< ${ALL_BOARD_DATA})" >> "$GITHUB_ENV"
Expand Down Expand Up @@ -107,7 +117,7 @@ jobs:
# for later jobs.

build-board:
# NOTE: this name is hardcoded in ci_inspect_logs.py
# NOTE: this name is hardcoded in ci_collect_data.py
name: Build for ${{ matrix.board }}
runs-on: ubuntu-latest
needs:
Expand Down Expand Up @@ -298,7 +308,7 @@ jobs:
# This step never fails, so that expected errors do not block the CI run.

test-core:
# NOTE: this name is hardcoded in ci_inspect_logs.py
# NOTE: this name is hardcoded in ci_collect_data.py
name: Test ${{ matrix.board }}:${{ matrix.link_mode }}
runs-on: ubuntu-latest
needs:
Expand All @@ -317,73 +327,14 @@ jobs:
if: ${{ !cancelled() && needs.build-env.result == 'success' }}
steps:

# only needs the test list generator and artifact information
- uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false
sparse-checkout: |
extra/ci_test_list.sh
extra/artifacts/

- uses: actions/download-artifact@v8
with:
name: ${{ env.CORE_ARTIFACT }}

- name: Set up core
run: |
tar xf ${CORE_ARTIFACT} # will create ArduinoCore-zephyr/
echo "REPORT_FILE=$(echo ${FQBN} | tr ':' '-').json" >> $GITHUB_ENV

- name: Get test sketches
run: |
# sets ALL_TESTS and ALL_LIBRARIES env vars in GITHUB_ENV
extra/ci_test_list.sh ${{ matrix.artifact }} ${{ matrix.variant }}

- name: Compile tests for ${{ matrix.board }}
uses: pillo79/compile-sketches@next
with:
fqbn: ${{ env.FQBN }}
platforms: |
# Use Board Manager version first to install the tools
- name: ${{ env.PLAT }}
# ... then replace that with the local version
- name: ${{ env.PLAT }}
source-path: "ArduinoCore-zephyr"
sketch-paths: |
${{ env.ALL_TESTS }}
libraries: |
${{ env.ALL_LIBRARIES }}
cli-compile-flags: |
- '--build-property'
- 'compiler.c.extra_flags=-Wno-type-limits -Wno-missing-field-initializers'
- '--build-property'
- 'compiler.cpp.extra_flags=-Wno-type-limits -Wno-missing-field-initializers'
verbose: 'false'
enable-deltas-report: 'false'
enable-issues-report: 'true'
always-succeed: 'true'

- name: Prepare log
if: ${{ success() || failure() }}
run: |
# make sure to create an empty report if none was created
[ ! -f sketches-reports/${REPORT_FILE} ] && mkdir -p sketches-reports && echo "{}" > sketches-reports/${REPORT_FILE}
# remove base path of the core install from all file references to make logs cleaner
sed -i -e 's!/home/runner/.arduino15/packages/arduino/hardware/zephyr/[^/]*/!!g' sketches-reports/${REPORT_FILE}

# archive the compile report for later
- uses: actions/upload-artifact@v7
if: ${{ success() || failure() }}
with:
name: test-report-${{ env.ARTIFACT_TAG }}
path: sketches-reports/*
retention-days: 1
true



# Collect all build and test reports, analyze them and produce a summary.
# See ci_inspect_logs.py for details.
# See ci_collect_data.py and ci_generate_report.py for details.

verify-core:
runs-on: ubuntu-latest
Expand All @@ -399,87 +350,18 @@ jobs:
GH_REPO: ${{ github.repository }}
steps:

- uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false
fetch-tags: true

- uses: actions/download-artifact@v8
with:
path: .
pattern: "*-report-*"
merge-multiple: true

- name: Generate workflow summary
run: |
# gather the array of job metadata (especially name and ID) for the current workflow run
export WORKFLOW_JOBS=$(gh run view ${{ github.run_id }} --attempt ${{ github.run_attempt }} --json jobs --jq '.jobs')
# Run the log inspection script
extra/ci_inspect_logs.py result summary full_log
cat result

# Display the summary and full log in the step summary
cat summary >> $GITHUB_STEP_SUMMARY
cat full_log >> $GITHUB_STEP_SUMMARY

# Create a comment for PRs using the summary file
if [ "${{ github.event_name }}" == "pull_request" ]; then
mkdir -p comment-request
echo "${{ github.event.pull_request.number }}" > comment-request/pr_number
echo -e "## Built \`$CORE_VER\`\n" > comment-request/comment_body
# strip LaTeX color commands and escape sequences for mail readability
cat summary | sed -e 's!\${\\color{\S*}\(.*\)}\$!\1!g' -e 's!\\%!%!g' >> comment-request/comment_body
fi
echo "{ 'done': true }" > ${{ env.CORE_VER }}.json # dummy metadata for now

# Prepare latest size artifact file on push events
if [ "${{ github.event_name }}" == "push" ]; then
tar jchf size-reports-${{ needs.build-env.outputs.CORE_HASH }}.tar.bz2 arduino-*.json
fi

- name: Compute code size changes
if: ${{ github.event_name == 'pull_request' }}
run: |
export GITHUB_BASE_SHA=$(git describe --always origin/${GITHUB_BASE_REF})
# errors due to race conditions with parallel branch runs should not fail the job
extra/ci_calc_size_reports.py ${GITHUB_BASE_SHA} sketches-reports/ || true

# upload comment request artifact (will be retrieved by leave_pr_comment.yml)
- name: Archive comment information
# upload build metadata artifact, for upload to ci-builds
- name: Archive build metadata information
uses: actions/upload-artifact@v7
if: ${{ github.event_name == 'pull_request' }}
with:
name: comment-request
path: comment-request/
name: build-metadata
path: ${{ env.CORE_VER }}.json
retention-days: 1

# upload size delta report artifact (will be retrieved by report_size_deltas.yml)
- name: Archive size deltas report information
uses: actions/upload-artifact@v7
if: ${{ github.event_name == 'pull_request' }}
with:
name: sketches-reports
path: sketches-reports/
retention-days: 1

# upload new official test size artifact (for AWS storage)
- name: Archive sketch report information
uses: actions/upload-artifact@v7
if: ${{ github.event_name == 'push' }}
with:
name: size-reports
path: size-reports-${{ needs.build-env.outputs.CORE_HASH }}.tar.bz2
retention-days: 1
archive: false

# The last line makes the job fail if the 'result' file does not contain "PASSED".
# No further actions are allowed in case of error.
- run: |
cat result
grep -q "PASSED" result # otherwise CI test failed



# Clean up test results only if the verification actually passed, so that
# they are still available for action re-runs in case of failure.

Expand Down Expand Up @@ -585,3 +467,66 @@ jobs:
with:
name: ArduinoCore-zephyr-${{ env.CORE_TAG }}-jsons
path: ArduinoCore-*-${{ env.CORE_TAG }}.json

ci-builds-upload:
runs-on: ubuntu-latest
needs:
- build-env
- verify-core
- prepare-json
permissions:
id-token: write # required to obtain the OIDC token
env:
CORE_TAG: ${{ needs.build-env.outputs.CORE_TAG }}
CORE_VER: ${{ needs.build-env.outputs.CORE_VER }}
steps:
- uses: actions/download-artifact@v8
with:
path: jsons/
name: ArduinoCore-zephyr-${{ env.CORE_TAG }}-jsons

- uses: actions/download-artifact@v8
with:
path: .
name: build-metadata

- run: |
find
echo "SNIPPETS<<EOF" >> $GITHUB_ENV
jq -n 'reduce inputs as $i ({}; .[input_filename] = $i)' ArduinoCore-*.json >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo "METADATA<<EOF" >> $GITHUB_ENV
jq -c '{"${{ env.CORE_VER }}": .}' ${CORE_VER}.json >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV

- name: Get OIDC identity token
id: oidc
uses: actions/github-script@v7
with:
script: |
const token = await core.getIDToken('arduino/ci-builds');
core.setOutput('token', token)

- name: Store snippets in ci-builds
uses: actions/github-script@v7
with:
github-token: ${{ secrets.CI_BUILDS_TOKEN }}
script: |
await github.rest.actions.createWorkflowDispatch({
owner: 'pillo79',
repo: 'ci-builds',
workflow_id: 'store-snippets.yml',
ref: 'main',
inputs: {
oidc_token: '${{ steps.oidc.outputs.token }}',
// Required only when running from a tag ref; ignored for branch refs.
// Snippets will be stored under this branch's folder.
base_branch: '${{ needs.build-env.outputs.CORE_BRANCH }}',
// 'platform' (default) or 'tool'
snippet_type: 'platform',
// build version — required when passing metadata
version: '${{ env.CORE_VER }}',
snippets: '${{ env.SNIPPETS }}',
metadata: '${{ env.METADATA }}',
},
});
5 changes: 2 additions & 3 deletions .github/workflows/upload_json.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ jobs:
submit-json-to-gh-pages:
name: Update git JSON on Github Pages
runs-on: ubuntu-latest
if: ${{ github.repository == 'arduino/ArduinoCore-zephyr'
&& github.event.workflow_run.event == 'push'
&& github.event.workflow_run.head_branch == 'main'
if: ${{ github.event.workflow_run.event == 'push'
&& !contains(github.event.workflow_run.head_branch, '/')
&& github.event.workflow_run.conclusion == 'success' }}
environment:
name: github-pages
Expand Down
12 changes: 10 additions & 2 deletions extra/artifacts/zephyr_unoq.test_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ get_branch_tip libraries arduino-libraries/ArduinoBLE master \
examples/Peripheral/ButtonLED \

# Arduino_RouterBridge
get_branch_tip libraries arduino-libraries/Arduino_RouterBridge main
get_branch_tip libraries arduino-libraries/Arduino_RouterBridge main \
examples/client \
examples/hci \
examples/monitor \
examples/server \
examples/udp_ntp_client \

# Arduino_RPClite
get_branch_tip libraries arduino-libraries/Arduino_RPClite main
get_branch_tip libraries arduino-libraries/Arduino_RPClite main \
examples/rpc_lite_client \
examples/rpc_lite_server \

Loading
Loading