Skip to content

Commit 1d04b7d

Browse files
Fix: Add requirements.txt, improve script error handling, and add CI workflow
1 parent f6b8f4c commit 1d04b7d

3 files changed

Lines changed: 35 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Python CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Set up Python
15+
uses: actions/setup-python@v5
16+
with:
17+
python-version: '3.11'
18+
- name: Install dependencies
19+
run: |
20+
python -m pip install --upgrade pip
21+
pip install -r requirements.txt
22+
- name: Lint with flake8
23+
run: |
24+
pip install flake8
25+
# stop the build if there are Python syntax errors or undefined names
26+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
27+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
28+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PyYAML>=6.0.1

scripts/execute_api_request.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import sys
22
import os
33
import json
4-
import yaml
54
import subprocess
65
import re
76

7+
try:
8+
import yaml
9+
except ImportError:
10+
print("Error: PyYAML is not installed. Please run 'pip install PyYAML'.")
11+
sys.exit(1)
12+
813
def execute_request(file_path):
914
if not os.path.exists(file_path):
1015
print(f"Error: File {file_path} not found.")

0 commit comments

Comments
 (0)