From f78fbd3edfc49a8a68a6a8e6441f9bebfeccd5c7 Mon Sep 17 00:00:00 2001 From: jspijker Date: Sun, 20 Nov 2022 10:51:42 +0100 Subject: [PATCH 1/3] Auto format printer/profiles with printer-linter Runs only master and release branch, will create a co-authored commit if formatting was applied --- .github/workflows/printer_linter_format.yml | 45 +++++++++++++++++++ .../workflows/requirements-printer-linter.txt | 1 + 2 files changed, 46 insertions(+) create mode 100644 .github/workflows/printer_linter_format.yml create mode 100644 .github/workflows/requirements-printer-linter.txt diff --git a/.github/workflows/printer_linter_format.yml b/.github/workflows/printer_linter_format.yml new file mode 100644 index 0000000000..75134cddbb --- /dev/null +++ b/.github/workflows/printer_linter_format.yml @@ -0,0 +1,45 @@ +name: printer-linter-format + +on: + push: + branches: + - main + - '[1-9].[0-9]' + - '[1-9].[0-9][0-9]' + path: + - 'resources/**' + +jobs: + printer_lint: + name: Printer linter auto format + + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Python and pip + uses: actions/setup-python@v4 + with: + python-version: 3.11.x + cache: 'pip' + cache-dependency-path: .github/workflows/requirements-printer-linter.txt + + - uses: technote-space/get-diff-action@v6 + with: + PATTERNS: | + resources/+(definitions|extruders)/*.def.json + resources/+(intent|quality|variants)/**/*.inst.cfg + + - name: Install Python requirements for runner + if: env.GIT_DIFF && !env.MATCHED_FILES + run: pip install -r .github/workflows/requirements-printer-linter.txt + + - name: Format file + if: env.GIT_DIFF && !env.MATCHED_FILES + run: python printer-linter/printer-linter.py --format ${{ env.GIT_DIFF_FILTERED }} + + - uses: stefanzweifel/git-auto-commit-action@v4 + if: env.GIT_DIFF && !env.MATCHED_FILES + with: + commit_message: "Applied printer-linter format" diff --git a/.github/workflows/requirements-printer-linter.txt b/.github/workflows/requirements-printer-linter.txt new file mode 100644 index 0000000000..4818cc5419 --- /dev/null +++ b/.github/workflows/requirements-printer-linter.txt @@ -0,0 +1 @@ +pyyaml \ No newline at end of file From db7e89815ee6d189aa5efd3ddc6f997688f88da3 Mon Sep 17 00:00:00 2001 From: jspijker Date: Mon, 21 Nov 2022 13:16:26 +0100 Subject: [PATCH 2/3] Renamed the workflow for consistency --- .github/workflows/printer-linter-format.yml | 45 +++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/printer-linter-format.yml diff --git a/.github/workflows/printer-linter-format.yml b/.github/workflows/printer-linter-format.yml new file mode 100644 index 0000000000..9fb5a1c584 --- /dev/null +++ b/.github/workflows/printer-linter-format.yml @@ -0,0 +1,45 @@ +name: printer-linter-format + +on: + push: + branches: + - main + - '[1-9].[0-9]' + - '[1-9].[0-9][0-9]' + path: + - 'resources/**' + +jobs: + printer-linter-format: + name: Printer linter auto format + + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Python and pip + uses: actions/setup-python@v4 + with: + python-version: 3.11.x + cache: 'pip' + cache-dependency-path: .github/workflows/requirements-printer-linter.txt + + - uses: technote-space/get-diff-action@v6 + with: + PATTERNS: | + resources/+(definitions|extruders)/*.def.json + resources/+(intent|quality|variants)/**/*.inst.cfg + + - name: Install Python requirements for runner + if: env.GIT_DIFF && !env.MATCHED_FILES + run: pip install -r .github/workflows/requirements-printer-linter.txt + + - name: Format file + if: env.GIT_DIFF && !env.MATCHED_FILES + run: python printer-linter/src/terminal.py --format ${{ env.GIT_DIFF_FILTERED }} + + - uses: stefanzweifel/git-auto-commit-action@v4 + if: env.GIT_DIFF && !env.MATCHED_FILES + with: + commit_message: "Applied printer-linter format" From def686e61af04f9330d797b7d1ab60bcd5eba536 Mon Sep 17 00:00:00 2001 From: jspijker Date: Mon, 21 Nov 2022 13:32:23 +0100 Subject: [PATCH 3/3] Remove old workflow --- .github/workflows/printer_linter_format.yml | 45 --------------------- 1 file changed, 45 deletions(-) delete mode 100644 .github/workflows/printer_linter_format.yml diff --git a/.github/workflows/printer_linter_format.yml b/.github/workflows/printer_linter_format.yml deleted file mode 100644 index 75134cddbb..0000000000 --- a/.github/workflows/printer_linter_format.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: printer-linter-format - -on: - push: - branches: - - main - - '[1-9].[0-9]' - - '[1-9].[0-9][0-9]' - path: - - 'resources/**' - -jobs: - printer_lint: - name: Printer linter auto format - - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup Python and pip - uses: actions/setup-python@v4 - with: - python-version: 3.11.x - cache: 'pip' - cache-dependency-path: .github/workflows/requirements-printer-linter.txt - - - uses: technote-space/get-diff-action@v6 - with: - PATTERNS: | - resources/+(definitions|extruders)/*.def.json - resources/+(intent|quality|variants)/**/*.inst.cfg - - - name: Install Python requirements for runner - if: env.GIT_DIFF && !env.MATCHED_FILES - run: pip install -r .github/workflows/requirements-printer-linter.txt - - - name: Format file - if: env.GIT_DIFF && !env.MATCHED_FILES - run: python printer-linter/printer-linter.py --format ${{ env.GIT_DIFF_FILTERED }} - - - uses: stefanzweifel/git-auto-commit-action@v4 - if: env.GIT_DIFF && !env.MATCHED_FILES - with: - commit_message: "Applied printer-linter format"