Skip to content

Commit

Permalink
Merge branch 'master' into frontend-release
Browse files Browse the repository at this point in the history
  • Loading branch information
ndepaola committed Aug 6, 2024
2 parents cb5e192 + c55089a commit 6538ea7
Show file tree
Hide file tree
Showing 21 changed files with 286 additions and 162 deletions.
4 changes: 2 additions & 2 deletions .github/actions/test-backend/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ runs:
steps:
- uses: browser-actions/setup-chrome@latest
- name: Set up Python 3.9
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install Python dependencies
Expand All @@ -29,7 +29,7 @@ runs:
run: sudo systemctl start elasticsearch.service
shell: bash
- name: Write Google Drive API credentials to file
uses: jsdaniell/create-json@1.1.2
uses: jsdaniell/create-json@v1.2.3
with:
name: "client_secrets.json"
json: ${{ inputs.google-drive-api-key }}
Expand Down
6 changes: 3 additions & 3 deletions .github/actions/test-desktop-tool/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ runs:
chrome-version: stable
- uses: browser-actions/setup-edge@latest
with:
edge-version: stable
edge-version: beta # beta version seems to work more consistently for linux CI
- name: Fix macOS Chromedriver
if: runner.os == 'macOS'
run: |
rm /usr/local/bin/chromedriver
shell: bash
- name: Set up Python 3.9
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install Python dependencies
Expand All @@ -26,7 +26,7 @@ runs:
pip install -r requirements.txt
shell: bash
- name: Write Google Drive API credentials to file
uses: jsdaniell/create-json@1.1.2
uses: jsdaniell/create-json@v1.2.3
with:
name: "client_secrets.json"
json: ${{ inputs.google-drive-api-key }}
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/test-frontend/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ runs:
using: composite
steps:
- name: Install npm
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.15
- name: Compile frontend
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/test-pre-commit/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ runs:
using: composite
steps:
- name: Set up Python 3.9
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install pre-commit
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/auto-author-assign.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ jobs:
assign-author:
runs-on: ubuntu-latest
steps:
- uses: toshimaru/auto-author-assign@v1.6.2
- uses: toshimaru/auto-author-assign@v2.2.1
15 changes: 9 additions & 6 deletions .github/workflows/build-desktop-tool.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ jobs:
strategy:
matrix:
include:
- os: macos-13 # TODO: revert back to macos-latest when https://github.com/actions/setup-python/issues/852 is fixed
TARGET: macos
- os: macos-latest
TARGET: macos-arm
OUT_FILE_NAME: autofill
- os: macos-12
TARGET: macos-intel
OUT_FILE_NAME: autofill
- os: windows-latest
TARGET: windows
Expand All @@ -24,26 +27,26 @@ jobs:
TARGET: linux
OUT_FILE_NAME: autofill
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: browser-actions/setup-chrome@latest
- name: Set up Python 3.9
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Write Google Drive API credentials to file
uses: jsdaniell/create-json@1.1.2
uses: jsdaniell/create-json@v1.2.3
with:
name: "client_secrets.json"
json: ${{ secrets.GOOGLE_DRIVE_API_KEY }}
dir: "desktop-tool/"
- name: Build with pyinstaller for ${{ matrix.TARGET }}
run: pyinstaller autofill.spec
- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
path: ./desktop-tool/dist/${{ matrix.OUT_FILE_NAME }}
name: autofill-${{ matrix.TARGET }}
2 changes: 1 addition & 1 deletion .github/workflows/build-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install npm
uses: actions/setup-node@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
ports:
- 5432:5432
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/test-backend
with:
google-drive-api-key: ${{ secrets.GOOGLE_DRIVE_API_KEY }}
4 changes: 2 additions & 2 deletions .github/workflows/test-desktop-tool.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
strategy:
matrix:
include:
- os: macos-13 # TODO: revert back to macos-latest when https://github.com/actions/setup-python/issues/852 is fixed
- os: macos-latest
- os: windows-latest
- os: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/test-desktop-tool
with:
google-drive-api-key: ${{ secrets.GOOGLE_DRIVE_API_KEY }}
2 changes: 1 addition & 1 deletion .github/workflows/test-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ jobs:
name: Frontend tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/test-frontend
2 changes: 1 addition & 1 deletion .github/workflows/test-pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ jobs:
name: Formatting and static type checking
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/test-pre-commit
10 changes: 5 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
ports:
- 5432:5432
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/test-backend
with:
google-drive-api-key: ${{ secrets.GOOGLE_DRIVE_API_KEY }}
Expand All @@ -32,23 +32,23 @@ jobs:
strategy:
matrix:
include:
- os: macos-13 # TODO: revert back to macos-latest when https://github.com/actions/setup-python/issues/852 is fixed
- os: macos-latest
- os: windows-latest
- os: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/test-desktop-tool
with:
google-drive-api-key: ${{ secrets.GOOGLE_DRIVE_API_KEY }}
test-frontend:
name: Frontend tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/test-frontend
test-pre-commit:
name: Formatting and static type checking
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/test-pre-commit
7 changes: 6 additions & 1 deletion desktop-tool/autofill.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from src.pdf_maker import PdfExporter
from src.processing import ImagePostProcessingConfig
from src.utils import bold
from src.web_server import WebServer

