Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b1820f803c | |||
| 20286a7e2c |
+2
-2
@@ -1,5 +1,5 @@
|
||||
[bumpversion]
|
||||
current_version = 1.2.0
|
||||
current_version = 1.1.6
|
||||
commit = True
|
||||
tag = True
|
||||
tag_name = {new_version}
|
||||
@@ -9,4 +9,4 @@ message = New release: {current_version} → {new_version}
|
||||
|
||||
[bumpversion:file:qmk_cli/__init__.py]
|
||||
|
||||
[bumpversion:file:pyproject.toml]
|
||||
[bumpversion:file:setup.cfg]
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
# Please see the documentation for all configuration options:
|
||||
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "github-actions" # See documentation for possible values
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
reviewers:
|
||||
- "qmk/collaborators"
|
||||
- package-ecosystem: "pip" # See documentation for possible values
|
||||
directory: "/" # Location of package manifests
|
||||
schedule:
|
||||
interval: "daily"
|
||||
reviewers:
|
||||
- "qmk/collaborators"
|
||||
@@ -0,0 +1,80 @@
|
||||
name: CLI Setup
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test_cli_base_container:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/qmk/qmk_base_container
|
||||
|
||||
env:
|
||||
QMK_HOME: ~/qmk_firmware
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: apt-get update && apt-get install -y python3-venv
|
||||
|
||||
- name: Run ci_tests
|
||||
run: ./ci_tests -a
|
||||
|
||||
test_cli_linux_macos:
|
||||
needs: test_cli_base_container
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
QMK_HOME: ~/qmk_firmware
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest]
|
||||
python-version: ['3.9', '3.10', '3.11', '3.12']
|
||||
include:
|
||||
- os: macos-13
|
||||
python-version: '3.9'
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Run ci_tests
|
||||
run: ./ci_tests -a
|
||||
|
||||
test_cli_win:
|
||||
needs: test_cli_base_container
|
||||
|
||||
runs-on: windows-latest
|
||||
env:
|
||||
QMK_HOME: $HOME/qmk_firmware
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: (MSYS2) Setup and install dependencies
|
||||
uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
update: true
|
||||
install: git mingw-w64-x86_64-toolchain mingw-w64-x86_64-python-pip mingw-w64-x86_64-python-build mingw-w64-x86_64-python-pillow mingw-w64-x86_64-rust
|
||||
|
||||
# Upgrade pip due to msys packaging + pypa/build/pull/736 issues
|
||||
- name: (MSYS2) Install Python dependencies
|
||||
shell: msys2 {0}
|
||||
run: |
|
||||
python3 -m pip install --upgrade pip
|
||||
|
||||
- name: (MSYS2) Install QMK CLI from source
|
||||
shell: msys2 {0}
|
||||
run: |
|
||||
python3 -m build
|
||||
python3 -m pip install dist/qmk-*.tar.gz
|
||||
- name: (MSYS2) Run qmk setup -y
|
||||
shell: msys2 {0}
|
||||
run: qmk setup -y
|
||||
@@ -0,0 +1,71 @@
|
||||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ master ]
|
||||
schedule:
|
||||
- cron: '22 18 * * 0'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'python' ]
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
|
||||
# Learn more:
|
||||
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v3
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v3
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v3
|
||||
@@ -0,0 +1,56 @@
|
||||
name: Rebuild Docker Image
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
redeploy:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.9'
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: 'Get Previous tag'
|
||||
id: previoustag
|
||||
uses: "WyriHaximus/github-action-get-previous-tag@v1"
|
||||
|
||||
- name: Download previous artifact
|
||||
run: |
|
||||
pip download -d "${GITHUB_WORKSPACE}/dist" qmk=="${{ steps.previoustag.outputs.tag }}"
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
|
||||
|
||||
- name: Build and Push to Docker Hub
|
||||
uses: docker/build-push-action@v6.9.0
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
platforms: linux/amd64,linux/arm64
|
||||
tags: |
|
||||
ghcr.io/qmk/qmk_cli:latest
|
||||
qmkfm/qmk_cli:latest
|
||||
@@ -0,0 +1,89 @@
|
||||
# This workflow will upload a Python Package using Twine when a release is created
|
||||
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
|
||||
|
||||
name: Upload Python Package
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version_part:
|
||||
description: 'Which part of the version to increment (patch, minor, major)'
|
||||
required: true
|
||||
default: 'patch'
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.9'
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Run ci_tests
|
||||
run: ./ci_tests
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python3 -m pip install --upgrade pip
|
||||
pip install setuptools wheel
|
||||
pip install -r requirements-dev.txt
|
||||
|
||||
- name: Bump version
|
||||
run: |
|
||||
git config --local user.email "hello@qmk.fm"
|
||||
git config --local user.name "QMK Bot"
|
||||
bumpversion ${{ github.event.inputs.version_part }}
|
||||
|
||||
- name: Push changes
|
||||
uses: ad-m/github-push-action@master
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
branch: master
|
||||
tags: true
|
||||
|
||||
- name: Build and publish
|
||||
env:
|
||||
TWINE_USERNAME: __token__
|
||||
TWINE_PASSWORD: ${{ secrets.PYPI_APITOKEN }}
|
||||
run: |
|
||||
python3 -m build
|
||||
twine upload dist/*
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
|
||||
|
||||
- name: Build and Push to Docker Hub
|
||||
uses: docker/build-push-action@v6.9.0
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
platforms: linux/amd64,linux/arm64
|
||||
tags: |
|
||||
ghcr.io/qmk/qmk_cli:latest
|
||||
qmkfm/qmk_cli:latest
|
||||
|
||||
- name: Trigger OS package builds
|
||||
run: ./trigger_packages
|
||||
env:
|
||||
QMK_BOT_TOKEN: ${{ secrets.QMK_BOT_TOKEN }}
|
||||
@@ -24,7 +24,6 @@ wheels/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
*.lock
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
FROM ghcr.io/qmk/qmk_base_container:latest
|
||||
|
||||
# Copy package in
|
||||
ADD dist /tmp/dist
|
||||
|
||||
# Install python packages
|
||||
RUN python3 -m pip uninstall -y qmk || true
|
||||
RUN python3 -m pip install --upgrade pip setuptools wheel nose2 && \
|
||||
python3 -m pip install /tmp/dist/qmk-*.whl && \
|
||||
rm -rf /tmp/dist
|
||||
|
||||
# Set the default location for qmk_firmware
|
||||
ENV QMK_HOME /qmk_firmware
|
||||
@@ -1,12 +1,9 @@
|
||||
# QMK CLI
|
||||
[](https://github.com/qmk/qmk_cli/actions/workflows/cli_setup.yml)
|
||||
|
||||
> A program to help users work with [QMK Firmware](https://qmk.fm/).
|
||||
A program to help users work with [QMK Firmware](https://qmk.fm/).
|
||||
|
||||
[](https://github.com/qmk/qmk_cli/tags)
|
||||
[](https://github.com/qmk/qmk_cli/actions?query=workflow%3ACLI+branch%3Amaster)
|
||||
[](https://discord.gg/qmk)
|
||||
|
||||
## Features
|
||||
# Features
|
||||
|
||||
* Interact with your qmk_firmware tree from any location
|
||||
* Use `qmk clone` to pull down anyone's `qmk_firmware` fork
|
||||
@@ -20,31 +17,36 @@
|
||||
* `qmk lint`
|
||||
* ...and many more!
|
||||
|
||||
## Quickstart
|
||||
|
||||
Follow our [documentation to get started](https://docs.qmk.fm/newbs_getting_started).
|
||||
|
||||
## Packages
|
||||
# Packages
|
||||
|
||||
We provide "install and go" packages for many Operating Systems.
|
||||
|
||||
### macOS
|
||||
## Linux
|
||||
|
||||
Packages for several distributions available here: https://github.com/qmk/qmk_fpm
|
||||
|
||||
## macOS
|
||||
|
||||
Using [Homebrew](https://brew.sh):
|
||||
|
||||
brew install qmk/qmk/qmk
|
||||
|
||||
### Windows
|
||||
## Windows
|
||||
|
||||
Download our custom MSYS2 installer here: https://msys.qmk.fm/
|
||||
|
||||
## Building
|
||||
# Quickstart
|
||||
|
||||
* `python3 -m pip install qmk`
|
||||
* `qmk setup`
|
||||
|
||||
# Building
|
||||
|
||||
We follow PEP517, you can install using [build](https://pypi.org/project/build/):
|
||||
|
||||
Setup:
|
||||
|
||||
python3 -m pip install --group dev
|
||||
python3 -m pip install build
|
||||
|
||||
Build:
|
||||
|
||||
@@ -52,6 +54,6 @@ Build:
|
||||
|
||||
You can read more about working with PEP517 packages in the [Python Packaging User Guide](https://packaging.python.org/guides/distributing-packages-using-setuptools/#packaging-your-project).
|
||||
|
||||
## Documentation
|
||||
# Documentation
|
||||
|
||||
Full documentation: <https://docs.qmk.fm/#/tutorial>
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
#set -x
|
||||
|
||||
ADVANCED=false
|
||||
TMPDIR=$(mktemp -d)
|
||||
QMK_HOME="$TMPDIR/qmk_firmware"
|
||||
export QMK_HOME
|
||||
|
||||
for arg in $@; do
|
||||
if [ "$arg" = "-a" ]; then
|
||||
ADVANCED=true
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $ADVANCED = true ]; then
|
||||
echo "*** Running in advanced mode with tmp files in $TMPDIR"
|
||||
else
|
||||
echo "*** Running in basic mode with tmp files in $TMPDIR"
|
||||
fi
|
||||
|
||||
# Setup our virtualenv
|
||||
if [ -e .ci_venv ]; then
|
||||
rm -rf .ci_venv
|
||||
fi
|
||||
|
||||
python3 -m venv .ci_venv
|
||||
source .ci_venv/bin/activate
|
||||
|
||||
# Install dependencies
|
||||
python3 -m pip install -U pip wheel
|
||||
python3 -m pip install .
|
||||
python3 -m pip install -r requirements-dev.txt
|
||||
|
||||
# Ensure that qmk works
|
||||
echo "*** Testing 'qmk clone -h'"
|
||||
qmk clone -h
|
||||
#echo "*** Testing 'qmk config -a'" # Test disabled as `milc` at least 1.6.8+ returns False and thus non-zero exit code
|
||||
#qmk config -a
|
||||
echo "*** Testing 'qmk setup -n'"
|
||||
qmk setup -n
|
||||
|
||||
echo
|
||||
echo "*** Basic tests completed successfully!"
|
||||
|
||||
# Run advanced test if requested
|
||||
if [ $ADVANCED = true ]; then
|
||||
echo
|
||||
echo "*** Testing 'qmk setup -y'"
|
||||
qmk setup -y
|
||||
|
||||
echo
|
||||
echo "*** Advanced tests completed successfully!"
|
||||
fi
|
||||
|
||||
# Cleanup
|
||||
deactivate
|
||||
rm -rf .ci_venv $TMPDIR
|
||||
+4
-133
@@ -1,135 +1,6 @@
|
||||
[build-system]
|
||||
requires = ["setuptools>=82.0.1"]
|
||||
requires = [
|
||||
"setuptools>=42",
|
||||
"wheel"
|
||||
]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "qmk"
|
||||
version = "1.2.0"
|
||||
license = "MIT"
|
||||
readme = "README.md"
|
||||
authors = [{name = "skullydazed", email = "skullydazed@gmail.com"}]
|
||||
description = "A program to help users work with QMK Firmware."
|
||||
classifiers = [
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
"Environment :: Console",
|
||||
"Intended Audience :: Developers",
|
||||
"Intended Audience :: System Administrators",
|
||||
"Intended Audience :: End Users/Desktop",
|
||||
"Natural Language :: English",
|
||||
"Programming Language :: Python :: 3 :: Only",
|
||||
"Topic :: Scientific/Engineering",
|
||||
"Topic :: Software Development",
|
||||
"Topic :: Utilities",
|
||||
]
|
||||
requires-python = ">=3.9"
|
||||
dependencies = [
|
||||
"hid",
|
||||
"milc>=1.9.0",
|
||||
"platformdirs",
|
||||
"pyusb",
|
||||
# qmk_firmware packages
|
||||
"dotty-dict",
|
||||
"hjson",
|
||||
"jsonschema>=4",
|
||||
"pillow",
|
||||
"pygments",
|
||||
"pyserial",
|
||||
]
|
||||
|
||||
[dependency-groups]
|
||||
dev = [
|
||||
"build",
|
||||
"bumpversion",
|
||||
"ruff",
|
||||
"twine",
|
||||
"yapf",
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
"Bug Tracker" = "https://github.com/qmk/qmk_cli/issues"
|
||||
Documentation = "https://docs.qmk.fm/cli"
|
||||
Homepage = "https://qmk.fm/"
|
||||
Source = "https://github.com/qmk/qmk_cli/"
|
||||
|
||||
[project.scripts]
|
||||
qmk = "qmk_cli.script_qmk:main"
|
||||
|
||||
[tool.setuptools]
|
||||
include-package-data = false
|
||||
|
||||
[tool.setuptools.packages]
|
||||
find = {namespaces = false}
|
||||
|
||||
[tool.ruff]
|
||||
target-version = "py39"
|
||||
|
||||
include = ['qmk_cli/**/*.py']
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = ["E", "F", "B", "N", "W", "COM", "C901", "PGH004"]
|
||||
ignore = [
|
||||
"E501", # QMK is ok with long lines.
|
||||
"E231", # Conflicts with our yapf config
|
||||
]
|
||||
|
||||
[tool.ruff.lint.mccabe]
|
||||
max-complexity = 14 # Let's slowly crank this down
|
||||
|
||||
[tool.yapfignore]
|
||||
ignore_patterns = [
|
||||
".direnv/**/*",
|
||||
".env/**/*",
|
||||
]
|
||||
|
||||
[tool.yapf]
|
||||
align_closing_bracket_with_visual_indent = true
|
||||
allow_multiline_dictionary_keys = false
|
||||
allow_multiline_lambdas = false
|
||||
allow_split_before_default_or_named_assigns = true
|
||||
allow_split_before_dict_value = true
|
||||
arithmetic_precedence_indication = true
|
||||
blank_lines_around_top_level_definition = 2
|
||||
blank_line_before_class_docstring = false
|
||||
blank_line_before_module_docstring = false
|
||||
blank_line_before_nested_class_or_def = false
|
||||
coalesce_brackets = true
|
||||
column_limit = 256
|
||||
continuation_align_style = "SPACE"
|
||||
continuation_indent_width = 4
|
||||
dedent_closing_brackets = true
|
||||
disable_ending_comma_heuristic = false
|
||||
each_dict_entry_on_separate_line = true
|
||||
i18n_comment = ""
|
||||
i18n_function_call = ""
|
||||
indent_blank_lines = false
|
||||
indent_dictionary_value = true
|
||||
indent_width = 4
|
||||
join_multiple_lines = false
|
||||
no_spaces_around_selected_binary_operators = ""
|
||||
spaces_around_default_or_named_assign = false
|
||||
spaces_around_power_operator = false
|
||||
spaces_before_comment = 2
|
||||
space_between_ending_comma_and_closing_bracket = false
|
||||
split_all_comma_separated_values = false
|
||||
split_arguments_when_comma_terminated = true
|
||||
split_before_arithmetic_operator = false
|
||||
split_before_bitwise_operator = true
|
||||
split_before_closing_bracket = true
|
||||
split_before_dict_set_generator = true
|
||||
split_before_dot = false
|
||||
split_before_expression_after_opening_paren = false
|
||||
split_before_first_argument = false
|
||||
split_before_logical_operator = false
|
||||
split_before_named_assigns = true
|
||||
split_complex_comprehension = true
|
||||
split_penalty_after_opening_bracket = 300
|
||||
split_penalty_after_unary_operator = 10000
|
||||
split_penalty_arithmetic_operator = 300
|
||||
split_penalty_before_if_expr = 0
|
||||
split_penalty_bitwise_operator = 300
|
||||
split_penalty_comprehension = 80
|
||||
split_penalty_excess_character = 7000
|
||||
split_penalty_for_added_line_split = 30
|
||||
split_penalty_import_names = 0
|
||||
split_penalty_logical_operator = 300
|
||||
use_tabs = false
|
||||
|
||||
@@ -2,5 +2,4 @@
|
||||
"""Wrapper to call the qmk cli script entrypoint.
|
||||
"""
|
||||
import qmk_cli.script_qmk
|
||||
|
||||
qmk_cli.script_qmk.main()
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
"""A program to help you work with qmk_firmware."""
|
||||
|
||||
__version__ = '1.2.0'
|
||||
__version__ = '1.1.6'
|
||||
|
||||
+5
-77
@@ -1,47 +1,22 @@
|
||||
"""Useful helper functions.
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
import stat
|
||||
import json
|
||||
import shutil
|
||||
from functools import lru_cache
|
||||
from importlib.util import find_spec
|
||||
from pathlib import Path
|
||||
|
||||
from milc import cli
|
||||
|
||||
|
||||
def AbsPath(arg): # noqa: N802
|
||||
"""Resolve relative paths to the original working directory.
|
||||
"""
|
||||
arg = Path(arg)
|
||||
if not arg.is_absolute():
|
||||
return (Path(os.environ['ORIG_CWD']) / arg).absolute()
|
||||
|
||||
return arg
|
||||
|
||||
|
||||
def rmtree(path):
|
||||
"""Safe version of shutil.rmtree which handles errors on Windows where some of the files have their read-only bit set."""
|
||||
def remove_readonly(func, path, _):
|
||||
"""Clear the readonly bit and reattempt the removal."""
|
||||
os.chmod(path, stat.S_IWRITE)
|
||||
func(path)
|
||||
|
||||
if sys.version_info >= (3, 12):
|
||||
# See https://docs.python.org/3.12/whatsnew/3.12.html#shutil
|
||||
return shutil.rmtree(path, onexc=remove_readonly)
|
||||
else:
|
||||
return shutil.rmtree(path, onerror=remove_readonly)
|
||||
|
||||
|
||||
def is_qmk_firmware(qmk_firmware):
|
||||
"""Returns True if the given Path() is a qmk_firmware clone.
|
||||
"""
|
||||
paths = [
|
||||
qmk_firmware,
|
||||
qmk_firmware / 'quantum',
|
||||
qmk_firmware / 'lib/python/qmk/cli/__init__.py',
|
||||
qmk_firmware / 'requirements.txt',
|
||||
qmk_firmware / 'requirements-dev.txt',
|
||||
qmk_firmware / 'lib/python/qmk/cli/__init__.py'
|
||||
]
|
||||
|
||||
for path in paths:
|
||||
@@ -51,7 +26,7 @@ def is_qmk_firmware(qmk_firmware):
|
||||
return True
|
||||
|
||||
|
||||
@lru_cache(maxsize=1)
|
||||
@lru_cache(maxsize=2)
|
||||
def find_qmk_firmware():
|
||||
"""Look for qmk_firmware in the usual places.
|
||||
|
||||
@@ -72,7 +47,6 @@ def find_qmk_firmware():
|
||||
return Path.home() / 'qmk_firmware'
|
||||
|
||||
|
||||
@lru_cache(maxsize=1)
|
||||
def in_qmk_firmware():
|
||||
"""Returns the path to the qmk_firmware we are currently in, or None if we are not inside qmk_firmware.
|
||||
"""
|
||||
@@ -84,49 +58,3 @@ def in_qmk_firmware():
|
||||
# Move up a directory before the next iteration
|
||||
cur_dir = cur_dir / '..'
|
||||
cur_dir = cur_dir.resolve()
|
||||
|
||||
|
||||
def is_qmk_userspace(qmk_userspace):
|
||||
"""Returns True if the given Path() is a qmk_userspace clone.
|
||||
"""
|
||||
path = qmk_userspace / 'qmk.json'
|
||||
if not path.exists():
|
||||
return False
|
||||
|
||||
try:
|
||||
return 'userspace_version' in json.loads(path.read_text(encoding="UTF-8"))
|
||||
except json.decoder.JSONDecodeError:
|
||||
return False
|
||||
|
||||
|
||||
@lru_cache(maxsize=1)
|
||||
def find_qmk_userspace():
|
||||
"""Look for qmk_userspace in the usual places.
|
||||
"""
|
||||
if in_qmk_userspace():
|
||||
return in_qmk_userspace()
|
||||
|
||||
if 'QMK_USERSPACE' in os.environ:
|
||||
path = Path(os.environ['QMK_USERSPACE']).expanduser()
|
||||
if path.exists():
|
||||
return path.resolve()
|
||||
return path
|
||||
|
||||
if cli.config.user.overlay_dir:
|
||||
return Path(cli.config.user.overlay_dir).expanduser().resolve()
|
||||
|
||||
return Path.home() / 'qmk_userspace'
|
||||
|
||||
|
||||
@lru_cache(maxsize=1)
|
||||
def in_qmk_userspace():
|
||||
"""Returns the path to the qmk_userspace we are currently in, or None if we are not inside qmk_userspace.
|
||||
"""
|
||||
cur_dir = Path.cwd()
|
||||
while len(cur_dir.parents) > 0:
|
||||
if is_qmk_userspace(cur_dir):
|
||||
return cur_dir
|
||||
|
||||
# Move up a directory before the next iteration
|
||||
cur_dir = cur_dir / '..'
|
||||
cur_dir = cur_dir.resolve()
|
||||
|
||||
+13
-33
@@ -4,7 +4,6 @@
|
||||
This program can be run from anywhere, with or without a qmk_firmware repository. If a qmk_firmware repository can be located we will use that to augment our available subcommands.
|
||||
"""
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -12,38 +11,15 @@ from platform import platform
|
||||
from traceback import print_exc
|
||||
|
||||
import milc
|
||||
import platformdirs
|
||||
|
||||
from . import __version__
|
||||
from .helpers import find_qmk_firmware, is_qmk_firmware, find_qmk_userspace, is_qmk_userspace
|
||||
|
||||
|
||||
def _get_default_distrib_path():
|
||||
if 'windows' in platform().lower():
|
||||
try:
|
||||
result = milc.cli.run(['cygpath', '-w', '/opt/qmk'])
|
||||
if result.returncode == 0:
|
||||
return result.stdout.strip()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return platformdirs.user_data_dir('qmk')
|
||||
|
||||
|
||||
# Ensure the QMK distribution is on the `$PATH` if present. This must be kept in sync with qmk/qmk_firmware.
|
||||
QMK_DISTRIB_DIR = Path(os.environ.get('QMK_DISTRIB_DIR', _get_default_distrib_path()))
|
||||
if QMK_DISTRIB_DIR.exists():
|
||||
os.environ['PATH'] = str(QMK_DISTRIB_DIR / 'bin') + os.pathsep + os.environ['PATH']
|
||||
|
||||
# Prepend any user-defined path prefix
|
||||
if 'QMK_PATH_PREFIX' in os.environ:
|
||||
os.environ['PATH'] = os.environ['QMK_PATH_PREFIX'] + os.pathsep + os.environ['PATH']
|
||||
from .helpers import find_qmk_firmware, is_qmk_firmware
|
||||
|
||||
milc.cli.milc_options(version=__version__)
|
||||
milc.EMOJI_LOGLEVELS['INFO'] = '{fg_blue}Ψ{style_reset_all}'
|
||||
|
||||
# These must happen after the milc.milc_options() call
|
||||
import milc.subcommand.config # noqa: E402, must come after milc.milc_options()
|
||||
import milc.subcommand.config # noqa, must come after milc.milc_options()
|
||||
|
||||
|
||||
@milc.cli.entrypoint('CLI wrapper for running QMK commands.')
|
||||
@@ -73,17 +49,21 @@ def main():
|
||||
print('Warning: Your Python version is out of date! Some subcommands may not work!')
|
||||
print('Please upgrade to Python 3.9 or later.')
|
||||
|
||||
if 'windows' in platform().lower():
|
||||
msystem = os.environ.get('MSYSTEM', '')
|
||||
|
||||
if 'mingw64' not in sys.executable or 'MINGW64' not in msystem:
|
||||
print('ERROR: It seems you are not using the MINGW64 terminal.')
|
||||
print('Please close this terminal and open a new MSYS2 MinGW 64-bit terminal.')
|
||||
print('Python: %s, MSYSTEM: %s' % (sys.executable, msystem))
|
||||
exit(1)
|
||||
|
||||
# Environment setup
|
||||
qmk_userspace = find_qmk_userspace()
|
||||
qmk_firmware = find_qmk_firmware()
|
||||
if is_qmk_userspace(qmk_userspace):
|
||||
os.environ['QMK_USERSPACE'] = str(qmk_userspace)
|
||||
elif 'QMK_USERSPACE' in os.environ: # Failed to find valid userspace, including what was in the environment if specified -- wipe any environment variable if present as it's clearly invalid.
|
||||
os.environ.pop('QMK_USERSPACE')
|
||||
os.environ['QMK_HOME'] = str(qmk_firmware)
|
||||
os.environ['ORIG_CWD'] = os.getcwd()
|
||||
|
||||
import qmk_cli.subcommands # noqa: F401
|
||||
import qmk_cli.subcommands
|
||||
|
||||
# Check out and initialize the qmk_firmware environment
|
||||
if is_qmk_firmware(qmk_firmware):
|
||||
@@ -92,7 +72,7 @@ def main():
|
||||
sys.path.append(str(qmk_firmware / 'lib/python'))
|
||||
|
||||
try:
|
||||
import qmk.cli # noqa: F401
|
||||
import qmk.cli # noqa
|
||||
|
||||
except ImportError as e:
|
||||
if qmk_firmware.name != 'qmk_firmware':
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
We list each subcommand here explicitly because all the reliable ways of searching for modules are slow and delay startup.
|
||||
"""
|
||||
from . import clone # noqa: F401
|
||||
from . import console # noqa: F401
|
||||
from . import env # noqa: F401
|
||||
from . import setup # noqa: F401
|
||||
from . import clone # noqa
|
||||
from . import console # noqa
|
||||
from . import env # noqa
|
||||
from . import setup # noqa
|
||||
|
||||
@@ -5,7 +5,6 @@ from pathlib import Path
|
||||
|
||||
from milc import cli
|
||||
from qmk_cli.git import git_clone
|
||||
from qmk_cli.helpers import AbsPath
|
||||
|
||||
default_repo = 'qmk_firmware'
|
||||
default_fork = 'qmk/' + default_repo
|
||||
@@ -14,14 +13,18 @@ default_branch = 'master'
|
||||
|
||||
@cli.argument('--baseurl', arg_only=True, default='https://github.com', help='The URL all git operations start from (Default: https://github.com)')
|
||||
@cli.argument('-b', '--branch', arg_only=True, default=default_branch, help='The branch to clone. Default: %s' % default_branch)
|
||||
@cli.argument('destination', arg_only=True, default=Path(os.environ['ORIG_CWD']) / default_repo, type=AbsPath, nargs='?', help='The directory to clone to. Default: (current directory)')
|
||||
@cli.argument('destination', arg_only=True, default=None, nargs='?', help='The directory to clone to. Default: (current directory)')
|
||||
@cli.argument('fork', arg_only=True, default=default_fork, nargs='?', help='The qmk_firmware fork to clone. Default: %s' % default_fork)
|
||||
@cli.subcommand('Clone a qmk_firmware fork.')
|
||||
def clone(cli):
|
||||
if not cli.args.destination:
|
||||
cli.args.destination = os.path.join(os.environ['ORIG_CWD'], default_fork.split('/')[-1])
|
||||
|
||||
qmk_firmware = Path(cli.args.destination)
|
||||
git_url = '/'.join((cli.args.baseurl, cli.args.fork))
|
||||
|
||||
# Exists (but not an empty dir)
|
||||
if cli.args.destination.exists() and any(cli.args.destination.iterdir()):
|
||||
if qmk_firmware.exists() and any(qmk_firmware.iterdir()):
|
||||
cli.log.error('Destination already exists: %s', cli.args.destination)
|
||||
exit(1)
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ KNOWN_BOOTLOADERS = {
|
||||
('2A03', '0036'): 'caterina: Arduino Leonardo',
|
||||
('2A03', '0037'): 'caterina: Arduino Micro',
|
||||
('314B', '0106'): 'apm32-dfu: APM32 DFU ISP Mode',
|
||||
('342D', 'DFA0'): 'wb32-dfu: WB32 Device in DFU Mode',
|
||||
('342D', 'DFA0'): 'wb32-dfu: WB32 Device in DFU Mode'
|
||||
}
|
||||
|
||||
|
||||
@@ -96,19 +96,7 @@ def import_usb_core():
|
||||
def import_hid():
|
||||
"""Attempts to import the hid module.
|
||||
"""
|
||||
import os
|
||||
old_cwd = os.getcwd()
|
||||
try:
|
||||
# macOS library search paths don't include homebrew by default when launched via a `uv`-based deployment.
|
||||
# The `hid` python module does a search and attempts to load a set of known library names, but doesn't qualify the path, nor gives the option to do so.
|
||||
# To work around this, we chdir to the homebrew lib directory before importing hid, then chdir back to where we were.
|
||||
if 'darwin' in platform().lower() or 'macos' in platform().lower():
|
||||
for path in ('/opt/homebrew/lib', '/usr/local/lib'):
|
||||
lib_search = Path(path) / 'libhidapi.dylib'
|
||||
if lib_search.exists():
|
||||
os.chdir(path)
|
||||
break
|
||||
|
||||
import hid
|
||||
return hid
|
||||
|
||||
@@ -119,8 +107,6 @@ def import_hid():
|
||||
return import_hid()
|
||||
|
||||
raise
|
||||
finally:
|
||||
os.chdir(old_cwd)
|
||||
|
||||
|
||||
class MonitorDevice(object):
|
||||
|
||||
@@ -4,20 +4,16 @@ import os
|
||||
from pathlib import Path
|
||||
|
||||
from milc import cli
|
||||
from qmk_cli.helpers import is_qmk_firmware, is_qmk_userspace
|
||||
from qmk_cli.helpers import is_qmk_firmware
|
||||
|
||||
|
||||
@cli.argument('var', arg_only=True, default=None, nargs='?', help='Optional variable to query')
|
||||
@cli.subcommand('Prints environment information.')
|
||||
def env(cli):
|
||||
home = os.environ.get('QMK_HOME', "")
|
||||
userspace = os.environ.get('QMK_USERSPACE', "")
|
||||
data = {
|
||||
'QMK_HOME': home,
|
||||
'QMK_FIRMWARE': home if is_qmk_firmware(Path(home)) else "",
|
||||
'QMK_USERSPACE': userspace if is_qmk_userspace(Path(userspace)) else "",
|
||||
'QMK_DISTRIB_DIR': os.environ.get('QMK_DISTRIB_DIR', ""),
|
||||
'QMK_PATH_PREFIX': os.environ.get('QMK_PATH_PREFIX', ""),
|
||||
'QMK_FIRMWARE': home if is_qmk_firmware(Path(home)) else ""
|
||||
}
|
||||
|
||||
# Now munge the current cli config
|
||||
|
||||
@@ -7,9 +7,9 @@ import sys
|
||||
from pathlib import Path
|
||||
|
||||
from milc import cli
|
||||
from milc.questions import choice, question, yesno
|
||||
from milc.questions import yesno
|
||||
from qmk_cli.git import git_clone
|
||||
from qmk_cli.helpers import AbsPath, is_qmk_firmware, rmtree
|
||||
from qmk_cli.helpers import is_qmk_firmware
|
||||
|
||||
default_base = 'https://github.com'
|
||||
default_repo = 'qmk_firmware'
|
||||
@@ -43,22 +43,11 @@ def git_upstream(destination):
|
||||
return False
|
||||
|
||||
|
||||
def git_clone_fork(fork, branch, force=False):
|
||||
if force:
|
||||
rmtree(cli.args.home)
|
||||
|
||||
git_url = '/'.join((cli.args.baseurl, fork))
|
||||
if git_clone(git_url, cli.args.home, branch):
|
||||
git_upstream(cli.args.home)
|
||||
else:
|
||||
exit(1)
|
||||
|
||||
|
||||
@cli.argument('-n', '--no', arg_only=True, action='store_true', help='Answer no to all questions')
|
||||
@cli.argument('-y', '--yes', arg_only=True, action='store_true', help='Answer yes to all questions')
|
||||
@cli.argument('--baseurl', arg_only=True, default=default_base, help='The URL all git operations start from. Default: %s' % default_base)
|
||||
@cli.argument('-b', '--branch', arg_only=True, default=default_branch, help='The branch to clone. Default: %s' % default_branch)
|
||||
@cli.argument('-H', '--home', arg_only=True, default=Path(os.environ['QMK_HOME']), type=AbsPath, help='The location for QMK Firmware. Default: %s' % os.environ['QMK_HOME'])
|
||||
@cli.argument('-H', '--home', arg_only=True, default=Path(os.environ['QMK_HOME']), type=Path, help='The location for QMK Firmware. Default: %s' % os.environ['QMK_HOME'])
|
||||
@cli.argument('fork', arg_only=True, default=default_fork, nargs='?', help='The qmk_firmware fork to clone. Default: %s' % default_fork)
|
||||
@cli.subcommand('Setup your computer for qmk_firmware.')
|
||||
def setup(cli):
|
||||
@@ -72,34 +61,9 @@ def setup(cli):
|
||||
cli.log.error("Can't use both --yes and --no at the same time.")
|
||||
exit(1)
|
||||
|
||||
# Check on qmk_firmware
|
||||
# If it exists, ask the user what to do with it
|
||||
# If it doesn't exist, offer to check it out
|
||||
# Check on qmk_firmware, and if it doesn't exist offer to check it out.
|
||||
if is_qmk_firmware(cli.args.home):
|
||||
cli.log.info('Found qmk_firmware at %s.', str(cli.args.home))
|
||||
found_prompt = "What do you want to do?"
|
||||
found_options = [
|
||||
f"Delete and reclone {cli.args.fork}",
|
||||
"Delete and clone a different fork",
|
||||
"Keep it and continue",
|
||||
]
|
||||
delete_confirm = "WARNING: This will delete your current qmk_firmware directory. Proceed?"
|
||||
|
||||
found_action = choice(found_prompt, options=found_options, default=2)
|
||||
if found_action == f"Delete and reclone {cli.args.fork}":
|
||||
if not yesno(delete_confirm, default=False):
|
||||
exit(1)
|
||||
|
||||
git_clone_fork(cli.args.fork, cli.args.branch, force=True)
|
||||
|
||||
elif found_action == "Delete and clone a different fork":
|
||||
fork_name = question("Enter the name of the fork:", default=cli.args.fork)
|
||||
branch_name = question("Enter the branch name to clone:", default=cli.args.branch)
|
||||
|
||||
if not yesno(delete_confirm, default=False):
|
||||
exit(1)
|
||||
|
||||
git_clone_fork(fork_name, branch_name, force=True)
|
||||
|
||||
# Exists (but not an empty dir)
|
||||
elif cli.args.home.exists() and any(cli.args.home.iterdir()):
|
||||
@@ -114,7 +78,12 @@ def setup(cli):
|
||||
else:
|
||||
cli.log.error('Could not find qmk_firmware!')
|
||||
if yesno(clone_prompt):
|
||||
git_clone_fork(cli.args.fork, cli.args.branch)
|
||||
git_url = '/'.join((cli.args.baseurl, cli.args.fork))
|
||||
|
||||
if git_clone(git_url, cli.args.home, cli.args.branch):
|
||||
git_upstream(cli.args.home)
|
||||
else:
|
||||
exit(1)
|
||||
else:
|
||||
cli.log.warning('Not cloning qmk_firmware due to user input or --no flag.')
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
# Increment the verison number and release a new version of qmk_cli.
|
||||
#
|
||||
# Required packages: pip3 install bumpversion twine
|
||||
|
||||
echo "Use the github action instead!"
|
||||
exit 1
|
||||
@@ -0,0 +1,4 @@
|
||||
build
|
||||
bumpversion
|
||||
requests
|
||||
twine
|
||||
@@ -0,0 +1,3 @@
|
||||
--index-url https://pypi.python.org/simple/
|
||||
|
||||
-e .
|
||||
@@ -0,0 +1,110 @@
|
||||
#[bumpversion]
|
||||
# Bumpversion config has been moved to .bumpversion.cfg
|
||||
|
||||
[bdist_wheel]
|
||||
universal = 1
|
||||
|
||||
[flake8]
|
||||
ignore = E501,E226
|
||||
|
||||
[metadata]
|
||||
name = qmk
|
||||
version = 1.1.6
|
||||
author = skullydazed
|
||||
author_email = skullydazed@gmail.com
|
||||
description = A program to help users work with QMK Firmware.
|
||||
long_description = file: README.md
|
||||
long_description_content_type = text/markdown
|
||||
license = MIT License
|
||||
project_urls =
|
||||
Bug Tracker = https://github.com/qmk/qmk_cli/issues
|
||||
Documentation = https://docs.qmk.fm/#/cli
|
||||
Homepage = https://qmk.fm/
|
||||
Source = https://github.com/qmk/qmk_cli/
|
||||
classifiers =
|
||||
Development Status :: 3 - Alpha
|
||||
Environment :: Console
|
||||
Intended Audience :: Developers
|
||||
Intended Audience :: System Administrators
|
||||
Intended Audience :: End Users/Desktop
|
||||
License :: OSI Approved :: MIT License
|
||||
Natural Language :: English
|
||||
Programming Language :: Python :: 3 :: Only
|
||||
Topic :: Scientific/Engineering
|
||||
Topic :: Software Development
|
||||
Topic :: Utilities
|
||||
|
||||
[options]
|
||||
install_requires =
|
||||
hid
|
||||
milc>=1.9.0
|
||||
pyusb
|
||||
setuptools>=45
|
||||
# qmk_firmware packages
|
||||
dotty-dict
|
||||
hjson
|
||||
httpx
|
||||
jsonschema>=4
|
||||
pillow
|
||||
pygments
|
||||
pyserial
|
||||
tqdm
|
||||
packages = find:
|
||||
python_requires = >=3.9
|
||||
|
||||
[options.entry_points]
|
||||
console_scripts =
|
||||
qmk = qmk_cli.script_qmk:main
|
||||
|
||||
[yapf]
|
||||
align_closing_bracket_with_visual_indent = True
|
||||
allow_multiline_dictionary_keys = False
|
||||
allow_multiline_lambdas = False
|
||||
allow_split_before_default_or_named_assigns = True
|
||||
allow_split_before_dict_value = True
|
||||
arithmetic_precedence_indication = True
|
||||
blank_lines_around_top_level_definition = 2
|
||||
blank_line_before_class_docstring = False
|
||||
blank_line_before_module_docstring = False
|
||||
blank_line_before_nested_class_or_def = False
|
||||
coalesce_brackets = True
|
||||
column_limit = 256
|
||||
continuation_align_style = SPACE
|
||||
continuation_indent_width = 4
|
||||
dedent_closing_brackets = True
|
||||
disable_ending_comma_heuristic = False
|
||||
each_dict_entry_on_separate_line = True
|
||||
i18n_comment =
|
||||
i18n_function_call =
|
||||
indent_blank_lines = False
|
||||
indent_dictionary_value = True
|
||||
indent_width = 4
|
||||
join_multiple_lines = False
|
||||
no_spaces_around_selected_binary_operators =
|
||||
spaces_around_default_or_named_assign = False
|
||||
spaces_around_power_operator = False
|
||||
spaces_before_comment = 2
|
||||
space_between_ending_comma_and_closing_bracket = False
|
||||
split_all_comma_separated_values = False
|
||||
split_arguments_when_comma_terminated = True
|
||||
split_before_arithmetic_operator = False
|
||||
split_before_bitwise_operator = True
|
||||
split_before_closing_bracket = True
|
||||
split_before_dict_set_generator = True
|
||||
split_before_dot = False
|
||||
split_before_expression_after_opening_paren = False
|
||||
split_before_first_argument = False
|
||||
split_before_logical_operator = False
|
||||
split_before_named_assigns = True
|
||||
split_complex_comprehension = True
|
||||
split_penalty_after_opening_bracket = 300
|
||||
split_penalty_after_unary_operator = 10000
|
||||
split_penalty_arithmetic_operator = 300
|
||||
split_penalty_before_if_expr = 0
|
||||
split_penalty_bitwise_operator = 300
|
||||
split_penalty_comprehension = 80
|
||||
split_penalty_excess_character = 7000
|
||||
split_penalty_for_added_line_split = 30
|
||||
split_penalty_import_names = 0
|
||||
split_penalty_logical_operator = 300
|
||||
use_tabs = False
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Trigger workflows that build QMK packages.
|
||||
"""
|
||||
from os import environ
|
||||
from pathlib import Path
|
||||
|
||||
import requests
|
||||
|
||||
# Pull in environment vars
|
||||
gh_user = environ.get('GH_USERNAME', 'qmk-bot')
|
||||
gh_pat = environ.get('QMK_BOT_TOKEN', '')
|
||||
gh_repo_owner = environ.get('REPO_OWNER', 'qmk')
|
||||
gh_repo_name = environ.get('REPO_NAME', 'qmk_fpm')
|
||||
gh_ref = environ.get('BRANCH_NAME', 'main')
|
||||
gh_workflow_ids = environ.get('WORKFLOW_IDS', 'all-trigger.yml').split(',')
|
||||
gh_api_url = environ.get('GITHUB_API_URL', 'https://api.github.com')
|
||||
gh_workflow_args = {'ref': gh_ref}
|
||||
gh_workflow_headers = {'Accept': 'application/vnd.github.v3+json'}
|
||||
|
||||
for gh_workflow_id in gh_workflow_ids:
|
||||
gh_workflow_endpoint = f'{gh_api_url}/repos/{gh_repo_owner}/{gh_repo_name}/actions/workflows/{gh_workflow_id}/dispatches'
|
||||
print(f'Triggering {gh_workflow_id} workflow at: {gh_workflow_endpoint}')
|
||||
workflow_dispatch = requests.post(gh_workflow_endpoint, headers=gh_workflow_headers, json=gh_workflow_args, auth=(gh_user, gh_pat))
|
||||
if workflow_dispatch.status_code != 204:
|
||||
print(f'Error from GitHub API, status_code {workflow_dispatch.status_code}!')
|
||||
print(workflow_dispatch.text)
|
||||
exit(1)
|
||||
|
||||
exit(0)
|
||||
Reference in New Issue
Block a user