Skip to content

Commit

Permalink
Fix binary build process & add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowmoose committed Jul 11, 2020
1 parent e07296e commit 6ac9129
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 27 deletions.
59 changes: 36 additions & 23 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ jobs:
- os: windows-latest
artifact: RMD-windows.exe
path: ./dist/RedditDownloader.exe
run_test: ./dist/RedditDownloader.exe --skip_update --run_tests=*
- os: ubuntu-16.04
artifact: RMD-ubuntu
path: ./dist/RedditDownloader
run_test: chmod +x ./dist/RedditDownloader && ./dist/RedditDownloader --skip_update --run_tests=*
- os: macOS-latest
artifact: RMD-macOS
path: ./dist/RedditDownloader
run_test: chmod +x ./dist/RedditDownloader && ./dist/RedditDownloader --skip_update --run_tests=*

steps:
- name: Check for Required Package Updates
Expand Down Expand Up @@ -62,12 +65,22 @@ jobs:
run: |
pip install -r requirements.txt
pip install -r requirements-dev.txt
pip install --upgrade 'setuptools>=49.1.1'
- name: Build with PyInstaller
if: steps.update.outputs.update_available == 'true'
run: |
pyinstaller build-rmd.spec
- name: Run Unit Tests
if: steps.update.outputs.update_available == 'true'
run: |
${{matrix.run_test}}
env:
RMD_REFRESH_TOKEN: ${{secrets.RMD_REFRESH_TOKEN}}
RMD_IMGUR_ID: ${{secrets.RMD_IMGUR_ID}}
RMD_IMGUR_SECRET: ${{secrets.RMD_IMGUR_SECRET}}

- name: Upload binaries to release
if: steps.update.outputs.update_available == 'true'
uses: svenstaro/[email protected]
Expand All @@ -79,27 +92,27 @@ jobs:
tag: ${{ steps.update.outputs.release_tag }}


# update-release-info:
# name: Update Artifact Metadata
# runs-on: ubuntu-latest
# needs: [publish]
# steps:
# - name: Build Data File
# uses: shadowmoose/[email protected]
# id: build
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# outFile: ./_public/release.json
# owner: shadowmoose
# repo: RedditDownloader
update-release-info:
name: Update Artifact Metadata
runs-on: ubuntu-latest
needs: [publish]
steps:
- name: Build Data File
uses: shadowmoose/[email protected]
id: build
with:
token: ${{ secrets.GITHUB_TOKEN }}
outFile: ./_public/release.json
owner: shadowmoose
repo: RedditDownloader

# - name: Deploy to release-metadata branch
# if: steps.build.outputs.is_released == 'true'
# uses: peaceiris/[email protected]
# env:
# ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
# PUBLISH_BRANCH: release-metadata-3.x
# PUBLISH_DIR: ./_public
# with:
# username: "shadow-bot"
# useremail: "[email protected]"
- name: Deploy to release-metadata branch
if: steps.build.outputs.is_released == 'true'
uses: peaceiris/[email protected]
env:
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
PUBLISH_BRANCH: release-metadata-3.x
PUBLISH_DIR: ./_public
with:
username: "shadow-bot"
useremail: "[email protected]"
1 change: 1 addition & 0 deletions redditdownloader/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from interfaces.terminal import TerminalUI
from interfaces.eelwrapper import WebUI
import tests.runner
import tests.mock
import sql
from tools import ffmpeg_download
import static.filesystem as fs
Expand Down
19 changes: 15 additions & 4 deletions redditdownloader/tests/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,24 @@
"""
import unittest
import os
import sys


application_base = getattr(sys, '_MEIPASS', os.path.abspath(os.path.join(os.path.realpath(__file__), '../../')))
application_path = getattr(sys, '_MEIPASS', os.path.abspath(os.path.join(os.path.realpath(__file__), '../../../')))


def run_tests(test_subdir):
if '*' in test_subdir or not test_subdir:
test_subdir = '' # Run all tests in directory.
print("Running %s tests" % (test_subdir if test_subdir else 'all'))
base_dir = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
tests = unittest.TestLoader().discover('redditdownloader/tests/'+test_subdir, top_level_dir=base_dir)
stats = unittest.TextTestRunner(verbosity=1, buffer=True).run(tests)
if getattr(sys, 'frozen', False):
subdir = 'tests/'
else:
subdir = 'redditdownloader/tests/'

test_path = os.path.join(application_path, subdir, test_subdir)
print("Running tests in %s" % test_path)

tests = unittest.TestLoader().discover(test_path, top_level_dir=application_base)
stats = unittest.TextTestRunner(verbosity=2, buffer=True).run(tests)
return len(stats.failures)

0 comments on commit 6ac9129

Please sign in to comment.