Skip to content

Commit 2fd7876

Browse files
committed
ci: github: west: Add a GH workflow to run the west command tests
Replace running west command tests in run_ci.sh with a github workflow. This provides some benefits in that we can run the west command tests on multiple python versions and host OSes (linux, mac and windows). Also have the benefit that the tests are only run on modifications to files in scripts/west_commands/ or scripts/west-commands.yml. Signed-off-by: Kumar Gala <[email protected]>
1 parent 1c80d79 commit 2fd7876

File tree

3 files changed

+66
-19
lines changed

3 files changed

+66
-19
lines changed

.github/workflows/west_cmds.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Copyright (c) 2020 Linaro Limited.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: Zephyr West Command Tests
5+
6+
on:
7+
push:
8+
paths:
9+
- 'scripts/west-commands.yml'
10+
- 'scripts/west_commands/**'
11+
pull_request:
12+
paths:
13+
- 'scripts/west-commands.yml'
14+
- 'scripts/west_commands/**'
15+
16+
jobs:
17+
build:
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
matrix:
21+
python-version: [3.6, 3.7, 3.8]
22+
os: [ubuntu-latest, macos-latest, windows-latest]
23+
steps:
24+
- name: checkout
25+
uses: actions/checkout@v2
26+
- name: Set up Python ${{ matrix.python-version }}
27+
uses: actions/setup-python@v1
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
- name: cache-pip-linux
31+
if: startsWith(runner.os, 'Linux')
32+
uses: actions/cache@v1
33+
with:
34+
path: ~/.cache/pip
35+
key: ${{ runner.os }}-pip-${{ matrix.python-version }}
36+
restore-keys: |
37+
${{ runner.os }}-pip-${{ matrix.python-version }}
38+
- name: cache-pip-mac
39+
if: startsWith(runner.os, 'macOS')
40+
uses: actions/cache@v1
41+
with:
42+
path: ~/Library/Caches/pip
43+
# Trailing '-' was just to get a different cache name
44+
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-
45+
restore-keys: |
46+
${{ runner.os }}-pip-${{ matrix.python-version }}-
47+
- name: cache-pip-win
48+
if: startsWith(runner.os, 'Windows')
49+
uses: actions/cache@v1
50+
with:
51+
path: ~\AppData\Local\pip\Cache
52+
key: ${{ runner.os }}-pip-${{ matrix.python-version }}
53+
restore-keys: |
54+
${{ runner.os }}-pip-${{ matrix.python-version }}
55+
- name: install pytest
56+
run: |
57+
pip3 install pytest west
58+
- name: run pytest-win
59+
if: runner.os == 'Windows'
60+
run: |
61+
cmd /C "set PYTHONPATH=.\scripts\west_commands && pytest ./scripts/west_commands/tests/"
62+
- name: run pytest-mac-linux
63+
if: runner.os != 'Windows'
64+
run: |
65+
PYTHONPATH=./scripts/west_commands pytest ./scripts/west_commands/tests/

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# * @galak @nashif
1515

1616
/.known-issues/ @inakypg @nashif
17+
/.github/workflows/ @galak @nashif
1718
/arch/arc/ @vonhust @ruuddw
1819
/arch/arm/ @MaureenHelm @galak @ioannisg
1920
/arch/arm/core/aarch32/cortex_m/cmse/ @ioannisg

scripts/ci/run_ci.sh

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,6 @@ function on_complete() {
110110
cp ${bsim_bt_test_results_file} shippable/testresults/
111111
fi
112112

113-
if [ -e ${west_commands_results_file} ]; then
114-
echo "Copy ${west_commands_results_file}"
115-
cp ${west_commands_results_file} shippable/testresults
116-
fi
117-
118113
if [ "$matrix" = "1" ]; then
119114
echo "Skip handling coverage data..."
120115
#handle_coverage
@@ -245,20 +240,6 @@ if [ -n "$main_ci" ]; then
245240
echo "Skipping BT simulator tests"
246241
fi
247242

248-
if [ "$matrix" = "1" ]; then
249-
# Run pytest-based testing for Python in matrix
250-
# builder 1. For now, this is just done for the west
251-
# extension commands, but additional directories which
252-
# run pytest could go here too.
253-
pytest=$(type -p pytest-3 || echo "pytest")
254-
mkdir -p $(dirname ${west_commands_results_file})
255-
PYTHONPATH=./scripts/west_commands "${pytest}" \
256-
--junitxml=${west_commands_results_file} \
257-
./scripts/west_commands/tests
258-
else
259-
echo "Skipping west command tests"
260-
fi
261-
262243
# cleanup
263244
rm -f test_file.txt
264245
touch test_file_1.txt test_file_2.txt

0 commit comments

Comments
 (0)