1name: Hello World (Multiplatform)
2
3on:
4  push:
5    branches:
6      - main
7      - v*-branch
8      - collab-*
9  pull_request:
10    branches:
11      - main
12      - v*-branch
13      - collab-*
14    paths:
15      - 'scripts/build/**'
16      - 'scripts/requirements*.txt'
17      - '.github/workflows/hello_world_multiplatform.yaml'
18      - 'SDK_VERSION'
19
20concurrency:
21  group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref }}
22  cancel-in-progress: true
23
24jobs:
25  build:
26    strategy:
27      fail-fast: false
28      matrix:
29        os: [ubuntu-22.04, macos-13, macos-14, windows-2022]
30    runs-on: ${{ matrix.os }}
31    steps:
32      - name: Checkout
33        uses: actions/checkout@v4
34        with:
35          path: zephyr
36          fetch-depth: 0
37
38      - name: Rebase
39        if: github.event_name == 'pull_request'
40        env:
41          BASE_REF: ${{ github.base_ref }}
42          PR_HEAD: ${{ github.event.pull_request.head.sha }}
43        working-directory: zephyr
44        shell: bash
45        run: |
46          git config --global user.email "actions@zephyrproject.org"
47          git config --global user.name "Github Actions"
48          git rebase origin/${BASE_REF}
49          git log --graph --oneline HEAD...${PR_HEAD}
50
51      - name: Set up Python
52        uses: actions/setup-python@v5
53        with:
54          python-version: 3.11
55
56      - name: Setup Zephyr project
57        uses: zephyrproject-rtos/action-zephyr-setup@v1
58        with:
59          app-path: zephyr
60          toolchains: all
61
62      - name: Build firmware
63        working-directory: zephyr
64        shell: bash
65        run: |
66          if [ "${{ runner.os }}" = "macOS" ]; then
67            EXTRA_TWISTER_FLAGS="-P native_sim --build-only"
68          elif [ "${{ runner.os }}" = "Windows" ]; then
69            EXTRA_TWISTER_FLAGS="-P native_sim --short-build-path -O/tmp/twister-out"
70          fi
71          ./scripts/twister --force-color --inline-logs -T samples/hello_world -v $EXTRA_TWISTER_FLAGS
72
73      - name: Upload artifacts
74        if: failure()
75        uses: actions/upload-artifact@v4
76        with:
77          if-no-files-found: ignore
78          path:
79            zephyr/twister-out/*/samples/hello_world/sample.basic.helloworld/build.log
80