Skip to content

Commit

Permalink
Refactor Pylint workflow and update configuration
Browse files Browse the repository at this point in the history
- Refactor the Pylint workflow to include Python versions 3.9, 3.10, and 3.11.
- Update the Pylint configuration to disable the E0015 check.

Resolves: #issue-number
  • Loading branch information
Tinny-Robot committed Oct 30, 2024
1 parent 83cd294 commit 7a1219d
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 11 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -26,5 +26,12 @@ jobs:
python -m pip install --upgrade pip
pip install pylint
- name: Run pylint
id: pylint
run: |
pylint --rcfile=.pylintrc $(git ls-files '*.py')
pylint --rcfile=.pylintrc $(git ls-files '*.py') > pylint_output.txt || true
score=$(tail -n 2 pylint_output.txt | head -n 1 | grep -oP '\d+\.\d+')
echo "Pylint score: $score"
if (( $(echo "$score < 8" | bc -l) )); then
echo "Pylint score is less than 8. Failing the job."
exit 1
fi
3 changes: 2 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,8 @@ disable=raw-checker-failed,
deprecated-pragma,
use-symbolic-message-instead,
use-implicit-booleaness-not-comparison-to-string,
use-implicit-booleaness-not-comparison-to-zero
use-implicit-booleaness-not-comparison-to-zero,
E0015

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
2 changes: 1 addition & 1 deletion core/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Initialization for the main core module
# Initialization for the main core module
7 changes: 6 additions & 1 deletion core/audio_processing.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
'''This module provides functionality to extract audio from video files.
Functions:
extract_audio(video_path, output_audio_path):'''

from moviepy.editor import VideoFileClip

def extract_audio(video_path, output_audio_path):
Expand All @@ -16,5 +21,5 @@ def extract_audio(video_path, output_audio_path):
audio.write_audiofile(output_audio_path)
audio.close()
video.close()

return output_audio_path
7 changes: 7 additions & 0 deletions core/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
"""
This module provides utility functions.
Functions:
check_file_exists(file_path): Checks if a file exists at the given file path.
"""

import os

def check_file_exists(file_path):
Expand Down
8 changes: 7 additions & 1 deletion core/video_processing.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
"""
This module contains functions for processing videos.
Functions:
resize_video(video_path, output_video_path, width, height):
"""

from moviepy.editor import VideoFileClip

def resize_video(video_path, output_video_path, width, height):
Expand All @@ -18,5 +25,4 @@ def resize_video(video_path, output_video_path, width, height):
resized_video.write_videofile(output_video_path)
resized_video.close()
video.close()

return output_video_path
8 changes: 6 additions & 2 deletions tests/test_audio_processing.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
'''Test cases for the audio processing functions.'''

import unittest
import os
from core.audio_processing import extract_audio

class TestAudioProcessing(unittest.TestCase):

'''Test cases for the audio processing functions.'''
def setUp(self):
# Paths to test files (replace these with actual test paths as needed)
self.video_path = "tests/files/test_video.mp4"
self.output_audio_path = "tests/files/test_audio.mp3"

def test_extract_audio(self):
'''Test the extract_audio function.'''
# Run the extract_audio function and capture the returned path
result_path = extract_audio(self.video_path, self.output_audio_path)

# Check if the returned path is correct and if the file was created
self.assertEqual(result_path, self.output_audio_path)
self.assertTrue(os.path.exists(result_path))

def tearDown(self):
'''Clean up the test files after tests.'''
# Cleanup test files
if os.path.exists(self.output_audio_path):
os.remove(self.output_audio_path)
Expand Down
17 changes: 14 additions & 3 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
'''
This module contains the test cases for the utility functions.
'''

import unittest
import os
from core.utils import check_file_exists

class TestUtils(unittest.TestCase):
"""Test cases for the utility functions.
Functions:
test_check_file_exists(self): Test the check_file_exists function.
"""

def setUp(self):
self.existing_file = "tests/files/existing_file.txt"
self.non_existing_file = "tests/files/non_existing_file.txt"

# Create a dummy file for testing
with open(self.existing_file, 'w') as f:
with open(self.existing_file, 'w', encoding='utf-8') as f:
f.write("Test content")

def test_check_file_exists(self):
"""
Test the check_file_exists function."""
# Test with an existing file
self.assertTrue(check_file_exists(self.existing_file))

# Test with a non-existing file
self.assertFalse(check_file_exists(self.non_existing_file))

Expand Down
6 changes: 6 additions & 0 deletions tests/test_video_processing.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
'''
This file contains the unit tests for the video_processing module.
'''

import unittest
import os
from core.video_processing import resize_video

class TestVideoProcessing(unittest.TestCase):
'''Test cases for the video processing functions.'''

def setUp(self):
self.video_path = "tests/files/test_video.mp4"
Expand All @@ -11,6 +16,7 @@ def setUp(self):
self.height = 360

def test_resize_video(self):
'''Test the resize_video function.'''
result_path = resize_video(self.video_path, self.output_video_path, self.width, self.height)
self.assertEqual(result_path, self.output_video_path)
self.assertTrue(os.path.exists(result_path))
Expand Down

0 comments on commit 7a1219d

Please sign in to comment.