-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from QAInsights/feature/windows
Add: Windows app
- Loading branch information
Showing
12 changed files
with
521 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ on: | |
push: | ||
branches: [ "main" ] | ||
paths-ignore: | ||
- '**/README.md' | ||
- '**/**.md' | ||
|
||
jobs: | ||
build: | ||
|
@@ -20,21 +20,34 @@ jobs: | |
|
||
strategy: | ||
matrix: | ||
os: [ self-hosted, macos ] | ||
arch: [ 'X64', 'ARM64' ] | ||
# os: [ windows-latest ] | ||
# arch: [ 'X86' ] | ||
os: [ self-hosted, macos, windows ] | ||
arch: [ 'X64', 'ARM64', 'X86' ] | ||
|
||
steps: | ||
# - name: Checkout feature/windows branch | ||
# uses: actions/checkout@v3 | ||
# with: | ||
# ref: feature/windows | ||
|
||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.10.11 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.10.11" | ||
|
||
- name: Install dependencies in Windows | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r .\windows\requirements.txt | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install py2app | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
if: matrix.os == 'macos' || matrix.os == 'self-hosted' | ||
|
||
- name: Generate app for intel architecture | ||
run: | | ||
|
@@ -48,6 +61,11 @@ jobs: | |
mv dist dist-arm64 | ||
if: matrix.os == 'self-hosted' && matrix.arch == 'ARM64' | ||
|
||
- name: Generate app for windows | ||
run: | | ||
python .\windows\setup.py bdist_msi | ||
mv dist dist-windows | ||
- name: Convert dist-intel to DMG | ||
run: | | ||
hdiutil create -volname "Hamster" -srcfolder dist-intel -ov -format UDZO dist-intel/${{ env.INTEL_DMG }} | ||
|
@@ -72,6 +90,12 @@ jobs: | |
path: dist-arm64/Hamster-darwin.dmg | ||
if: matrix.os == 'self-hosted' && matrix.arch == 'ARM64' | ||
|
||
- name: Upload windows app | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: Hamster-windows-x86_64 | ||
path: dist-windows/Hamster-*.msi | ||
|
||
- name: GitHub Tag | ||
uses: mathieudutour/[email protected] | ||
with: | ||
|
@@ -98,4 +122,15 @@ jobs: | |
generate_release_notes: true | ||
tag_name: ${{ env.RELEASE_TAG }} | ||
files: | | ||
dist-intel/${{ env.INTEL_DMG }} | ||
dist-intel/${{ env.INTEL_DMG }} | ||
- name: Release Windows | ||
uses: softprops/action-gh-release@v1 | ||
if: github.ref == 'refs/heads/main' | ||
with: | ||
token: ${{ secrets.HAMSTER_APP_RELEASE_SECRET }} | ||
body: 'Release for commit ${{ github.sha }}' | ||
generate_release_notes: true | ||
tag_name: ${{ env.RELEASE_TAG }} | ||
files: | | ||
dist-windows/Hamster-*.msi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Build instructions for Windows | ||
## Prerequisites | ||
- Python | ||
|
||
## Build | ||
|
||
```powershell | ||
cd windows | ||
python .\setup.py bdist_msi | ||
``` | ||
|
||
## Launch | ||
|
||
```powershell | ||
cd windows\dist | ||
.\Hamster-{version}-win64.msi | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__VERSION__ = "0.0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import re | ||
|
||
from collections import OrderedDict | ||
from pathlib import Path | ||
# from windows import __VERSION__ | ||
|
||
|
||
class AppConfig: | ||
def __init__(self): | ||
self.app_title = 'Hamster' | ||
self.app_title_emoji = f'🐹 {self.app_title}' | ||
self.app_caption = 'Instantly Launch JMeter Test Plans' | ||
self.app_caption_emoji = f'{self.app_caption} 🚀' | ||
self.app_properties_template = "hamster_app.properties" | ||
self.win_app_properties = self.app_properties_template.replace(".properties", ".ini") | ||
self.home_dir = Path.home() | ||
self.menu_items_dict = OrderedDict() | ||
|
||
self.jmeter_recent_files_pattern = re.compile("recent_file_.*") | ||
self.app_version = "0.0.1" | ||
self.buy_me_a_coffee_url = 'https://www.buymeacoffee.com/QAInsights' | ||
self.authors = ['NaveenKumar Namachivayam', 'Leela Prasad Vadla'] | ||
self.about_website = 'https://QAInsights.com' | ||
|
||
@property | ||
def authors_str(self): | ||
return '\n'.join(self.authors) | ||
|
||
@property | ||
def about_text(self): | ||
return f'''{self.app_title_emoji} - {self.app_caption_emoji}\n\n | ||
Authors:\n{self.authors_str}\n\n{self.about_website} | ||
''' | ||
|
||
@property | ||
def help_text(self): | ||
return ''' | ||
Hamster is a menu bar app to instantly launch JMeter test plans.\n\n | ||
1. Configure `JMETER_HOME` by launching `Hamster > Edit JMETER_HOME`\n | ||
2. To launch JMeter, click on `Hamster > Launch JMeter`\n | ||
3. To launch JMeter test plans, click on `Hamster > Recent Test Plans > select the test plan`.\n | ||
4. To view the configuration, click on `Hamster > View Config`\n | ||
5. To restart Hamster, click on `Hamster > Refresh`\n | ||
6. To know more about Hamster, click on `Hamster > About`\n | ||
7. To refresh the recent test plans, click on `Hamster > Restart`\n | ||
8. To quit Hamster, click on `Hamster > Quit`\n | ||
''' | ||
|
||
|
||
app_config = AppConfig() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import re | ||
|
||
from collections import OrderedDict | ||
from pathlib import Path | ||
from windows import __VERSION__ | ||
|
||
|
||
class AppConfig: | ||
def __init__(self): | ||
self.app_title = 'Hamster' | ||
self.app_title_emoji = f'🐹 {self.app_title}' | ||
self.app_caption = 'Instantly Launch JMeter Test Plans' | ||
self.app_caption_emoji = f'{self.app_caption} 🚀' | ||
self.app_properties_template = "hamster_app.properties" | ||
self.win_app_properties = self.app_properties_template.replace(".properties", ".ini") | ||
self.home_dir = Path.home() | ||
self.menu_items_dict = OrderedDict() | ||
|
||
self.jmeter_recent_files_pattern = re.compile("recent_file_.*") | ||
self.app_version = __VERSION__ | ||
self.buy_me_a_coffee_url = 'https://www.buymeacoffee.com/QAInsights' | ||
self.authors = ['NaveenKumar Namachivayam', 'Leela Prasad Vadla'] | ||
self.about_website = 'https://QAInsights.com' | ||
|
||
@property | ||
def authors_str(self): | ||
return '\n'.join(self.authors) | ||
|
||
@property | ||
def about_text(self): | ||
return f'''{self.app_title_emoji} - {self.app_caption_emoji}\n\n | ||
Authors:\n{self.authors_str}\n\n{self.about_website} | ||
''' | ||
|
||
@property | ||
def help_text(self): | ||
return ''' | ||
Hamster is a menu bar app to instantly launch JMeter test plans.\n\n | ||
1. Configure `JMETER_HOME` by launching `Hamster > Edit JMETER_HOME`\n | ||
2. To launch JMeter, click on `Hamster > Launch JMeter`\n | ||
3. To launch JMeter test plans, click on `Hamster > Recent Test Plans > select the test plan`.\n | ||
4. To view the configuration, click on `Hamster > View Config`\n | ||
5. To restart Hamster, click on `Hamster > Refresh`\n | ||
6. To know more about Hamster, click on `Hamster > About`\n | ||
7. To refresh the recent test plans, click on `Hamster > Restart`\n | ||
8. To quit Hamster, click on `Hamster > Quit`\n | ||
''' | ||
|
||
|
||
app_config = AppConfig() |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[JMETER] | ||
home = C:\Tools\apache-jmeter-5.6.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from PIL import Image | ||
from pystray import MenuItem, Menu, Icon | ||
|
||
from config import app_config | ||
from utils import get_recent_test_plans, create_app_data_dir, action_launch_jmeter, action_recent_test_plan, \ | ||
action_view_config, action_edit_config, action_refresh, action_quit, action_help, action_about, action_sponsor | ||
|
||
|
||
def main(): | ||
""" | ||
The main function of the application. It creates a system tray icon with a context menu. | ||
The context menu includes options to launch JMeter, view recent test plans, view and edit configuration, refresh, and quit the application. | ||
Returns: | ||
""" | ||
# argv impl | ||
image = Image.open("hamster.png") | ||
recent_test_plans = get_recent_test_plans() | ||
recent_test_plans_menu_items = [MenuItem(plan, action_recent_test_plan) for plan in recent_test_plans] | ||
|
||
app_config.menu_items_dict.update({ | ||
"Launch JMeter": MenuItem('🚀 Launch JMeter', action_launch_jmeter), | ||
"Recent Test Plans": MenuItem('Recent Test Plans', Menu(*recent_test_plans_menu_items)), | ||
"Seperator01": Menu.SEPARATOR, | ||
"View Config": MenuItem('View Config', action_view_config), | ||
"Configure JMETER_HOME": MenuItem('Configure JMETER_HOME', action_edit_config), | ||
"Seperator02": Menu.SEPARATOR, | ||
"Refresh": MenuItem('Refresh', action_refresh), | ||
"Buy me a coffee": MenuItem('☕ Buy me a coffee', action_sponsor), | ||
"Help": MenuItem('Help', action_help), | ||
"About": MenuItem('About', action_about), | ||
"Quit": MenuItem('Quit', action_quit) | ||
}) | ||
|
||
# Create the menu with the menu items | ||
menu = Menu(*app_config.menu_items_dict.values()) | ||
|
||
# Create the icon with the menu | ||
icon = Icon("Hamster", image, f"{app_config.app_title} - {app_config.app_caption}", menu) | ||
icon.run() | ||
|
||
|
||
if __name__ == "__main__": | ||
create_app_data_dir() | ||
main() |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import sys | ||
from cx_Freeze import setup, Executable | ||
# from windows import __VERSION__ | ||
|
||
msi_data = { | ||
"ProgId": [ | ||
("Prog.Id", None, None, "Hamster - Instantly Launch JMeter Test Plans", "IconId", None), | ||
], | ||
"Icon": [ | ||
("IconId", r'windows\\hamster.ico'), | ||
], | ||
} | ||
|
||
bdist_msi_options = { | ||
"data": msi_data, | ||
"install_icon": r'windows\\hamster.ico', | ||
"initial_target_dir": r'[ProgramFilesFolder]\%s\%s' % ("QAInsights", "Hamster"), | ||
"summary_data": { | ||
"author": "QAInsights", | ||
"comments": "Hamster - Instantly Launch JMeter Test Plans", | ||
"keywords": "JMeter, Performance Testing, QAInsights, Apache JMeter, Hamster", | ||
}, | ||
} | ||
|
||
build_exe_options = { | ||
"include_files": ["windows\\hamster.png", | ||
"windows\\config.py", | ||
"windows\\utils.py", | ||
"windows\\hamster_app.properties", | ||
"windows\\hamster.ico", | ||
], | ||
} | ||
base = "Win32GUI" if sys.platform == "win32" else None | ||
|
||
executables = [ | ||
Executable( | ||
"windows\\main.py", | ||
copyright="Copyright (C) 2023 QAInsights", | ||
base=base, | ||
shortcut_name="Hamster", | ||
shortcut_dir="ProgramMenuFolder", | ||
icon="windows\\hamster.ico", | ||
), | ||
] | ||
|
||
setup( | ||
name="Hamster", | ||
version="0.0.1", | ||
description="Hamster - Instantly Launch JMeter Test Plans 🚀", | ||
options={ | ||
"build_exe": build_exe_options, | ||
"bdist_msi": bdist_msi_options, | ||
}, | ||
executables=executables, | ||
packages=["windows"] | ||
) |
Oops, something went wrong.