Skip to content

Commit

Permalink
Merge pull request #2 from kleo-53/ci_setup
Browse files Browse the repository at this point in the history
Setting up CI
  • Loading branch information
kleo-53 authored Sep 13, 2023
2 parents f424a03 + 7eb6367 commit b4c029a
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 22 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/black-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Format code with Black

on:
push:
branches:
- main

jobs:
format-code:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.10.12

- name: Install Black
run: |
python -m pip install --upgrade pip
pip install black
- name: Run Black
run: black pioneer_uploader.py

- name: Commit and Push Changes
run: |
git add pioneer_uploader.py
git commit -m "Format code with Black"
git push
20 changes: 13 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,25 @@ jobs:

- name: Install dependencies
run: pip install -r requirements.txt

- name: Format code with Black
run: black pioneer-uploader.py
- name: Install PyInstaller
run: pip install pyinstaller

- name: Build with PyInstaller
run: pyinstaller --onefile pioneer-uploader.py
run: pyinstaller --onefile pioneer_uploader.py

- name: Install pytest
run: pip install pytest

- name: Run tests
run:
export PYTHONPATH=$PYTHONPATH:$GITHUB_WORKSPACE
pytest

- name: Publish artifact
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v2
with:
name: publish-artifact
name: pioneer-uploader.exe
path: dist

- name: Run tests
run: pytest
15 changes: 0 additions & 15 deletions test/test_uploader.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from pathlib import Path

import pytest
import pioneer_uploader
from unittest.mock import patch
Expand All @@ -21,18 +19,5 @@ def test_few_arguments(mock_logging_error):
mock_logging_error.assert_called_once_with("Invalid arguments")


@patch("logging.error")
def test_correct_arguments(mock_logging_error):
current_file = Path(__file__).resolve()
file = current_file.parent/'test_file.lua'
print(file)
test_args = ["parameter", file, "127.0.0.1", "8888", "wifi"]
with patch('sys.argv', test_args):
with pytest.raises(ConnectionResetError):
pioneer_uploader.main()
# mock_logging_error.assert_called_once_with(ConnectionResetError(10054,
# 'An existing connection was forcibly closed by the remote host', None, 10054, None))


if __name__ == "__main__":
pytest.main()

0 comments on commit b4c029a

Please sign in to comment.