Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/main-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Main Tests

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
test-commits:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Create test list file
run: echo "isaacs/github" > test_list.txt

- name: Run main.py and save output (commits)
run: python main.py --commits -l test_list.txt -o output_commits.csv -t ${{ secrets.GITHUB_TOKEN }}
- name: Compare output with reference CSV (commits)
run: |
if [ ! -f output_commits.csv ]; then
echo 'output_commits.csv not found, skipping compare.'
exit 1
fi
python compare_csv.py output_commits.csv .github/workflows/reference_commits.csv

- name: Run main.py and save output (contributors)
run: python main.py --contributors -l test_list.txt -o output_contributors.csv -t ${{ secrets.GITHUB_TOKEN }}
- name: Compare output with reference CSV (contributors)
run: |
if [ ! -f output_contributors.csv ]; then
echo 'output_contributors.csv not found, skipping compare.'
exit 1
fi
python compare_csv.py output_contributors.csv .github/workflows/reference_contributors.csv

- name: Run main.py and save output (issues)
run: python main.py --issues -l test_list.txt -o output_issues.csv -t ${{ secrets.GITHUB_TOKEN }}
- name: Compare output with reference CSV (issues)
run: |
if [ ! -f output_issues.csv ]; then
echo 'output_issues.csv not found, skipping compare.'
exit 1
fi
python compare_csv.py output_issues.csv .github/workflows/reference_issues.csv

- name: Run main.py and save output (pulls)
run: python main.py -p -l test_list.txt -o output_pulls.csv -t ${{ secrets.GITHUB_TOKEN }}
- name: Compare output with reference CSV (pulls)
run: |
if [ ! -f output_pulls.csv ]; then
echo 'output_pulls.csv not found, skipping compare.'
exit 1
fi
python compare_csv.py output_pulls.csv .github/workflows/reference_pulls.csv

43 changes: 43 additions & 0 deletions compare_csv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import csv
import sys


def compare_csv_files(actual_path, expected_path):
with open(actual_path, newline='', encoding='utf-8') as actual_file, \
open(expected_path, newline='', encoding='utf-8') as expected_file:
actual_reader = csv.DictReader(actual_file)
expected_reader = csv.DictReader(expected_file)

actual_rows = list(actual_reader)
expected_rows = list(expected_reader)

common_fields = set(actual_reader.fieldnames) & set(expected_reader.fieldnames)
if not common_fields:
print('Нет общих столбцов для сравнения!')
sys.exit(1)

def rows_to_set(rows):
return set(tuple(row[field] for field in sorted(common_fields)) for row in rows)

actual_set = rows_to_set(actual_rows)
expected_set = rows_to_set(expected_rows)

if actual_set != expected_set:
print('Файлы отличаются по общим столбцам:')
print('Только в output.csv:')
for row in actual_set - expected_set:
print(row)
print('Только в reference.csv:')
for row in expected_set - actual_set:
print(row)
sys.exit(1)
else:
print('Файлы совпадают по общим столбцам.')


if __name__ == "__main__":
if len(sys.argv) != 3:
print(f"Usage: python {sys.argv[0]} <actual_csv> <expected_csv>")
sys.exit(1)
compare_csv_files(sys.argv[1], sys.argv[2])

Loading