forked from udacity/nd0821-c3-starter-code
-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (55 loc) · 2.47 KB
/
python-app.yml
File metadata and controls
65 lines (55 loc) · 2.47 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
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python application
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest # Which OS this runs on
strategy:
matrix:
python-version: ["3.11.13"] # You can build against multiple Python versions
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }} # Name of an action that sets up Python
uses: actions/setup-python@v5 # https://github.com/actions/setup-python
with:
python-version: ${{ matrix.python-version }}
- name: Install and upgrade core tools
run: |
python -m pip install --upgrade pip
python -m pip install pip-tools
- name: Verify lockfile consistency (diagnostic mode)
run: |
echo "Generating requirements.txt from source to check for differences..."
pip-compile --quiet requirements.in -o requirements.txt
echo "Comparing the generated file with the one in the repository:"
# 'git diff' will show any diff's. '|| true' ensures the step doesn't fail.
git diff requirements.txt || true
- name: Install Python dependencies from lockfile
run: |
echo "Installing dependencies from requirements.txt..."
if [ -f requirements.txt ]; then python -m pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
# DVC iterative setup installation path is not working (Nov 2024), now happens via requirement.txt
# - name: DVC install # see: https://github.com/iterative/setup-dvc
# uses: iterative/setup-dvc@v1
# - name: DVC
# run: |
# # see: https://dvc.org/doc/user-guide/troubleshooting#missing-files,
# # no remote cloud service available yet
# dvc pull
- name: Test with pytest
run: |
# Final action: runs pytest for all tests in the ./tests dir
pytest ./tests/*.py -vv