add new work flow1

算了,不需要 init sub modules

我的问题,没处理好依赖

some fix to make ruff happy

remove ruff format
This commit is contained in:
shenjack 2023-11-20 20:34:33 +08:00
parent c12088697b
commit eabcc82d0e
Signed by: shenjack
GPG Key ID: 7B1134A979775551
10 changed files with 154 additions and 38 deletions

View File

@ -25,7 +25,7 @@ jobs:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python-version: ["3.8", "3.10"] # 3.11 still not support by nuitka
python-version: ["3.8"] # 3.11 is now supported!, but just run 3.8
runs-on: ${{ matrix.os }}
@ -35,10 +35,10 @@ jobs:
uses: actions/checkout@v4
# check out submodule
- name: init submodule
run: |
git submodule init
git submodule update
# - name: init submodule
# run: |
# git submodule init
# git submodule update
# 缓存 Rust 构建
- name: Cache rust
@ -70,12 +70,12 @@ jobs:
cache: 'pip'
cache-dependency-path: |
**/requirement-dev.txt
.github/workflows/requirement.txt
# 安装依赖
- name: Install env
run: |
pip install -r requirement-dev.txt
pip install git+https://github.com/shenjackyuanjie/lib-not-dr.git
# 提取 DR 版本和其他信息
- name: Display Difficult-Rocket info

View File

@ -39,10 +39,11 @@ jobs:
uses: actions/checkout@v4
# 初始化子模块
- name: Init submodules
run: |
git submodule init
git submodule update
# 暂时不需要 因为直接用 git install
# - name: Init submodules
# run: |
# git submodule init
# git submodule update
# 安装 Python
- name: Setup Python ${{ matrix.python-version }}
@ -53,12 +54,12 @@ jobs:
cache: 'pip'
cache-dependency-path: |
**/requirement-dev.txt
.github/workflows/requirement.txt
# 安装 pyglet
- name: Install pyglet
# 安装特殊依赖
- name: Install git denpendencies
run: |
pip install git+https://github.com/shenjackyuanjie/pyglet.git
pip install git+https://github.com/shenjackyuanjie/lib-not-dr.git
# 安装依赖
- name: Install env
@ -71,7 +72,7 @@ jobs:
# 只在 windows 的 python 3.8 上检查 减少无用报错
run: |
pip install ruff
ruff check . --exit-zero --format github
ruff check . --exit-zero
# 提取 DR 版本和其他信息
- name: Display Difficult-Rocket info

113
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,113 @@
# 名称
name: Build DR release
# 运行条件
on:
# 触发条件
workflow_dispatch:
# 主任务
jobs:
build-release:
# 全都要!
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
# 老子全都要 !
runs-on: ${{ matrix.os }}
steps:
# Check-out repository
- name: Check out
uses: actions/checkout@v4
# 初始化子模块
# - name: Init submodules
# run: |
# git submodule init
# git submodule update
# 缓存 Rust 构建
- name: Cache rust
uses: Swatinem/rust-cache@v2
with:
workspaces: mods/dr_game/Difficult_Rocket_rs
key: dr_release_v1
# 安装 Python
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }} # 为了支持 win7 我还是得用 3.8
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
cache: 'pip'
cache-dependency-path: |
**/requirement-dev.txt
# 安装特殊依赖
- name: Install git denpendencies
run: |
pip install git+https://github.com/shenjackyuanjie/pyglet.git
pip install git+https://github.com/shenjackyuanjie/lib-not-dr.git
# 安装依赖
- name: Install env
run: |
pip install -r requirement-dev.txt
# 提取 DR 版本和其他信息
- name: Display Difficult-Rocket info
id: DR_info
shell: pwsh
run: |
$infos = python .github/workflows/get_info.py -github
Write-Output $infos >> $env:GITHUB_ENV
python .github/workflows/get_info.py
# 使用新的 nuitka_build.py
- name: Build by nuitka
shell: pwsh
run: |
python nuitka_build.py --github
# 集成的构建脚本 好耶!
# 编译 dr_rs
- name: Build dr_rs
shell: pwsh
run: |
Set-Location mods/dr_game/Difficult_Rocket_rs/src
python setup.py build
python post_build.py
python setup.py clean
cd ..
Remove-Item -Recurse -Force src
# 获取短 sha
- name: Get short commit sha
id: get_short_sha
shell: pwsh
run: |
$short_sha = Write-Output $env:GITHUB_SHA
$short_sha = $short_sha.substring(1,7)
Write-Output $short_sha
Write-Output "short_sha=$short_sha" >> $env:GITHUB_ENV
# Uploads artifact
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: Difficult-Rocket_v${{env.DR_version}}-${{runner.os}}${{matrix.python-version}}.zip
path: |
build/github/DR.dist
# Uploads artifact
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: DR_rs${{env.DR_version}}-${{runner.os}}${{matrix.python-version}}-Build.${{github.run_number}}+${{env.short_sha}}
path: |
mods/dr_game

View File

@ -7,11 +7,11 @@
from typing import Dict, Union
from dataclasses import dataclass
from libs.lib_not_dr.types.options import (Options,
OptionsError,
OptionNameNotDefined,
OptionNotFound,
get_type_hints_)
from lib_not_dr.types.options import (Options,
OptionsError,
OptionNameNotDefined,
OptionNotFound,
get_type_hints_)
from libs.MCDR.version import (Version,
VersionRequirement,
VersionParsingError)

