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.8, 3.9, '3.10']
29        os: [ubuntu-20.04]
30    steps:
31      - name: checkout
32        uses: actions/checkout@v3
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          git rebase origin/${BASE_REF}
46          git log --graph --oneline HEAD...${PR_HEAD}
47
48      - name: Set up Python ${{ matrix.python-version }}
49        uses: actions/setup-python@v4
50        with:
51          python-version: ${{ matrix.python-version }}
52
53      - name: cache-pip-linux
54        if: startsWith(runner.os, 'Linux')
55        uses: actions/cache@v3
56        with:
57          path: ~/.cache/pip
58          key: ${{ runner.os }}-pip-${{ matrix.python-version }}
59          restore-keys: |
60            ${{ runner.os }}-pip-${{ matrix.python-version }}
61
62      - name: install-packages
63        run: |
64          pip3 install -r scripts/requirements-base.txt -r scripts/requirements-build-test.txt
65
66      - name: Run pytest
67        env:
68          ZEPHYR_BASE: ./
69        run: |
70          echo "Run script tests"
71          pytest ./scripts/build
72