# https://stackoverflow.com/questions/12492810/python-how-can-i-make-the-ansi-escape-codes-to-work-also-in-windows
os.system("") # enables ansi escape characters in terminal
Expand Down Expand Up @@ -159,8 +160,12 @@ def main(
card_orders = aggregate_and_split_orders(
orders=CardOrder.from_xmls_in_folder(), target_site=target_site, combine_orders=combine_orders
)
web_server = WebServer()
AutofillDriver(
browser=Browsers[browser], target_site=target_site, binary_location=binary_location
browser=Browsers[browser],
target_site=target_site,
binary_location=binary_location,
starting_url=web_server.server_url(),
).execute_orders(
orders=card_orders,
auto_save_threshold=auto_save_threshold if auto_save else None,
Expand Down
2 changes: 1 addition & 1 deletion desktop-tool/autofill.spec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ block_cipher = None

a = Analysis(['autofill.py'],
binaries=collect_dynamic_libs('ansicon') + collect_dynamic_libs('enlighten'),
datas=[('client_secrets.json', '.')],
datas=[('client_secrets.json', '.'), ('post-launch.html', '.')],
hiddenimports=['colorama', 'jinxed.terminfo.vtwin10', 'wakepy._linux._jeepney_dbus'],
hookspath=[],
runtime_hooks=[],
Expand Down
20 changes: 20 additions & 0 deletions desktop-tool/post-launch.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>MPC Autofill</title>
</head>
<body>
<h1>Congratulations!</h1>
<p>
MPC Autofill has started up successfully, please look back at your terminal
application to answer a few questions so the upload process can begin.
</p>
<p>
If you have more questions about using MPC Autofill, check out
<a href="https://github.com/chilli-axe/mpc-autofill/wiki/Desktop-Tool">the documentation</a>.
</p>
</body>
</html>
2 changes: 1 addition & 1 deletion desktop-tool/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ pytest-retry~=1.5
ratelimit~=2.2.1
requests~=2.31.0
sanitize-filename~=1.2.0
selenium~=4.19.0
selenium~=4.23
wakepy==0.6.0
6 changes: 6 additions & 0 deletions desktop-tool/src/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ class TargetSite:
default={cardstock: cardstock.value for cardstock in Cardstocks}
)
# endregion
# region save states
saved_successfully_text: str = attr.ib(default="Saved successfully")
# endregion

def format_url(self, url: str) -> str:
return f"{self.base_url}/{url}"
Expand Down Expand Up @@ -161,6 +164,7 @@ class TargetSites(Enum):
base_url="https://www.printerstudio.de",
starting_url_route="machen/blanko-spielkarten-63x88mm-personalisieren.html",
supports_foil=False,
saved_successfully_text="Speicherung erfolgreich",
cardstock_site_name_mapping={
Cardstocks.S30: "Standard (glatt)",
Cardstocks.S33: "Super (glatt)",
Expand All @@ -175,3 +179,5 @@ class TargetSites(Enum):

PROJECT_MAX_SIZE = 612 # shared between target sites
THREADS = 5 # shared between CardImageCollections

POST_LAUNCH_HTML_FILENAME = "post-launch.html"
Loading

0 comments on commit 6538ea7

Please sign in to comment.