forked from ham-radio-software/D-Rats
-
Notifications
You must be signed in to change notification settings - Fork 1
executable file
·75 lines (67 loc) · 2.43 KB
/
Copy pathpython_unit_tests.yml
File metadata and controls
executable file
·75 lines (67 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
---
name: python_unit_tests
# Always run on Pull Requests
on: # yamllint disable-line rule:truthy
pull_request:
jobs:
get_files:
runs-on: ubuntu-latest
outputs:
changed_files_list: ${{ steps.get-changed-files.outputs.files }}
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch-depth 0 is required for diffing
- name: Get changed Python files
id: get-changed-files
run: |
# Use git diff to find changed files and format them as a
# newline-separated string
changed="$(git diff --name-only --diff-filter=ACMRT HEAD~1 HEAD |\
grep '.*\.py$' | tr '\n' ' ')"
echo "changed files = $changed"
# Set the string as a step output
echo "files=$changed" >> $GITHUB_OUTPUT
- name: Display changed files (in the same job)
run: |
echo "Changed files in this job:"
echo "${{ steps.get-changed-files.outputs.files }}"
shell: bash
python_unit_tests:
needs: [get_files]
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
# Define additional variables for different target platforms or
# configurations
target: [x86_64, arm64]
# Optional: set fail-fast to false to allow all jobs to complete
# even if one fails
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Python 3
uses: actions/setup-python@v5 # Action to set up Python
with:
cache: 'pip' # Caches dependencies for faster subsequent runs
- name: Install dependencies
# The conditional check differs slightly between shells
# (Linux/macOS vs. Windows)
run: |
REQUIREMENTS_FILE="workflow/${{ runner.os }}/requirements.txt"
if [ -f "$REQUIREMENTS_FILE" ]; then
python -m pip install --upgrade pip
pip install -r "$REQUIREMENTS_FILE"
fi
shell: bash # Explicitly use bash for consistency on
# Linux/macOS/Windows runners
- name: Run unit test script
# GitHub VS-CODE plugin false positive
run: |
files="${{ needs.get_files.outputs.changed_files_list }}"
export CHANGED_FILES="$files"
./tests/pre-commit_d/python_unit_tests.sh
shell: bash