Skip to content

Commit

Permalink
Merge pull request #171 from MangaManagerORG/develop
Browse files Browse the repository at this point in the history
v1.0.2 Merge from develop
  • Loading branch information
ThePromidius authored Apr 5, 2023
2 parents 603d161 + d9c3af8 commit 228e024
Show file tree
Hide file tree
Showing 101 changed files with 5,968 additions and 4,656 deletions.
209 changes: 140 additions & 69 deletions .github/workflows/Run_Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,117 +9,188 @@ env:
$$_ENV_DEVELOPMENT_MM_$$: true
IMAGE_NAME: "thepromidius/manga-manager"
jobs:
build:
test_linux:
env:
DISPLAY: ":99.0"
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.11' ]
name: Python ${{ matrix.python-version }} sample
name: Python ${{ matrix.python-version }} - Linux
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- run: sudo apt install xvfb
- run: pip install -r requirements.txt
- name: Start xvfb
run: |
Xvfb :99 -screen 0 1920x1080x24 &disown
- name: Run the tests
run: |
python3 -m unittest discover -s MangaManager/tests -t MangaManager/
-
uses: actions/checkout@v3
-
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
-
run: sudo apt install xvfb
-
run: pip install -r requirements.txt
-
name: Start xvfb
run: |
Xvfb :99 -screen 0 1920x1080x24 &disown
-
name: Run the tests
run: |
cd MangaManager
python -m unittest discover -s tests -t .


# test_windows:
# env:
# DISPLAY: ":99.0"
# runs-on: windows-latest
# if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/test' }}
# strategy:
# matrix:
# python-version: [ '3.11' ]
# name: Python ${{ matrix.python-version }} - Windows
# steps:
# -
# uses: actions/checkout@v3
# -
# uses: actions/setup-python@v4
# with:
# python-version: ${{ matrix.python-version }}
# cache: 'pip'
# -
# run: pip install -r requirements.txt
# -
# name: Run the tests
# run: |
# cd MangaManager
# python -m unittest discover -s tests -t .
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
-
uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
docker_dev:
name: Nightly Build
needs: [ build, sonarcloud ]

parse_versions:
name: Parse Versions Env
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }}
outputs:
latest_commit: ${{ steps.latest_commit.outputs.latest_commit }}
release_commit: ${{ steps.release_commit.outputs.release_commit }}
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
push: true
tags: ${{ env.IMAGE_NAME }}:nightly
docker_stable:
name: Stable Build
needs: [ build, sonarcloud ]
- name: Checkout code
uses: actions/checkout@v3

- name: Set latest release commit hash (latest)
id: release_commit
run: |
release_url=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest)
tag_name=$(echo $release_url | jq -r '.tag_name')
tag_url=$(curl -s https://api.github.com/repos/${{ github.repository }}/git/ref/tags/$tag_name)
release_commit=$(echo $tag_url | jq -r '.object.sha')
short_release_commit=$(git rev-parse --short $release_commit)
echo "release_commit=$short_release_commit" >> $GITHUB_OUTPUT
- name: Set latest commit hash (develop)
id: latest_commit
run: |
latest_commit=$(git rev-parse --short HEAD)
echo "latest_commit=$latest_commit" >> $GITHUB_OUTPUT
docker_test:
name: Test and Build - Test Version
needs: [test_linux, sonarcloud, parse_versions]
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/test' }}
steps:
- name: Set up QEMU
-
name: Checkout
uses: actions/checkout@v3
-
name: Replace "nightly" with commit hash
run: |
file_contents=$(head -n 1 MangaManager/src/__version__.py)
new_contents="${file_contents/nightly/nightly:${{ needs.parse_versions.outputs.latest_commit }}}"
echo "$new_contents" > MangaManager/src/__version__.py
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
-
name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
-
name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ env.IMAGE_NAME }}:latest
docker_test:
name: Test Build
needs: [ build, sonarcloud ]
tags: ${{ env.IMAGE_NAME }}:test

docker_nightly:
name: Test and Build - Nightly Version
needs: [test_linux, sonarcloud, parse_versions ]
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/test' }}
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }}
steps:
- name: Set up QEMU
-
name: Checkout
uses: actions/checkout@v3
-
name: Replace "nightly" with commit hash
run: |
file_contents=$(head -n 1 MangaManager/src/__version__.py)
new_contents="${file_contents/nightly/nightly:${{ needs.parse_versions.outputs.latest_commit }}}"
echo "$new_contents" > MangaManager/src/__version__.py
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
-
name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
-
name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ env.IMAGE_NAME }}:test
docker_rework:
name: Rework Build
needs: [ build, sonarcloud ]
tags: ${{ env.IMAGE_NAME }}:nightly

docker_stable:
name: Stable Build
needs: [test_linux, sonarcloud ]
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/rework/master' }}
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
steps:
- name: Set up QEMU
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
-
name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
-
name: Build and push
uses: docker/build-push-action@v3
with:
push: true
tags: ${{ env.IMAGE_NAME }}:rework
tags: ${{ env.IMAGE_NAME }}:latest
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,6 @@ settings.ini
/MangaManager/dist

