Skip to content

Commit

Permalink
feat: Add new setup use CI auto build portable version
Browse files Browse the repository at this point in the history
Signed-off-by: loonghao <hal.long@outlook.com>
  • Loading branch information
loonghao committed Jul 10, 2024
1 parent 5d0276b commit 9ec183d
Show file tree
Hide file tree
Showing 21 changed files with 297 additions and 123 deletions.
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.


**Additional context**
Add any other context about the problem here.
18 changes: 18 additions & 0 deletions .github/workflows/issue-translator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: 'issue-translator'
on:
issue_comment:
types: [created]
issues:
types: [opened]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: usthe/issues-translate-action@v2.7
with:
IS_MODIFY_TITLE: false
# not require, default false, . Decide whether to modify the issue title
# if true, the robot account @Issues-translate-bot must have modification permissions, invite @Issues-translate-bot to your project or use your custom bot.
CUSTOM_BOT_NOTE: Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿
# not require. Customize the translation robot prefix message.
30 changes: 30 additions & 0 deletions .github/workflows/mr-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: MR Checks
on: [ pull_request ]

jobs:
python-check:
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 3
matrix:
os: [ 'windows-2019' ]
python-version: ["3.10"]
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install -r requirements-dev.txt
poetry --version
- name: lint
run: |
nox -s lint
- name: test build
run: |
nox -s build-exe
build\x86_64-pc-windows-msvc\release\install\rez.exe env --help
68 changes: 68 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Upload Python Package

on:
push:
tags:
- "v*"

jobs:
deploy:
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 3
matrix:
os: [ 'windows-2019' ]
python-version: ["3.10"]
fail-fast: false
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
contents: write
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4
with:
token: "${{ secrets.GITHUB_TOKEN }}"
fetch-depth: 0
ref: main
- uses: olegtarasov/get-tag@v2.1.3
id: get_tag_name
with:
tagRegex: "v(?<version>.*)"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install -r requirements-dev.txt
poetry --version
- name: build exe
id: build_exe
run: |
nox -s build-exe -- --release --version ${{ steps.get_tag_name.outputs.version }}
- name: Generate changelog
id: changelog
uses: jaywcjlove/changelog-generator@main
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
filter-author: (|dependabot|renovate\\[bot\\]|dependabot\\[bot\\]|Renovate Bot)
filter: '[R|r]elease[d]\s+[v|V]\d(\.\d+){0,2}'
template: |
## Bugs
{{fix}}
## Feature
{{feat}}
## Improve
{{refactor,perf,clean}}
## Misc
{{chore,style,ci||🔶 Nothing change}}
## Unknown
{{__unknown__}}
- uses: ncipollo/release-action@v1
with:
artifacts: ".zip/portable_rez-*.zip"
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
body: |
Comparing Changes: ${{ steps.changelog.outputs.compareurl }}
${{ steps.changelog.outputs.changelog }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ docs/src/*
venv/
/venv_python/
/.eggs/
.zip/
.nox/
run_pycharm.bat
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

A portable rez (Windows only)

## required
- python-3
## setup dev env
```shell
pip install -r requirements-dev.txt
```

## build portable rez
check `build.bat`
```shell
nox -s build-exe
```
3 changes: 0 additions & 3 deletions build.bat

This file was deleted.

89 changes: 0 additions & 89 deletions build.py

This file was deleted.

Empty file added nox_actions/__init__.py
Empty file.
16 changes: 16 additions & 0 deletions nox_actions/codetest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Import built-in modules
import os

# Import third-party modules
import nox

from nox_actions.utils import PACKAGE_NAME, THIS_ROOT


def pytest(session: nox.Session) -> None:
session.install("pytest", "pytest_cov", "pytest_mock")
test_root = os.path.join(THIS_ROOT, "tests")
session.run("pytest", f"--cov={PACKAGE_NAME}",
"--cov-report=xml:coverage.xml",
f"--rootdir={test_root}",
env={"PYTHONPATH": THIS_ROOT})
18 changes: 18 additions & 0 deletions nox_actions/lint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Import third-party modules
import nox

from nox_actions.utils import PACKAGE_NAME


def lint(session: nox.Session) -> None:
session.install("isort", "ruff")
session.run("isort", "--check-only", PACKAGE_NAME)
session.run("ruff", "check")


def lint_fix(session: nox.Session) -> None:
session.install("isort", "ruff", "pre-commit", "autoflake")
session.run("ruff", "check", "--fix")
session.run("isort", ".")
session.run("pre-commit", "run", "--all-files")
session.run("autoflake", "--in-place", "--remove-all-unused-imports", "--remove-unused-variables")
38 changes: 38 additions & 0 deletions nox_actions/release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Import built-in modules
import argparse
import os
import shutil
import zipfile

# Import third-party modules
import nox

from nox_actions.utils import PACKAGE_NAME, THIS_ROOT


@nox.session(name="build-exe", reuse_venv=True)
def build_exe(session: nox.Session) -> None:
parser = argparse.ArgumentParser(prog="nox -s build-exe --release")
parser.add_argument("--release", action="store_true")
parser.add_argument("--version", default="0.5.0", help="Version to use for the zip file")
args = parser.parse_args(session.posargs)
build_root = THIS_ROOT / "build" / "x86_64-pc-windows-msvc" / "release" / "install"
session.install("pyoxidizer")
session.run("pyoxidizer", "build", "install", "--path", THIS_ROOT, "--release")
rez_exe = build_root / "portable_rez.exe"
rez_exe.rename(build_root / "rez.exe")

if args.release:
temp_dir = os.path.join(THIS_ROOT, ".zip")
shutil.rmtree(temp_dir, ignore_errors=True)
version = str(args.version)
print(f"make zip to current version: {version}")
os.makedirs(temp_dir, exist_ok=True)
zip_file = os.path.join(temp_dir, f"{PACKAGE_NAME}-{version}.zip")
with zipfile.ZipFile(zip_file, "w") as zip_obj:
for root, _, files in os.walk(build_root):
for file in files:
zip_obj.write(os.path.join(root, file),
os.path.relpath(os.path.join(root, file),
os.path.join(build_root, ".")))
print("Saving to {zipfile}".format(zipfile=zip_file))
18 changes: 18 additions & 0 deletions nox_actions/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Import built-in modules
from pathlib import Path

PACKAGE_NAME = "portable_rez"
THIS_ROOT = Path(__file__).parent.parent
PROJECT_ROOT = THIS_ROOT.parent


def _assemble_env_paths(*paths):
"""Assemble environment paths separated by a semicolon.
Args:
*paths: Paths to be assembled.
Returns:
str: Assembled paths separated by a semicolon.
"""
return ";".join(paths)
23 changes: 23 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- coding: UTF-8 -*-
# Import built-in modules
import os
import sys

# Import third-party modules
import nox

ROOT = os.path.dirname(__file__)

# Ensure maya_umbrella is importable.
if ROOT not in sys.path:
sys.path.append(ROOT)

# Import third-party modules
from nox_actions import codetest # noqa: E402
from nox_actions import lint # noqa: E402
from nox_actions import release # noqa: E402

nox.session(lint.lint, name="lint")
nox.session(lint.lint_fix, name="lint-fix")
nox.session(codetest.pytest, name="pytest")
nox.session(release.build_exe, name="build-exe")
Empty file.
Loading

0 comments on commit 9ec183d

Please sign in to comment.