1# Copyright 2023 Google LLC
2# SPDX-License-Identifier: Apache-2.0
3
4name: Scripts tests
5
6on:
7  push:
8    branches:
9      - main
10      - v*-branch
11    paths:
12      - 'scripts/build/**'
13      - '.github/workflows/scripts_tests.yml'
14  pull_request:
15    branches:
16      - main
17      - v*-branch
18    paths:
19      - 'scripts/build/**'
20      - '.github/workflows/scripts_tests.yml'
21
22jobs:
23  scripts-tests:
24    name: Scripts tests
25    runs-on: ${{ matrix.os }}
26    strategy:
27      matrix:
28        python-version: ['3.10', '3.11', '3.12', '3.13']
29        os: [ubuntu-20.04]
30    steps:
31      - name: checkout
32        uses: actions/checkout@v4
33        with:
34          ref: ${{ github.event.pull_request.head.sha }}
35          fetch-depth: 0
36
37      - name: Rebase
38        continue-on-error: true
39        env:
40          BASE_REF: ${{ github.base_ref }}
41          PR_HEAD: ${{ github.event.pull_request.head.sha }}
42        run: |
43          git config --global user.email "actions@zephyrproject.org"
44          git config --global user.name "Github Actions"
45          rm -fr ".git/rebase-apply"
46          rm -fr ".git/rebase-merge"
47          git rebase origin/${BASE_REF}
48          git clean -f -d
49          git log --graph --oneline HEAD...${PR_HEAD}
50
51      - name: Set up Python ${{ matrix.python-version }}
52        uses: actions/setup-python@v5
53        with:
54          python-version: ${{ matrix.python-version }}
55
56      - name: cache-pip-linux
57        if: startsWith(runner.os, 'Linux')
58        uses: actions/cache@v4
59        with:
60          path: ~/.cache/pip
61          key: ${{ runner.os }}-pip-${{ matrix.python-version }}
62          restore-keys: |
63            ${{ runner.os }}-pip-${{ matrix.python-version }}
64
65      - name: install-packages
66        run: |
67          pip install -r scripts/requirements-base.txt -r scripts/requirements-build-test.txt
68
69      - name: Run pytest
70        env:
71          ZEPHYR_BASE: ./
72        run: |
73          echo "Run script tests"
74          pytest ./scripts/build
75