-
Notifications
You must be signed in to change notification settings - Fork 76
67 lines (54 loc) · 1.87 KB
/
pytest-tests.yml
File metadata and controls
67 lines (54 loc) · 1.87 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
# This workflow will install Python dependencies, run tests and pre-commit hook
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Run Unit Test via Pytest
on:
pull_request:
branches: ["develop"]
# allows to manually start a workflow run from the GitHub UI or using the GitHub API.
workflow_dispatch:
permissions:
contents: read
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.11"]
runs-on: ${{ matrix.os }}
steps:
- name: Disable Git AutoCRLF
run: git config --global core.autocrlf false
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
# Removed manual venv creation (was Linux-only and breaks on Windows)
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ".[dev]"
- name: Get changed files
shell: bash
id: changed-files
run: |
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | tr '\n' ' ')
echo "CHANGED_FILES=${CHANGED_FILES}" >> $GITHUB_ENV
- name: Print changed files
shell: bash
run: |
echo "Changed files:" && echo "$CHANGED_FILES" | tr ' ' '\n'
- name: Run pre-commit on changed files
shell: bash
run: |
if [ -n "$CHANGED_FILES" ]; then
pre-commit run --color always --files $CHANGED_FILES --show-diff-on-failure
else
echo "No changed files to check."
fi
- name: Run tests
run: |
pytest src/tests