diff --git a/.github/workflows/codestyle.yml b/.github/workflows/codestyle.yml index a5882397..525f9791 100644 --- a/.github/workflows/codestyle.yml +++ b/.github/workflows/codestyle.yml @@ -5,19 +5,21 @@ on: [push, pull_request] jobs: lint: runs-on: ubuntu-latest + steps: - uses: actions/checkout@v3 - uses: psf/black@stable + - name: Set up Python 3.9 uses: actions/setup-python@v4 with: python-version: 3.9 + - name: Install Dependencies - run: | - pip install black isort + run: make install + - name: black - run: | - black --check src + run: make black + - name: isort - run: | - isort --check src \ No newline at end of file + run: make isort-check diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 68c0d4af..b06ad33e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,26 +1,31 @@ name: Docs + on: [push, pull_request, workflow_dispatch] + jobs: docs: runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - - uses: actions/setup-node@v3 - with: - node-version: 16 - - run: npm install -g @mermaid-js/mermaid-cli - - name: Install dependencies - run: | - make install - - name: Sphinx build - run: | - make docs - - name: Deploy - uses: peaceiris/actions-gh-pages@v3 - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }} - with: - publish_branch: gh-pages - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: docs/html/ - force_orphan: true \ No newline at end of file + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + - uses: actions/setup-node@v3 + with: + node-version: 16 + + - run: npm install -g @mermaid-js/mermaid-cli + + - name: Install dependencies + run: make install + + - name: Sphinx build + run: make docs + + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }} + with: + publish_branch: gh-pages + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: docs/html/ + force_orphan: true diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml index e0579c79..0860ee8a 100644 --- a/.github/workflows/mypy.yml +++ b/.github/workflows/mypy.yml @@ -5,16 +5,17 @@ on: [push, pull_request] jobs: build: runs-on: ubuntu-latest - name: Mypy type checking + steps: - uses: actions/checkout@v3 + - name: Set up Python 3.9 uses: actions/setup-python@v4 with: python-version: 3.9 + - name: Install Dependencies - run: | - pip install mypy types-setuptools types-docutils + run: make install + - name: mypy - run: | - mypy src \ No newline at end of file + run: make mypy diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 691fa084..ec576c69 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,12 +1,6 @@ name: Test mxmake -on: - push: - branches: - - master - workflow_dispatch: - branches: - - master +on: [push, pull_request] jobs: build: @@ -20,12 +14,14 @@ jobs: - "3.8" - "3.9" - "3.10" + - "3.11" + - "3.12" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3 - - name: Install project - run: make install + - name: Install project + run: make install - - name: Run tests - run: make test + - name: Run tests + run: make test diff --git a/Makefile b/Makefile index e8d823c8..675b5c47 100644 --- a/Makefile +++ b/Makefile @@ -7,10 +7,10 @@ #: core.mxfiles #: core.packages #: docs.sphinx -#: qa.black #: qa.coverage #: qa.isort #: qa.mypy +#: qa.ruff #: qa.test # # SETTINGS (ALL CHANGES MADE BELOW SETTINGS WILL BE LOST) @@ -72,17 +72,17 @@ MXDEV?=https://github.com/mxstack/mxdev/archive/main.zip # Default: mxmake MXMAKE?=-e . -## qa.isort +## qa.ruff -# Source folder to scan for Python files to run isort on. +# Source folder to scan for Python files to run ruff on. # Default: src -ISORT_SRC?=src +RUFF_SRC?=src -## qa.black +## qa.isort -# Source folder to scan for Python files to run black on. +# Source folder to scan for Python files to run isort on. # Default: src -BLACK_SRC?=src +ISORT_SRC?=src ## docs.sphinx @@ -198,8 +198,10 @@ endif MXENV_TARGET:=$(SENTINEL_FOLDER)/mxenv.sentinel $(MXENV_TARGET): $(SENTINEL) ifeq ("$(VENV_ENABLED)", "true") +ifeq ("$(VENV_CREATE)", "true") @echo "Setup Python Virtual Environment under '$(VENV_FOLDER)'" @$(PYTHON_BIN) -m venv $(VENV_FOLDER) +endif endif @$(MXENV_PATH)pip install -U pip setuptools wheel @$(MXENV_PATH)pip install -U $(MXDEV) @@ -216,7 +218,9 @@ mxenv-dirty: .PHONY: mxenv-clean mxenv-clean: mxenv-dirty ifeq ("$(VENV_ENABLED)", "true") +ifeq ("$(VENV_CREATE)", "true") @rm -rf $(VENV_FOLDER) +endif else @$(MXENV_PATH)pip uninstall -y $(MXDEV) @$(MXENV_PATH)pip uninstall -y $(MXMAKE) @@ -226,6 +230,40 @@ INSTALL_TARGETS+=mxenv DIRTY_TARGETS+=mxenv-dirty CLEAN_TARGETS+=mxenv-clean +############################################################################## +# ruff +############################################################################## + +RUFF_TARGET:=$(SENTINEL_FOLDER)/ruff.sentinel +$(RUFF_TARGET): $(MXENV_TARGET) + @echo "Install Ruff" + @$(MXENV_PATH)pip install ruff + @touch $(RUFF_TARGET) + +.PHONY: ruff-check +ruff-check: $(RUFF_TARGET) + @echo "Run ruff check" + @$(MXENV_PATH)ruff check $(RUFF_SRC) + +.PHONY: ruff-format +ruff-format: $(RUFF_TARGET) + @echo "Run ruff format" + @$(MXENV_PATH)ruff format $(RUFF_SRC) + +.PHONY: ruff-dirty +ruff-dirty: + @rm -f $(RUFF_TARGET) + +.PHONY: ruff-clean +ruff-clean: ruff-dirty + @test -e $(MXENV_PATH)pip && $(MXENV_PATH)pip uninstall -y ruff || : + +INSTALL_TARGETS+=$(RUFF_TARGET) +CHECK_TARGETS+=ruff-check +FORMAT_TARGETS+=ruff-format +DIRTY_TARGETS+=ruff-dirty +CLEAN_TARGETS+=ruff-clean + ############################################################################## # isort ############################################################################## @@ -260,40 +298,6 @@ FORMAT_TARGETS+=isort-format DIRTY_TARGETS+=isort-dirty CLEAN_TARGETS+=isort-clean -############################################################################## -# black -############################################################################## - -BLACK_TARGET:=$(SENTINEL_FOLDER)/black.sentinel -$(BLACK_TARGET): $(MXENV_TARGET) - @echo "Install Black" - @$(MXENV_PATH)pip install black - @touch $(BLACK_TARGET) - -.PHONY: black-check -black-check: $(BLACK_TARGET) - @echo "Run black checks" - @$(MXENV_PATH)black --check $(BLACK_SRC) - -.PHONY: black-format -black-format: $(BLACK_TARGET) - @echo "Run black format" - @$(MXENV_PATH)black $(BLACK_SRC) - -.PHONY: black-dirty -black-dirty: - @rm -f $(BLACK_TARGET) - -.PHONY: black-clean -black-clean: black-dirty - @test -e $(MXENV_PATH)pip && $(MXENV_PATH)pip uninstall -y black || : - -INSTALL_TARGETS+=$(BLACK_TARGET) -CHECK_TARGETS+=black-check -FORMAT_TARGETS+=black-format -DIRTY_TARGETS+=black-dirty -CLEAN_TARGETS+=black-clean - ############################################################################## # sphinx ############################################################################## @@ -370,6 +374,7 @@ $(FILES_TARGET): $(PROJECT_CONFIG) $(MXENV_TARGET) $(SOURCES_TARGET) $(LOCAL_PAC $(call set_mxfiles_env,$(MXENV_PATH),$(MXMAKE_FILES)) @$(MXENV_PATH)mxdev -n -c $(PROJECT_CONFIG) $(call unset_mxfiles_env,$(MXENV_PATH),$(MXMAKE_FILES)) + @test -e $(MXMAKE_FILES)/pip.conf && cp $(MXMAKE_FILES)/pip.conf $(VENV_FOLDER)/pip.conf || : @touch $(FILES_TARGET) .PHONY: mxfiles diff --git a/src/mxmake/main.py b/src/mxmake/main.py index 86561890..84d82031 100644 --- a/src/mxmake/main.py +++ b/src/mxmake/main.py @@ -58,21 +58,21 @@ def list_command(args: argparse.Namespace): sys.stdout.write(f"Domain {topic.name}.{domain.name}:\n") depends = ", ".join(domain.depends) if domain.depends else "No dependencies" sys.stdout.write(f" Depends: {depends}\n") - sys.stdout.write(f" Targets:") + sys.stdout.write(" Targets:") targets = domain.targets if not targets: - sys.stdout.write(f" No targets provided\n") + sys.stdout.write(" No targets provided\n") else: - sys.stdout.write(f"\n") + sys.stdout.write("\n") for target in targets: description = indent(target.description, 6 * " ").strip() sys.stdout.write(f" {target.name}: {description}\n") - sys.stdout.write(f" Settings:") + sys.stdout.write(" Settings:") settings = domain.settings if not settings: - sys.stdout.write(f" No settings provided\n") + sys.stdout.write(" No settings provided\n") else: - sys.stdout.write(f"\n") + sys.stdout.write("\n") for setting in settings: description = indent(setting.description, 8 * " ").strip() sys.stdout.write(