generated from amazon-archives/__template_MIT-0
-
Notifications
You must be signed in to change notification settings - Fork 112
82 lines (71 loc) · 2.4 KB
/
python-app.yml
File metadata and controls
82 lines (71 loc) · 2.4 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
76
77
78
79
80
81
82
# 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 Pattern Submission Workflow
on:
push:
paths:
- "python-test-samples/**"
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed files using defaults
id: get_changed
uses: tj-actions/changed-files@e9772d140489982e0e3704fea5ee93d536f1e275
with:
separator: ","
- name: Echo changed files
id: setfiles
run: |
files=${{ steps.get_changed.outputs.all_changed_files }}
echo $files
echo "FILES=$files" >> $GITHUB_OUTPUT
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Get new folder
id: setfolders
run: |
python -m pip install --upgrade pip
pip install github-action-utils
python .github/workflows/getPatternFolder.py "${{ steps.setfiles.outputs.FILES }}"
- name: Install dependencies
run: |
for folder in ${{ steps.setfolders.outputs.folders }}
do
cd $folder
pip install flake8 pytest boto3
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f tests/requirements.txt ]; then pip install -r tests/requirements.txt; fi
cd -
done
- name: Lint with flake8
run: |
for folder in ${{ steps.setfolders.outputs.folders }}
do
cd $folder
# 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
cd -
done
- name: Test with pytest
run: |
for folder in ${{ steps.setfolders.outputs.folders }}
do
cd $folder
# Set dummy values to keep botocore happy
export AWS_DEFAULT_REGION=us-east-1
export AWS_ACCESS_KEY_ID=fake
export AWS_SECRET_ACCESS_KEY=fake
pytest -s tests/unit -v
cd -
done