Build and Test #1491
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: Build and Test | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| device_thingy91x: | |
| description: 'Test thingy91x' | |
| type: boolean | |
| required: false | |
| default: false | |
| device_nrf9151dk: | |
| description: 'Test nrf9151dk' | |
| type: boolean | |
| required: false | |
| default: false | |
| device_ppk_thingy91x: | |
| description: 'Test ppk_thingy91x' | |
| type: boolean | |
| required: false | |
| default: false | |
| device_gnss_nrf9151dk: | |
| description: 'Test gnss_nrf9151dk' | |
| type: boolean | |
| required: false | |
| default: false | |
| device_prov_thingy91x: | |
| description: 'Test prov_thingy91x' | |
| type: boolean | |
| required: false | |
| default: false | |
| run_nightly_tests: | |
| description: 'Include slow tests for the selected boards' | |
| type: boolean | |
| required: false | |
| default: false | |
| workflow_call: | |
| inputs: | |
| build_type: | |
| description: 'Override build scope (leave empty to auto-derive from selected devices)' | |
| type: string | |
| required: false | |
| default: "" | |
| schedule: | |
| - cron: "0 0 * * *" | |
| push: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - "docs/**" | |
| permissions: | |
| contents: read | |
| jobs: | |
| setup: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| devices: ${{ steps.setup.outputs.devices }} | |
| build_type: ${{ steps.setup.outputs.build_type }} | |
| push_memory_badges: ${{ steps.setup.outputs.push_memory_badges == 'true' }} | |
| run_nightly_tests: ${{ steps.setup.outputs.run_nightly_tests == 'true' }} | |
| steps: | |
| - name: Setup | |
| id: setup | |
| run: | | |
| SCHEDULED=${{ github.event_name == 'schedule' }} | |
| PUSH=${{ github.event_name == 'push' }} | |
| push_memory_badges=false | |
| if [[ $SCHEDULED == true ]]; then | |
| devices="thingy91x nrf9151dk ppk_thingy91x gnss_nrf9151dk prov_thingy91x" | |
| push_memory_badges=true | |
| run_nightly_tests=true | |
| elif [[ $PUSH == true ]]; then | |
| devices="thingy91x" | |
| build_type=all | |
| else | |
| # Build devices list from selected checkboxes | |
| devices="" | |
| if [[ "${{ inputs.device_thingy91x }}" == "true" ]]; then | |
| devices="$devices thingy91x" | |
| fi | |
| if [[ "${{ inputs.device_nrf9151dk }}" == "true" ]]; then | |
| devices="$devices nrf9151dk" | |
| fi | |
| if [[ "${{ inputs.device_ppk_thingy91x }}" == "true" ]]; then | |
| devices="$devices ppk_thingy91x" | |
| fi | |
| if [[ "${{ inputs.device_gnss_nrf9151dk }}" == "true" ]]; then | |
| devices="$devices gnss_nrf9151dk" | |
| fi | |
| if [[ "${{ inputs.device_prov_thingy91x }}" == "true" ]]; then | |
| devices="$devices prov_thingy91x" | |
| fi | |
| # Trim leading space | |
| devices=$(echo "$devices" | xargs) | |
| if [[ -z "$devices" ]]; then | |
| echo "ERROR: At least one device must be selected" | |
| exit 1 | |
| fi | |
| run_nightly_tests=${{ inputs.run_nightly_tests }} | |
| fi | |
| # Derive build_type unless explicitly overridden via workflow_call input. | |
| # minimal: thingy91x base firmware only (sufficient when only thingy91x-family devices selected) | |
| # release: only set explicitly via workflow_call (e.g. release workflow) | |
| # all: builds everything | |
| only_thingy91x_family=false | |
| for d in $devices; do | |
| if [[ "$d" == "thingy91x" || "$d" == "ppk_thingy91x" || "$d" == "prov_thingy91x" ]]; then | |
| only_thingy91x_family=true | |
| else | |
| only_thingy91x_family=false | |
| break | |
| fi | |
| done | |
| if [[ -n "${build_type:-}" ]]; then | |
| : # build_type already set (e.g. push or schedule) | |
| elif [[ -n "${{ inputs.build_type }}" ]]; then | |
| build_type=${{ inputs.build_type }} | |
| elif [[ "$only_thingy91x_family" == "true" && "${run_nightly_tests:-false}" != "true" ]]; then | |
| build_type=minimal | |
| else | |
| build_type=all | |
| fi | |
| echo "devices=$devices" | |
| echo "build_type=$build_type" | |
| echo "push_memory_badges=$push_memory_badges" | |
| echo "run_nightly_tests=${run_nightly_tests:-false}" | |
| echo "devices=$devices" >> $GITHUB_OUTPUT | |
| echo "build_type=$build_type" >> $GITHUB_OUTPUT | |
| echo "push_memory_badges=$push_memory_badges" >> $GITHUB_OUTPUT | |
| echo "run_nightly_tests=${run_nightly_tests:-false}" >> $GITHUB_OUTPUT | |
| build: | |
| needs: setup | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| uses: ./.github/workflows/build.yml | |
| secrets: inherit | |
| with: | |
| build_type: ${{ needs.setup.outputs.build_type }} | |
| push_memory_badges: ${{ needs.setup.outputs.push_memory_badges == 'true' }} | |
| test: | |
| permissions: | |
| actions: read | |
| contents: write | |
| packages: read | |
| uses: ./.github/workflows/target-test.yml | |
| needs: [build, setup] | |
| secrets: inherit | |
| with: | |
| artifact_fw_version: ${{ needs.build.outputs.version }} | |
| artifact_run_id: ${{ needs.build.outputs.run_id }} | |
| devices: ${{ needs.setup.outputs.devices }} | |
| run_nightly_tests: ${{ needs.setup.outputs.run_nightly_tests == 'true' }} |