View File

@ -66,7 +66,7 @@ class SingleTextStyle:
@tag.setter
def tag(self, value: list):
assert type(value) == list, 'SingleTextStyle.tag must be list'
assert isinstance(value, list), 'SingleTextStyle.tag must be list'
for tag in value:
if tag not in self._tag:
self._tag.append(tag)
@ -82,7 +82,7 @@ class SingleTextStyle:
:param other: 叠加的字体样式
:return: 叠加后的字体样式
"""
assert type(other) == SingleTextStyle, f'SingleTextStyle + other\n other must be the same type, not a {type(other)}'
assert isinstance(other, SingleTextStyle), f'SingleTextStyle + other\n other must be the same type, not a {type(other)}'
return SingleTextStyle(
font_name=other.font_name or self.font_name,
font_size=other.font_size or self.font_size,
@ -102,7 +102,7 @@ class SingleTextStyle:
:param other: 叠加的字体样式
:return: 叠加后的字体样式
"""
assert type(other) == SingleTextStyle, f'SingleTextStyle += other\n other must be the same type, not a {type(other)}'
assert isinstance(other, SingleTextStyle), f'SingleTextStyle += other\n other must be the same type, not a {type(other)}'
self.font_name = other.font_name or self.font_name
self.font_size = other.font_size or self.font_size
self.bold = other.bold or self.bold
@ -125,7 +125,7 @@ class SingleTextStyle:
:param other: 叠加的字体样式
:return: 是否相同
"""
assert type(other) == SingleTextStyle
assert isinstance(other, SingleTextStyle)
return other.tag in self.tag
def same_font(self, other: 'SingleTextStyle') -> bool:
@ -134,7 +134,7 @@ class SingleTextStyle:
:param other: 叠加的字体样式
:return: 是否相同
"""
assert type(other) == SingleTextStyle
assert isinstance(other, SingleTextStyle)
return (self.font_name == other.font_name and
self.font_size == other.font_size and
self.color == other.color and
@ -146,7 +146,7 @@ class SingleTextStyle:
:param other: 叠加的字体样式
:return: 是否相同
"""
assert type(other) == SingleTextStyle
assert isinstance(other, SingleTextStyle)
return self.bold == other.bold
def same_italic(self, other: 'SingleTextStyle') -> bool:
@ -155,7 +155,7 @@ class SingleTextStyle:
:param other: 叠加的字体样式
:return: 是否相同
"""
assert type(other) == SingleTextStyle
assert isinstance(other, SingleTextStyle)
return self.italic == other.italic
"""

View File

@ -125,7 +125,7 @@ class CommandLine(widgets.WidgetBase):
@text.setter
def text(self, value):
assert type(value) is str, 'CommandLine\'s text must be string!'
assert isinstance(value, str), 'CommandLine\'s text must be string!'
self._text = value
self._line.text = value
@ -143,7 +143,7 @@ class CommandLine(widgets.WidgetBase):
0 ~ (self.length-1) -> 切换视角到对应的行数
实际上还有一个限制
"""
assert type(value) is int, 'Command View must be integer'
assert isinstance(value, int), 'Command View must be integer'
assert -self.length < value < self.length, f'Command View must be bigger than {-self.length} and smaller than {self.length}'
if value == -1: # flush command list
self._label.insert(0, self._label[-1])
@ -168,7 +168,7 @@ class CommandLine(widgets.WidgetBase):
@editing.setter
def editing(self, value):
assert type(value) is bool, 'Command editing must be bool!'
assert isinstance(value, bool), 'Command editing must be bool!'
self._editing = value
self._line.visible = value
self._outline.visible = value

View File

@ -4,9 +4,8 @@
# All rights reserved
# -------------------------------
from typing import Optional, Tuple
from typing import Tuple
from pyglet.shapes import Rectangle
from pyglet.graphics import Batch, Group
from Difficult_Rocket.gui.widget.theme import BaseTheme, FontTheme

View File

@ -37,7 +37,7 @@ class TranslateConfig:
def set(self, item: str, value: Union[bool, "Tr", "Translates"]) -> 'TranslateConfig':
assert getattr(self, item, None) is not None, f'Config {item} is not in TranslateConfig'
assert type(value) is bool
assert isinstance(value, bool)
setattr(self, item, value)
return self

View File

@ -5,8 +5,7 @@
# -------------------------------
import math
from typing import Dict, Union, Optional
from dataclasses import dataclass
from typing import Dict, Union
# pyglet
from pyglet.image import load, AbstractImage

View File

@ -40,11 +40,15 @@ build = [
target-version = "py38"
line-length = 150
src = ["Difficult_Rocket", "libs/lib_not_dr", "libs/utils"]
src = ["Difficult_Rocket", "libs/utils"]
exclude = ['libs/pyglet',
'libs/pyperclip',
'libs/lib_not_dr',
'libs/MCDR/serializer.py',
'libs/utils/logger-old.py' # 旧版日志, 忽略他就好
]
exclude = ['libs/pyglet', 'libs/pyperclip', 'libs/MCDR/serializer.py']
[nuitka]
[tool.lndl.nuitka]
lto = "yes"
main = "DR.py"