1# Copyright (c) 2020 Linaro Limited.
2# Copyright (c) 2020 Nordic Semiconductor ASA
3# SPDX-License-Identifier: Apache-2.0
4
5name: Devicetree script tests
6
7on:
8  push:
9    branches:
10    - main
11    - v*-branch
12    paths:
13    - 'scripts/dts/**'
14    - '.github/workflows/devicetree_checks.yml'
15  pull_request:
16    branches:
17    - main
18    - v*-branch
19    paths:
20    - 'scripts/dts/**'
21    - '.github/workflows/devicetree_checks.yml'
22
23jobs:
24  devicetree-checks:
25    name: Devicetree script tests
26    runs-on: ${{ matrix.os }}
27    strategy:
28      matrix:
29        python-version: [3.8, 3.9, '3.10']
30        os: [ubuntu-22.04, macos-11, windows-2022]
31        exclude:
32        - os: macos-11
33          python-version: 3.6
34        - os: windows-2022
35          python-version: 3.6
36    steps:
37    - name: checkout
38      uses: actions/checkout@v3
39    - name: Set up Python ${{ matrix.python-version }}
40      uses: actions/setup-python@v4
41      with:
42        python-version: ${{ matrix.python-version }}
43    - name: cache-pip-linux
44      if: startsWith(runner.os, 'Linux')
45      uses: actions/cache@v3
46      with:
47        path: ~/.cache/pip
48        key: ${{ runner.os }}-pip-${{ matrix.python-version }}
49        restore-keys: |
50          ${{ runner.os }}-pip-${{ matrix.python-version }}
51    - name: cache-pip-mac
52      if: startsWith(runner.os, 'macOS')
53      uses: actions/cache@v3
54      with:
55        path: ~/Library/Caches/pip
56        # Trailing '-' was just to get a different cache name
57        key: ${{ runner.os }}-pip-${{ matrix.python-version }}-
58        restore-keys: |
59          ${{ runner.os }}-pip-${{ matrix.python-version }}-
60    - name: cache-pip-win
61      if: startsWith(runner.os, 'Windows')
62      uses: actions/cache@v3
63      with:
64        path: ~\AppData\Local\pip\Cache
65        key: ${{ runner.os }}-pip-${{ matrix.python-version }}
66        restore-keys: |
67          ${{ runner.os }}-pip-${{ matrix.python-version }}
68    - name: install python dependencies
69      run: |
70        pip3 install wheel
71        pip3 install pytest pyyaml tox
72    - name: run tox
73      working-directory: scripts/dts/python-devicetree
74      run: |
75        tox
76