Skip to content

Commit

Permalink
fixing ci
Browse files Browse the repository at this point in the history
  • Loading branch information
rtmigo committed Sep 14, 2023
1 parent 8023cda commit f1f9f86
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ jobs:

strategy:
matrix:
# 2023-09 тесты 3.12.0-rc.2 не проходили на windows-latest,
# поэтому пока отключены

os: [ ubuntu-latest, macos-latest, windows-latest ]
python-version: [ 3.7, 3.8, 3.9, '3.10', '3.11', '3.12' ]

python-version: [ 3.7, 3.8, 3.9, '3.10', '3.11' ]

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Generic badge](https://img.shields.io/badge/Maturity-Experimental-red.svg)
](#)
[![Generic badge](https://img.shields.io/badge/Python-3.7..3.12-blue.svg)](#)
[![Generic badge](https://img.shields.io/badge/Python-3.7–3.11-blue.svg)](#)
[![Generic badge](https://img.shields.io/badge/OS-Linux%20|%20macOS%20|%20Windows-blue.svg)](#)

# [dmk: dark matter keeper](https://github.com/rtmigo/dmk_py#readme)
Expand Down
1 change: 1 addition & 0 deletions dmk/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@

__version__ = "0.7.0"
__copyright__ = "2021-2022 Artem IG <github.com/rtmigo>"
__build_timestamp__ = "0000-00-00 00:00"
112 changes: 112 additions & 0 deletions do.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import datetime
import os
import re
import shutil
import subprocess
import sys
from pathlib import Path

import PyInstaller.__main__ as compile
import click
import neatest
from chkpkg import Package


@click.group()
def app():
pass


@app.command()
def test():
_test()


def _test():
neatest.run(warnings=neatest.Warnings.fail)


@app.command()
def test_pkg():
with Package() as pkg:
pkg.run_shell_code('dmk --version')
print("\nPackage is OK!")


@app.command()
def run():
subprocess.call([sys.executable, "_run.py"])


@app.command()
def lint():
_lint()


def _lint():
print("Running mypy...")
if subprocess.call(['mypy', 'dmk',
'--ignore-missing-imports']) != 0:
exit(1)


# def _get_git_commit():
# return subprocess.check_output("git log --pretty=format:'%h' -n 1".split())


def _replace_build_date(fn: Path):
now = datetime.datetime.now().isoformat(sep=" ", timespec="seconds")
text = fn.read_text()
new_text = re.sub(
r'__build_timestamp__.+',
f'__build_timestamp__ = "{now}"',
text)
print(new_text)
assert new_text != text, "timestamp not changed"
fn.write_text(new_text)


# def _replace_git_commit(fn: Path):
# now = datetime.datetime.now().isoformat(sep=" ", timespec="seconds")
# text = fn.read_text()
# text = re.sub(
# r'__prev_commit__.+$',
# f'__prev_prev_commit__ = "{now}"',
# text)
# print(text)
# fn.write_text(text)


@app.command()
def install():
"""Build PyInstaller executable and copy it to ~/.local/bin"""
name = "dmk"
project_dir = Path(__file__).parent

_test()
_lint()

_replace_build_date(Path("dmk/_constants.py"))
# exit()

compile.run([
"--clean", "--onefile", "-y",
"--collect-all", "dmk",
"--name", name, "_run.py"
])

exe = project_dir / "dist" / name
print(f"Exe size: {exe.stat().st_size / 1024 / 1024:.0f} MiB")

os.remove(project_dir / "dmk.spec")
shutil.rmtree(project_dir / "build")
target = Path(os.path.expanduser("~/.local/bin")) / name
if target.parent.exists():
print(f"Copying to {target}")
shutil.move(exe, target)
else:
print(f"{target.parent} does not exist")


if __name__ == "__main__":
app()

0 comments on commit f1f9f86

Please sign in to comment.