Optimize turnLed function. #138
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Package, test and upload core | |
on: | |
- push | |
- pull_request | |
jobs: | |
package-core: | |
name: Build and package core | |
runs-on: ubuntu-latest | |
env: | |
CCACHE_IGNOREOPTIONS: -specs=* | |
outputs: | |
CORE_TAG: ${{ env.CORE_TAG }} | |
CORE_ARTIFACT: ${{ env.CORE_ARTIFACT }} | |
BOARD_VARIANTS: ${{ env.BOARD_VARIANTS }} | |
steps: | |
- name: Install OS dependencies | |
working-directory: /opt | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y --no-install-recommends git cmake wget python3-pip ninja-build ccache | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
fetch-depth: 0 | |
persist-credentials: false | |
fetch-tags: true | |
token: ${{ secrets.ARDUINOBOT_TOKEN }} | |
- name: Initialize Zephyr environment | |
run: | | |
yes | ./extra/bootstrap.sh -o=--filter=tree:0 | |
echo "CORE_TAG=$(git describe --tag)" >> "$GITHUB_ENV" | |
echo "CORE_ARTIFACT=ArduinoCore-zephyr-$(git describe --tag)" >> "$GITHUB_ENV" | |
echo "BOARD_VARIANTS=$(extra/get_board_details.sh | jq -cr 'sort_by(.variant)')" >> "$GITHUB_ENV" | |
- name: ccache | |
uses: hendrikmuhs/[email protected] | |
with: | |
verbose: 1 | |
- name: Build variants | |
shell: bash | |
run: | | |
./extra/build_all.sh -f | |
- name: Package core | |
run: | | |
./extra/package_core.sh ${{ env.CORE_TAG }} | |
- name: Archive core | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.CORE_ARTIFACT }} | |
path: distrib/${{ env.CORE_ARTIFACT }}.tar.bz2 | |
test-core: | |
name: Test ${{ matrix.board }} board | |
runs-on: ubuntu-latest | |
needs: package-core | |
strategy: | |
matrix: | |
include: | |
${{ fromJSON( needs.package-core.outputs.BOARD_VARIANTS ) }} | |
fail-fast: false | |
env: | |
FQBN: arduino:zephyr:${{ matrix.board }} | |
REPORT_FILE: arduino-zephyr-${{ matrix.board }}.json | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: ${{ needs.package-core.outputs.CORE_ARTIFACT }} | |
- name: Set up core | |
run: | | |
tar xf ${{ needs.package-core.outputs.CORE_ARTIFACT }}.tar.bz2 | |
- name: Create Blink sketch | |
run: | | |
mkdir Blink/ | |
wget -nv https://raw.githubusercontent.com/arduino/arduino-examples/refs/heads/main/examples/01.Basics/Blink/Blink.ino -P Blink/ | |
- name: Compile Blink for ${{ matrix.board }} | |
uses: pillo79/compile-sketches@main | |
with: | |
fqbn: ${{ env.FQBN }} | |
platforms: | | |
# Use Board Manager to install the latest release of Arduino Zephyr Boards to get the toolchain | |
- name: "arduino:zephyr" | |
source-url: "https://downloads.arduino.cc/packages/package_zephyr_index.json" | |
- name: "arduino:zephyr" | |
source-path: "ArduinoCore-zephyr" | |
sketch-paths: Blink | |
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-warnings-report: 'true' | |
enable-warnings-log: 'true' | |
- name: Get job ID | |
id: job_id | |
if: ${{ success() || failure() }} | |
uses: actions/github-script@main | |
with: | |
script: | | |
const { data: workflow_run } = await github.rest.actions.listJobsForWorkflowRun({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: context.runId | |
}); | |
const job_name = `Test ${{ matrix.board }} board` | |
return workflow_run.jobs.find((job) => job.name === job_name).id; | |
- name: Prepare log | |
if: ${{ success() || failure() }} | |
run: | | |
sed -i -e 's!/home/runner/.arduino15/packages/arduino/hardware/zephyr/[^/]*/!!g' sketches-reports/${REPORT_FILE} | |
cat sketches-reports/${REPORT_FILE} | jq -cr ".boards[0].sketches[0] += { job_id: ${{ steps.job_id.outputs.result }} }" > ${REPORT_FILE} && mv ${REPORT_FILE} sketches-reports/ | |
- uses: actions/upload-artifact@v4 | |
if: ${{ success() || failure() }} | |
with: | |
name: test-report-${{ needs.package-core.outputs.CORE_TAG }}-${{ matrix.board }} | |
path: sketches-reports/* | |
collect-logs: | |
name: Collect logs | |
runs-on: ubuntu-latest | |
needs: | |
- package-core | |
- test-core | |
if: ${{ !cancelled() && needs.package-core.result == 'success' }} | |
env: | |
BOARD_VARIANTS: ${{ needs.package-core.outputs.BOARD_VARIANTS }} | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
path: . | |
pattern: test-report-* | |
merge-multiple: true | |
- run: | | |
echo "### Core test results:" >> "$GITHUB_STEP_SUMMARY" | |
jq -c '.[]' <<< "$BOARD_VARIANTS" | while read -r BOARD_VARIANT; do | |
BOARD=$(echo $BOARD_VARIANT | jq -cr '.board') | |
VARIANT=$(echo $BOARD_VARIANT | jq -cr '.variant') | |
FQBN="arduino:zephyr:$BOARD" | |
REPORT_FILE="arduino-zephyr-$BOARD.json" | |
if [ ! -f $REPORT_FILE ]; then | |
echo "* :x: $BOARD (`$VARIANT`) - No report found?" >> "$GITHUB_STEP_SUMMARY" | |
else | |
REPORT=$(jq -cr '.boards[0].sketches[0]' $REPORT_FILE) | |
JOB_ID=$(echo $REPORT | jq -cr '.job_id') | |
JOB_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${JOB_ID}#step:5:2" | |
if ! $(echo $REPORT | jq -cr '.compilation_success') ; then | |
echo "* :x: [$BOARD]($JOB_URL) (\`$VARIANT\`) - Build failed" >> "$GITHUB_STEP_SUMMARY" | |
else | |
WARNINGS=$(echo $REPORT | jq -cr '.warnings.current.absolute // 0') | |
if [ $WARNINGS -eq 0 ]; then | |
echo "* :white_check_mark: $BOARD (\`$VARIANT\`) - Build successful" >> "$GITHUB_STEP_SUMMARY" | |
else | |
echo >> "$GITHUB_STEP_SUMMARY" | |
echo "<details><summary> :warning: <a href=\"$JOB_URL\">$BOARD</a> (<tt>$VARIANT</tt>) - $WARNINGS warnings:</summary>" >> "$GITHUB_STEP_SUMMARY" | |
echo >> "$GITHUB_STEP_SUMMARY" | |
echo "\`\`\`" >> "$GITHUB_STEP_SUMMARY" | |
echo $REPORT | jq -cr '.warnings_log[]' >> "$GITHUB_STEP_SUMMARY" | |
echo "\`\`\`" >> "$GITHUB_STEP_SUMMARY" | |
echo >> "$GITHUB_STEP_SUMMARY" | |
echo "</details>" >> "$GITHUB_STEP_SUMMARY" | |
echo >> "$GITHUB_STEP_SUMMARY" | |
fi | |
fi | |
fi | |
done | |
- name: Clean up intermediate artifacts | |
uses: geekyeggo/[email protected] | |
with: | |
name: test-report-* | |
failOnError: false | |
publish-core: | |
name: Publish core | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/') && github.event_name == 'push' && github.repository == 'bcmi-labs/ArduinoCore-zephyr' | |
needs: | |
- package-core | |
- test-core | |
environment: staging | |
permissions: | |
id-token: write | |
contents: read | |
env: | |
CORE_ARTIFACT: ${{ needs.package-core.outputs.CORE_ARTIFACT }} | |
ARTIFACT_FILE: ${{ needs.package-core.outputs.CORE_ARTIFACT }}.tar.bz2 | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: ${{ env.CORE_ARTIFACT }} | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: 'us-east-1' | |
role-to-assume: "arn:aws:iam::257442868231:role/static-website/ArduinoCore-zephyr" | |
role-session-name: "GHA_to_AWS_via_OIDC_for_ArduinoCore-zephyr" | |
- name: Upload artifact | |
run: aws s3 cp ${{ env.ARTIFACT_FILE }} s3://apt-repo.oniudra.cc/ | |
publish-json: | |
name: Publish json | |
environment: staging | |
permissions: | |
id-token: write | |
contents: read | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/') && github.event_name == 'push' && github.repository == 'bcmi-labs/ArduinoCore-zephyr' | |
needs: | |
- package-core | |
- test-core | |
- publish-core | |
env: | |
CORE_ARTIFACT: ${{ needs.package-core.outputs.CORE_ARTIFACT }} | |
ARTIFACT_FILE: ${{ needs.package-core.outputs.CORE_ARTIFACT }}.tar.bz2 | |
CORE_TAG: ${{ needs.package-core.outputs.CORE_TAG }} | |
PACKAGE_INDEX_JSON: zephyr-core-imola.json | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
sparse-checkout: | | |
extra/gen_package_index_json.sh | |
extra/zephyr-core-template.json | |
- uses: actions/download-artifact@v4 | |
with: | |
name: ${{ env.CORE_ARTIFACT }} | |
# uses: ARTIFACT_FILE CORE_TAG PACKAGE_INDEX_JSON | |
- name: Prepare package index snippet | |
run: | | |
./extra/gen_package_index_json.sh | |
# Replaces downloads with the temporary private bucket. It is okay to write the pw in plain text in this case. | |
# The reason is because we will distribute this and hardcode it in plain text anyway, for the sample boards we'll ship. | |
sed -i "s#https://downloads.arduino.cc/cores/zephyr/#https://arduino:[email protected]/#" ${{ env.PACKAGE_INDEX_JSON }} | |
- name: Archive package index snippet | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.PACKAGE_INDEX_JSON }} | |
path: ${{ env.PACKAGE_INDEX_JSON }} | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: 'us-east-1' | |
role-to-assume: "arn:aws:iam::257442868231:role/static-website/ArduinoCore-zephyr" | |
role-session-name: "GHA_to_AWS_via_OIDC_for_ArduinoCore-zephyr" | |
- name: Upload artifact | |
run: aws s3 cp ${{ env.PACKAGE_INDEX_JSON }} s3://apt-repo.oniudra.cc/ |