Skip to content

Commit

Permalink
feat: update ci
Browse files Browse the repository at this point in the history
  • Loading branch information
dreulavelle committed Mar 26, 2024
1 parent 51ce641 commit 64d18bf
Show file tree
Hide file tree
Showing 20 changed files with 617 additions and 294 deletions.
36 changes: 36 additions & 0 deletions .github/ISSUE_TEMPLATE/---bug-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: "\U0001F41E Bug Report"
labels: ["kind/bug", "status/triage"]
description: "Rank Torrent Name (RTN) not working the way it is documented?"

body:
- type: markdown
attributes:
value: |
Thank you for taking the time to file a complete bug report.
- type: textarea
attributes:
label: Description
description: |
Please describe what happened, with as much pertinent information as you can. Feel free to use markdown syntax.
Also, ensure that the issue is not already fixed in the latest release.
validations:
required: true

- type: textarea
attributes:
label: Workarounds
description: |
Is there a mitigation or workaround that allows users to avoid the issue today?
validations:
required: true

- type: textarea
attributes:
label: Attach Error Logs
description: |
Please attach logs or error messages that can help in debugging the issue.
render: 'bash session'
validations:
required: true
50 changes: 50 additions & 0 deletions .github/ISSUE_TEMPLATE/---feature-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: "\U0001F381 Feature Request"
labels: ["kind/feature", "status/triage"]
description: "Did you find bugs, errors, or anything that isn't straightforward in the documentation?"

body:
- type: markdown
attributes:
value: |
Thank you for taking the time to file a complete bug report.
Before submitting your issue, please search [issues](https://github.com/dreulavelle/rank-torrent-name/issues) to ensure this is not a duplicate.
If the issue is trivial, why not submit a pull request instead?
- type: dropdown
attributes:
label: Issue Kind
description: |
What best describes this issue?
options:
- "New Feature Request"
- "Change in current behaviour"
- "Other"
validations:
required: true

- type: textarea
attributes:
label: Description
description: |
Please describe the issue, with as much pertinent information as you can. Feel free to use markdown syntax.
validations:
required: true

- type: textarea
attributes:
label: Impact
description: |
Please describe the motivation for this issue. Describe, as best you can, how this improves or impacts the users of RTN and why this is important.
validations:
required: true

- type: textarea
attributes:
label: Workarounds
description: |
Is there a mitigation, workaround, or another application that allows users to achieve the same functionality today?
validations:
required: true
54 changes: 54 additions & 0 deletions .github/ISSUE_TEMPLATE/---maintainers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: "\U0001F41E Bug Report"
labels: ["kind/maintainer", "status/triage"]
description: "Want to help in the development of Rank Torrent Name (RTN)?"

body:
- type: markdown
attributes:
value: |
Thank you for taking the time to file a complete bug report.
- type: dropdown
attributes:
label: Experience
description: |
Do you have experience in Python?
options:
- "Yes"
- "No"
- "Willing to learn"
- "I bring experience in another area"
- "Other"
validations:
required: true

- type: dropdown
attributes:
label: Operating System
description: |
What Operating System are you using?
options:
- "Windows"
- "macOS"
- "Linux"
- "Other"
validations:
required: true

- type: textarea
attributes:
label: Description
description: |
What can you do to help in the development of RTN? Feel free to use markdown syntax.
Do you have experience in testing, documentation, or any other area that can help in development?
validations:
required: true

- type: textarea
attributes:
label: What can you do?
description: |
Please describe what you can do to help in the development of RTN.
validations:
required: true
11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Ref: https://help.github.com/en/github/building-a-strong-community/configuring-issue-templates-for-your-repository#configuring-the-template-chooser
blank_issues_enabled: false
contact_links:
- name: '💬 Discussions'
url: https://github.com/dreulavelle/rank-torrent-name/discussions
about: |
Ask questions about using Rank Torrent Name (RTN), features and roadmap, or get support and feedback for your usage of RTN.
- name: '💬 Discord Server'
url: https://discord.gg/38SFhtN8ph
about: |
Chat with the community and RTN maintainers about both the usage of and development of the project.
8 changes: 8 additions & 0 deletions .github/workflows/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Pull Request Check List

Resolves: #issue-number-here

- [ ] Added **tests** for changed code.
- [ ] Updated **documentation** for changed code.

<!-- If you have *any* questions to *any* of the points above, just **submit and ask**! This checklist is here to *help* you, not to deter you from contributing! -->
44 changes: 44 additions & 0 deletions .github/workflows/battery.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Run Battery of Checks

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, 3.10, 3.11, 3.12]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install poetry
poetry install
- name: Lint with Ruff
run: poetry run ruff check ./RTN
- name: Check imports with isort
run: poetry run isort --check-only ./RTN
- name: Type check
run: poetry run pyright
- name: Run Tests
run: poetry run pytest
- name: Coverage Report
run: |
poetry run coverage run -m pytest
poetry run coverage xml
poetry run coverage report -m
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
45 changes: 45 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: "CodeQL"

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
paths:
- RTN
paths-ignore:
- '**/*.md'
- '**/*.txt'
- '**/*.json'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'python' ]
# For more customization, see: https://docs.github.com/en/code-security/secure-coding/configuring-code-scanning

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

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
# Optional. Specify a category to distinguish between multiple analyses
# for the same tool and ref. If you don't use `category` in your workflow,
# GitHub will generate a default category name for you
category: "rtn"
12 changes: 12 additions & 0 deletions .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2

updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "monthly"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish Python Package to PyPI
name: Publish RTN to PyPI

on:
push:
Expand Down
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Performance Benchmarking

We use `pyperf` for performance benchmarking to ensure that changes do not adversely affect the performance of RTN. If you're making changes that might impact performance, please run the benchmarks with:

```bash
make benchmark
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: install lint format check test clean coverage pr-ready publish
.PHONY: install lint format check test clean coverage benchmark pr-ready publish

SRC_DIR := ./RTN

Expand All @@ -15,7 +15,7 @@ clean:

# Run linters
lint:
poetry run ruff $(SRC_DIR)
poetry run ruff check $(SRC_DIR)
poetry run isort --check-only $(SRC_DIR)

# Format code
Expand All @@ -37,6 +37,9 @@ coverage:
@poetry run coverage html
@poetry run coverage report -m

benchmark:
poetry run python benchmarks/rank.py

pr-ready: clean format lint check test

publish:
Expand Down
2 changes: 1 addition & 1 deletion RTN/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
"ParsedData",
"BaseRankingModel",
"DefaultRanking",
"SettingsModel"
"SettingsModel",
]
14 changes: 8 additions & 6 deletions RTN/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ def check_fetch(data: ParsedData, settings: SettingsModel) -> bool:
if not check_trash(data.raw_title):
return False
if settings.require and any(
pattern.search(data.raw_title) for pattern in settings.require if pattern # type: ignore
pattern.search(data.raw_title) for pattern in settings.require if pattern # type: ignore
):
return True
if settings.exclude and any(
pattern.search(data.raw_title) for pattern in settings.exclude if pattern # type: ignore
pattern.search(data.raw_title) for pattern in settings.exclude if pattern # type: ignore
):
return False
return all(
Expand All @@ -33,6 +33,7 @@ def check_fetch(data: ParsedData, settings: SettingsModel) -> bool:
]
)


def fetch_quality(data: ParsedData, settings: SettingsModel) -> bool:
"""Check if the quality is fetchable based on user settings."""
if not settings.custom_ranks["webdl"].fetch and "WEB-DL" in data.quality:
Expand All @@ -45,6 +46,7 @@ def fetch_quality(data: ParsedData, settings: SettingsModel) -> bool:
return False
return True


def fetch_resolution(data: ParsedData, settings: SettingsModel) -> bool:
"""Check if the resolution is fetchable based on user settings."""
if data.is_4k and not settings.custom_ranks["uhd"].fetch:
Expand All @@ -53,20 +55,19 @@ def fetch_resolution(data: ParsedData, settings: SettingsModel) -> bool:
return False
if "720p" in data.resolution and not settings.custom_ranks["hd"].fetch:
return False
if (
any(res in data.resolution for res in ["576p", "480p"])
and not settings.custom_ranks["sd"].fetch
):
if any(res in data.resolution for res in ["576p", "480p"]) and not settings.custom_ranks["sd"].fetch:
return False
return True


def fetch_codec(data: ParsedData, settings: SettingsModel) -> bool:
"""Check if the codec is fetchable based on user settings."""
# May add more to this later...
if not settings.custom_ranks["av1"].fetch and "AV1" in data.codec:
return False
return True


def fetch_audio(data: ParsedData, settings: SettingsModel) -> bool:
"""Check if the audio is fetchable based on user settings."""
if not data.audio:
Expand Down Expand Up @@ -94,6 +95,7 @@ def fetch_audio(data: ParsedData, settings: SettingsModel) -> bool:
return False
return True


def fetch_other(data: ParsedData, settings: SettingsModel) -> bool:
"""Check if the other data is fetchable based on user settings."""
if not settings.custom_ranks["proper"].fetch and data.proper:
Expand Down
Loading

0 comments on commit 64d18bf

Please sign in to comment.