Skip to content

Commit

Permalink
DMG Workflow macos-15 (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasgriffin authored Dec 21, 2024
1 parent 8853300 commit 54f4910
Show file tree
Hide file tree
Showing 11 changed files with 148 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
name: Build Test AppImage



on:
workflow_dispatch:
inputs:
tags:
commitHash:
description: 'Enter the commit hash to build (leave empty to use the default branch or the branch that triggered the workflow)'
required: false
type: string
buildDMG:
description: 'Test Build AppImage'
required: false
type: boolean


jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -16,6 +23,7 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all history for all branches and tags
ref: ${{ github.event.inputs.commitHash || github.sha }}


- name: Set up Python environment
Expand Down Expand Up @@ -67,6 +75,12 @@ jobs:
fi
- name: Upload AppImage Files from dist/
uses: actions/upload-artifact@v4
with:
name: appimages
path: dist/*.appimage

# - name: Install Dependencies for gui test
# run: |
# sudo apt-get update
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
name: Build Test DMG

on:
workflow_dispatch:
inputs:
tags:
description: 'Test Build DMG'
commitHash:
description: 'Enter the commit hash to build (leave empty to use the default branch or the branch that triggered the workflow)'
required: false
type: string
buildDMG:
description: 'Test Build DMG (Arm64)'
required: false
type: boolean

# push:
# branches: [ "main" ]
# pull_request:
# branches: [ "main" ]

jobs:
build:
runs-on: macos-14 # see available: https://github.com/actions/runner-images?tab=readme-ov-file#available-images
Expand All @@ -16,7 +24,7 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all history for all branches and tags

ref: ${{ github.event.inputs.commitHash || github.sha }}


- name: Run build script
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ name: Build Test Windows
on:
workflow_dispatch:
inputs:
tags:
description: 'Test Build AppImage'
commitHash:
description: 'Enter the commit hash to build (leave empty to use the default branch or the branch that triggered the workflow)'
required: false
type: string
buildDMG:
description: 'Test Build Exe'
required: false
type: boolean

Expand All @@ -16,6 +20,7 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all history for all branches and tags
ref: ${{ github.event.inputs.commitHash || github.sha }}


- name: Set up Python environment
Expand Down Expand Up @@ -72,3 +77,9 @@ jobs:
echo "Setup EXE file is missing"
exit 1
fi
- name: Upload EXE Files from dist/
uses: actions/upload-artifact@v4
with:
name: exes
path: dist/*.exe
9 changes: 9 additions & 0 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,12 @@ jobs:
- name: Run Tests for marker_qt_2
run: |
poetry run pytest -m 'marker_qt_2' -vvv --log-cli-level=DEBUG --setup-show --maxfail=1
- name: Upload output Files from tests/output
uses: actions/upload-artifact@v4
with:
name: test-output
path: tests/output
21 changes: 21 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@
],
"console": "integratedTerminal",
"preLaunchTask": "Poetry Install" // label of the task
},{
"name": "Build mac",
"type": "python",
"request": "launch",
"program": "tools/build.py",
"args": [
"--targets", "mac",
],
"console": "integratedTerminal",
"preLaunchTask": "Poetry Install" // label of the task
},{
"name": "Build Linux (Current Files)",
"type": "python",
Expand All @@ -149,6 +159,17 @@
],
"console": "integratedTerminal",
"preLaunchTask": "Poetry Install" // label of the task
},{
"name": "Build Mac (Current Files)",
"type": "python",
"request": "launch",
"program": "tools/build.py",
"args": [
"--targets", "mac",
"--commit", "None",
],
"console": "integratedTerminal",
"preLaunchTask": "Poetry Install" // label of the task
},{
"name": "Build Windows (Current Files)",
"type": "python",
Expand Down
2 changes: 1 addition & 1 deletion tests/gui/qt/test_setup_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def enter_text(text: str, widget: QWidget) -> None:
QTest.keyClick(widget, char)


@pytest.mark.marker_qt_1
@pytest.mark.marker_qt_1 # repeated gui tests let the RAM usage increase (unclear why the memory isnt freed), and to stay under the github VM limit, we split the tests
def test_wizard(
qapp: QApplication,
qtbot: QtBot,
Expand Down
4 changes: 2 additions & 2 deletions tools/build-mac/make_osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ $python3 -m pip install --no-build-isolation --no-dependencies --no-binary :all:
|| fail "Could not install build dependencies (mac)"

info "Installing some build-time deps for compilation..."
brew install autoconf automake libtool gettext coreutils pkgconfig libiconv
brew install autoconf automake libtool gettext coreutils pkgconfig

info "Building PyInstaller."
PYINSTALLER_REPO="https://github.com/pyinstaller/pyinstaller.git"
Expand Down Expand Up @@ -195,7 +195,7 @@ $python3 -m pip uninstall -y pip


info "Faking timestamps..."
find . -exec touch -t '200101220000' {} + || true
find . -exec sudo touch -t '200101220000' {} + || true

VERSION=$(git describe --tags --dirty --always)

Expand Down
18 changes: 17 additions & 1 deletion tools/build-mac/osx.spec
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
# -*- mode: python -*-

import platform
from PyInstaller.utils.hooks import collect_data_files, collect_submodules, collect_dynamic_libs
from PyInstaller.building.api import COLLECT, EXE, PYZ
from PyInstaller.building.build_main import Analysis
from PyInstaller.building.osx import BUNDLE

import sys, os



# Function to determine target architecture based on Python's running architecture
def get_target_arch():
arch = platform.machine()
if arch == 'x86_64':
return 'x86_64'
elif arch in ('arm', 'arm64', 'aarch64'):
return 'arm64'
else:
return 'universal2' # Defaulting to universal for other cases (as a fallback)
target_arch = get_target_arch()
print(f"Building for {target_arch=}")


PACKAGE_NAME='Bitcoin_Safe.app'
PYPKG='bitcoin_safe'
PROJECT_ROOT = os.path.abspath(".")
Expand Down Expand Up @@ -112,7 +128,7 @@ exe = EXE(
upx=True,
icon=ICONS_FILE,
console=False,
target_arch='x86_64', # TODO investigate building 'universal2'
target_arch=target_arch, # TODO investigate building 'universal2'
)

app = BUNDLE(
Expand Down
55 changes: 53 additions & 2 deletions tools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,60 @@ def build_in_docker(

def build_dmg(
self,
build_commit: None | str | Literal["current_commit"] = "current_commit",
):
PROJECT_ROOT = Path(".").resolve().absolute()
run_local(PROJECT_ROOT / "tools" / "build-mac" / "make_osx.sh")
PROJECT_ROOT_OR_FRESHCLONE_ROOT = PROJECT_ROOT = Path(".").resolve().absolute()
DISTDIR = PROJECT_ROOT / "dist"

if build_commit == "current_commit":
# Get the current git HEAD commit
result = subprocess.run(
["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE, check=True, text=True
)
build_commit = result.stdout.strip()

if not build_commit:
# Local development build
logger.info(f"Building within current project")

# Possibly do a fresh clone
FRESH_CLONE = False
if build_commit:
logger.info(f"BITCOINSAFE_BUILD_COMMIT={build_commit}. Doing fresh clone and git checkout.")
FRESH_CLONE = Path(f"/tmp/{build_commit.replace(' ','')}/fresh_clone/bitcoin_safe")
try:
run_local(f'rm -rf "{FRESH_CLONE}"')
except subprocess.CalledProcessError:
logger.info("We need sudo to remove previous FRESH_CLONE.")
run_local(f'sudo rm -rf "{FRESH_CLONE}"')
os.umask(0o022)
run_local(f'git clone "{PROJECT_ROOT}" "{FRESH_CLONE}"')
os.chdir(str(FRESH_CLONE))
run_local(f'git checkout "{build_commit}"')
PROJECT_ROOT_OR_FRESHCLONE_ROOT = FRESH_CLONE
else:
logger.info("Not doing fresh clone.")

Source_Dist_dir = PROJECT_ROOT_OR_FRESHCLONE_ROOT / "dist"

os.chdir(str(PROJECT_ROOT_OR_FRESHCLONE_ROOT))
run_local(f'bash {PROJECT_ROOT_OR_FRESHCLONE_ROOT / "tools" / "build-mac" / "make_osx.sh"}')

os.chdir(str(PROJECT_ROOT))

# Ensure the resulting binary location is independent of fresh_clone
if Source_Dist_dir != DISTDIR:
os.makedirs(DISTDIR, exist_ok=True)
for file in Source_Dist_dir.iterdir():
# only move the .app directory (no need for the unsigned dmg)
if file.is_dir() and file.name.endswith(".app"):
logger.info(f"Moving {file} --> {DISTDIR / file.name}")
# Replace module name with formatted app name in the directory name
new_dir_name = file.name.replace(
self.module_name, self.app_name_formatter(self.module_name)
)
# Perform the move
shutil.move(str(file), str(DISTDIR / new_dir_name))

def briefcase_appimage(self, **kwargs):
# briefcase appimage building works on some systems, but not on others... unknown why.
Expand Down
1 change: 1 addition & 0 deletions tools/make_libusb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ info "Building $pkgname..."
LDFLAGS=""
fi
LDFLAGS="$LDFLAGS" ./configure \
--prefix="$HOME/local" \
$AUTOCONF_FLAGS \
|| fail "Could not configure $pkgname. Please make sure you have a C compiler installed and try again."
fi
Expand Down
4 changes: 4 additions & 0 deletions tools/make_zbar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ info "Building $pkgname..."
if [ "$BUILD_TYPE" = "wine" ] ; then
echo "libzbar_la_LDFLAGS += -Wc,-static" >> zbar/Makefile.am
echo "LDFLAGS += -Wc,-static" >> Makefile.am
LDFLAGS="-L/usr/local/lib -liconv" # Example for adding libiconv
fi
if ! [ -x configure ] ; then
autoreconf -vfi || fail "Could not run autoreconf for $pkgname. Please make sure you have automake and libtool installed, and try again."
Expand All @@ -56,17 +57,20 @@ info "Building $pkgname..."
--disable-dependency-tracking"
elif [ $(uname) == "Darwin" ]; then
# macos target
LDFLAGS="-L/opt/local/lib -liconv" # Adjust for macOS specific libiconv path if needed
AUTOCONF_FLAGS="$AUTOCONF_FLAGS \
--with-x=no \
--enable-video=no \
--with-jpeg=no"
else
# linux target
LDFLAGS="-L/usr/lib/x86_64-linux-gnu -liconv" # Adjust based on your distro
AUTOCONF_FLAGS="$AUTOCONF_FLAGS \
--with-x=yes \
--enable-video=yes \
--with-jpeg=yes"
fi
export LDFLAGS
./configure \
$AUTOCONF_FLAGS \
--prefix="$here/$pkgname/dist" \
Expand Down

0 comments on commit 54f4910

Please sign in to comment.