# From Tests
/MangaManager/*.cbz
/MangaManager/*.cbz
/.idea
/PYTHON_MANGA_MANAGER_WORKFLOW.vsdx
2 changes: 1 addition & 1 deletion .idea/runConfigurations/MangaManager.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 64 additions & 0 deletions BUILD.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
##$repoName = "Manga-Manager"
##$ownerName = "MangaManagerOrg"
### Get the latest release
##$latestRelease = Invoke-RestMethod -Uri "https://api.github.com/repos/$ownerName/$repoName/releases/latest"
### Get the branch or tag name of the commit where the latest release is tied to
##$latestReleaseBranchOrTagName = $latestRelease.target_commitish
### Get the short hash of the commit where the latest release is tied to
##$latestReleaseCommitHash = git rev-parse --short $latestReleaseBranchOrTagName
### Get the short hash of the latest commit in the develop branch
##$latestDevelopHash = git rev-parse --short develop
##
##$content = Get-Content .\MangaManager\src\__version__.py
##if ($content -match '(?<=__version__ = ")[^:"]+') {
## $newContent = $content -replace '__version__ = ".*"', "__version__ = `"$versionNumber:nightly--$latestReleaseCommitHash->$latestDevelopHash`""
## $newContent | Set-Content .\MangaManager\src\__version__.py
##}
##Write-Output $newContent
#$repoName = "Manga-Manager"
#$ownerName = "MangaManagerOrg"
## Get the latest release
#$latestRelease = Invoke-RestMethod -Uri "https://api.github.com/repos/$ownerName/$repoName/releases/latest"
## Get the branch or tag name of the commit where the latest release is tied to
#$latestReleaseBranchOrTagName = $latestRelease.target_commitish
## Get the short hash of the commit where the latest release is tied to
#$latestReleaseCommitHash = git rev-parse --short $latestReleaseBranchOrTagName
## Get the short hash of the latest commit in the develop branch
#$latestDevelopHash = git rev-parse --short develop
#
#$content = Get-Content .\MangaManager\src\__version__.py
#$versionRegex = '(?<=__version__ = ")[^:"]+'
#if ($content -match $versionRegex) {
# $versionNumber = $matches[0]
# $newContent = $content -replace '__version__ = ".*"', "__version__ = `"$versionNumber:nightly--$latestReleaseCommitHash->$latestDevelopHash`""
# $newContent | Set-Content .\MangaManager\src\__version__.py
#}
#Write-Output $newContent
$repoName = "Manga-Manager"
$ownerName = "MangaManagerOrg"
# Get the latest release
$latestRelease = Invoke-RestMethod -Uri "https://api.github.com/repos/$ownerName/$repoName/releases/latest"
# Get the branch or tag name of the commit where the latest release is tied to
$latestReleaseBranchOrTagName = $latestRelease.target_commitish
# Get the short hash of the commit where the latest release is tied to
$latestReleaseCommitHash = git rev-parse --short $latestReleaseBranchOrTagName
# Get the short hash of the latest commit in the develop branch
$latestDevelopHash = git rev-parse --short develop

$content = Get-Content .\MangaManager\src\__version__.py
$versionFile = ".\MangaManager\src\__version__.py"

# Read the current contents of the version file
$content = Get-Content $versionFile

# Update the commit hashes in the version file
$content | ForEach-Object {
if ($_ -match "^__version__ = '.*:stable$'") {
$_ -replace "(?<=[^-])-?[0-9a-f]{7,}?(?=-|->)", $latestReleaseCommitHash
} elseif ($_ -match "^__version__ = '.*:nightly$'") {
$_ -replace "(?<=[^-])-?[0-9a-f]{7,}?(?=-|->)", $latestDevelopHash
} else {
$_
}
} | Set-Content $versionFile
Write-Output $content
14 changes: 14 additions & 0 deletions DEVELOPMENT.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

## Versioning and building
When a build is to be made, copy the short hash of last commit and update it in `src/__version__.py`. After that make commit and push the version bump.

After that you can now create the build with the command below

## How to build:
`python -m PyInstaller .\MangaManager.spec --clean`

## Errors building with pyinstaller
If you can not run the build make sure all requirements are installed.
Pyinstaller does not use the virtual env requirements. So make sure the base python has them installed
Some of the requirements that gave me issues are:
- `chardet`
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ RUN apt-get update && \
xfce4 \
xubuntu-default-settings \
xubuntu-icon-theme \
unrar\
# Python \
idle-python3.11 \
python3-tk \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
from typing import final



class IExtensionApp(tkinter.Toplevel, metaclass=abc.ABCMeta):
"""
"""
name = None
embedded_ui = False
master_frame = None
master = None
_super= None
_super = None

@final
def __init__(self, master, super_=None, **kwargs):
"""
Expand Down
4 changes: 1 addition & 3 deletions MangaManager/Extensions/Template.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import logging

from Extensions.Interface import IExtensionApp
from src import settings_class
from Extensions.IExtensionApp import IExtensionApp

settings = settings_class.get_setting("main")
logger = logging.getLogger()


Expand Down
Loading

0 comments on commit 228e024

Please sign in to comment.