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
22permissions:
23  contents: read
24
25jobs:
26  scripts-tests:
27    name: Scripts tests
28    runs-on: ${{ matrix.os }}
29    strategy:
30      matrix:
31        python-version: ['3.10', '3.11', '3.12', '3.13']
32        os: [ubuntu-24.04]
33    steps:
34      - name: checkout
35        uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
36        with:
37          ref: ${{ github.event.pull_request.head.sha }}
38          fetch-depth: 0
39
40      - name: Rebase
41        continue-on-error: true
42        env:
43          BASE_REF: ${{ github.base_ref }}
44          PR_HEAD: ${{ github.event.pull_request.head.sha }}
45        run: |
46          git config --global user.email "actions@zephyrproject.org"
47          git config --global user.name "Github Actions"
48          rm -fr ".git/rebase-apply"
49          rm -fr ".git/rebase-merge"
50          git rebase origin/${BASE_REF}
51          git clean -f -d
52          git log --graph --oneline HEAD...${PR_HEAD}
53
54      - name: Set up Python ${{ matrix.python-version }}
55        uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
56        with:
57          python-version: ${{ matrix.python-version }}
58          cache: pip
59          cache-dependency-path: scripts/requirements-actions.txt
60
61      - name: Install Python packages
62        run: |
63          pip install -r scripts/requirements-actions.txt --require-hashes
64
65      - name: Run pytest
66        env:
67          ZEPHYR_BASE: ./
68        run: |
69          echo "Run script tests"
70          pytest ./scripts/build
71