From deed84ce8c2bdc442b4b4dea8d9cb4f5bfa13cb6 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 10 Jun 2024 00:26:19 +0200 Subject: [PATCH 1/4] feat: new workflows --- .editorconfig | 10 +++++ .github/workflows/format-all.yml | 55 ++++++++++++++++++++++++ .github/workflows/format-lua.yml | 56 ++++++++++++++++++++++++ .github/workflows/format-prettier.yml | 62 +++++++++++++++++++++++++++ 4 files changed, 183 insertions(+) create mode 100644 .editorconfig create mode 100644 .github/workflows/format-all.yml create mode 100644 .github/workflows/format-lua.yml create mode 100644 .github/workflows/format-prettier.yml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..383d3ca5e --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +trim_trailing_whitespace = true +max_line_length = 300 +indent_size = 4 +indent_style = space \ No newline at end of file diff --git a/.github/workflows/format-all.yml b/.github/workflows/format-all.yml new file mode 100644 index 000000000..e61c04b60 --- /dev/null +++ b/.github/workflows/format-all.yml @@ -0,0 +1,55 @@ +name: formatter-all + +on: + push: + branches: [ main ] + pull_request: + types: [ labeled ] + +jobs: + formatter: + name: formatter + runs-on: ubuntu-latest + permissions: + contents: write + if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.label.name == 'format_all') }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + fetch-depth: 0 + - uses: actions/setup-node@v3 + with: + node-version: "16" + - name: Check exist lua files + id: check_lua_files + uses: andstor/file-existence-action@v2 + with: + files: "*.lua" + - name: Install stylua and format files + if: steps.check_lua_files.outputs.files_exists == 'true' + uses: JohnnyMorganz/stylua-action@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + version: v0.18.0 + args: -- . + - name: Check exist web files + id: check_web_files + uses: andstor/file-existence-action@v2 + with: + files: "**/*.{ts,js,css,html}" + - name: Format files with Prettier + if: steps.check_web_files.outputs.files_exists == 'true' + run: | + npx prettier --write '**/*.{ts,js,css,html}' + - name: Update repo before push + run: | + git pull + - name: Commit changes and push current branch + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_user_name: BPT GITHUB ACTIONS BOT + commit_user_email: bpt-github-actions-bot@users.noreply.github.com + commit_message: :art:Code formatted in all files \ No newline at end of file diff --git a/.github/workflows/format-lua.yml b/.github/workflows/format-lua.yml new file mode 100644 index 000000000..803971a96 --- /dev/null +++ b/.github/workflows/format-lua.yml @@ -0,0 +1,56 @@ +name: formatter-lua + +on: + push: + branches: [ main ] + pull_request: + types: [ labeled ] + +jobs: + formatter: + name: formatter + runs-on: ubuntu-latest + permissions: + contents: write + if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.label.name == 'format') }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + fetch-depth: 0 + - uses: actions/setup-node@v3 + with: + node-version: "16" + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v37 + with: + files: | + **/*.lua + !**/*.yml + - name: List all changed files + run: | + for file in ${{ steps.changed-files.outputs.all_changed_files }}; do + echo "$file was changed" + done + - name: Install stylua + if: steps.changed-files.outputs.any_changed == 'true' + uses: JohnnyMorganz/stylua-action@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + version: v0.18.0 + args: -- ${{ steps.changed-files.outputs.all_changed_files }} + - name: Update repo before push + run: | + git pull + - name: Commit changes and push current branch + if: steps.changed-files.outputs.any_changed == 'true' + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_user_name: BPT GITHUB ACTIONS BOT + commit_user_email: bpt-github-actions-bot@users.noreply.github.com + commit_message: :art:Code formatted in *.lua files + file_pattern: '*.lua' + status_options: '--untracked-files=no' \ No newline at end of file diff --git a/.github/workflows/format-prettier.yml b/.github/workflows/format-prettier.yml new file mode 100644 index 000000000..5f881b3f4 --- /dev/null +++ b/.github/workflows/format-prettier.yml @@ -0,0 +1,62 @@ +name: formatter-prettier + +on: + push: + branches: [ main ] + pull_request: + types: [ labeled ] + +jobs: + formatter: + name: formatter + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.label.name == 'format') }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + fetch-depth: 0 + - uses: actions/setup-node@v3 + with: + node-version: "16" + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v37 + with: + files: | + **/*.{js,html,css} + !**/*.yml + !**/*.min.js + - name: List all changed files + run: | + for file in ${{ steps.changed-files.outputs.all_changed_files }}; do + echo "$file was changed" + done + - name: Get file extensions + if: steps.changed-files.outputs.any_changed == 'true' + id: getext + run: | + import os + files = '${{ steps.changed-files.outputs.all_changed_files }}'.split() + extensions = set('*' + os.path.splitext(file)[1] for file in files) + with open(os.getenv('GITHUB_ENV'), 'a') as f: + f.write(f"CHANGED_EXTENSIONS={' '.join(extensions)}\n") + shell: python + - name: Format changed files with Prettier + if: steps.changed-files.outputs.any_changed == 'true' + run: | + npx prettier --write ${{ steps.changed-files.outputs.all_changed_files }} + - name: Update repo before push + run: | + git pull + - name: Commit changed files and push current branch + if: steps.changed-files.outputs.any_changed == 'true' + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_user_name: BPT GITHUB ACTIONS BOT + commit_user_email: bpt-github-actions-bot@users.noreply.github.com + commit_message: :art:Code formatted in ${{ env.CHANGED_EXTENSIONS }} files + file_pattern: ${{ env.CHANGED_EXTENSIONS }} + status_options: '--untracked-files=no' \ No newline at end of file From 216e46a296cae82aefbef5f39addedbaac8cdde7 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 10 Jun 2024 00:28:19 +0200 Subject: [PATCH 2/4] delete: .github\labeler.yml --- .github/labeler.yml | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 .github/labeler.yml diff --git a/.github/labeler.yml b/.github/labeler.yml deleted file mode 100644 index a8a1bd725..000000000 --- a/.github/labeler.yml +++ /dev/null @@ -1,22 +0,0 @@ -# This workflow will triage pull requests and apply a label based on the -# paths that are modified in the pull request. -# -# To use this workflow, you will need to set up a .github/labeler.yml -# file with configuration. For more information, see: -# https://github.com/actions/labeler - -name: Labeler -on: [pull_request] - -jobs: - label: - - runs-on: ubuntu-latest - permissions: - contents: read - pull-requests: write - - steps: - - uses: actions/labeler@v4 - with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" From e38f24d0f400a3cf413fd5cfb15e6b0bbd7980ef Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 10 Jun 2024 00:30:28 +0200 Subject: [PATCH 3/4] fix: years LICENSE --- LICENSE | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index 26ecd4f64..7c1b638e7 100644 --- a/LICENSE +++ b/LICENSE @@ -632,7 +632,7 @@ state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - Copyright (C) 2022-2023 bitpredator + Copyright (C) 2022-2024 bitpredator This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: - Copyright (C) 2022-2023 bitpredator + Copyright (C) 2022-2024 bitpredator This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. From 82876a2fd1da71c5d6b121d26749a763a51abee1 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 10 Jun 2024 00:38:01 +0200 Subject: [PATCH 4/4] chore: change workflows --- .github/workflows/StyLuaGitHubAction.yml | 7 +++ .github/workflows/format-all.yml | 55 --------------------- .github/workflows/format-lua.yml | 56 --------------------- .github/workflows/format-prettier.yml | 62 ------------------------ 4 files changed, 7 insertions(+), 173 deletions(-) create mode 100644 .github/workflows/StyLuaGitHubAction.yml delete mode 100644 .github/workflows/format-all.yml delete mode 100644 .github/workflows/format-lua.yml delete mode 100644 .github/workflows/format-prettier.yml diff --git a/.github/workflows/StyLuaGitHubAction.yml b/.github/workflows/StyLuaGitHubAction.yml new file mode 100644 index 000000000..c2e6153e9 --- /dev/null +++ b/.github/workflows/StyLuaGitHubAction.yml @@ -0,0 +1,7 @@ +- uses: actions/checkout@v4 +- uses: JohnnyMorganz/stylua-action@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + version: latest # NOTE: we recommend pinning to a specific version in case of formatting changes + # CLI arguments + args: --check . \ No newline at end of file diff --git a/.github/workflows/format-all.yml b/.github/workflows/format-all.yml deleted file mode 100644 index e61c04b60..000000000 --- a/.github/workflows/format-all.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: formatter-all - -on: - push: - branches: [ main ] - pull_request: - types: [ labeled ] - -jobs: - formatter: - name: formatter - runs-on: ubuntu-latest - permissions: - contents: write - if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.label.name == 'format_all') }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - uses: actions/checkout@v3 - with: - ref: ${{ github.head_ref }} - fetch-depth: 0 - - uses: actions/setup-node@v3 - with: - node-version: "16" - - name: Check exist lua files - id: check_lua_files - uses: andstor/file-existence-action@v2 - with: - files: "*.lua" - - name: Install stylua and format files - if: steps.check_lua_files.outputs.files_exists == 'true' - uses: JohnnyMorganz/stylua-action@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - version: v0.18.0 - args: -- . - - name: Check exist web files - id: check_web_files - uses: andstor/file-existence-action@v2 - with: - files: "**/*.{ts,js,css,html}" - - name: Format files with Prettier - if: steps.check_web_files.outputs.files_exists == 'true' - run: | - npx prettier --write '**/*.{ts,js,css,html}' - - name: Update repo before push - run: | - git pull - - name: Commit changes and push current branch - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_user_name: BPT GITHUB ACTIONS BOT - commit_user_email: bpt-github-actions-bot@users.noreply.github.com - commit_message: :art:Code formatted in all files \ No newline at end of file diff --git a/.github/workflows/format-lua.yml b/.github/workflows/format-lua.yml deleted file mode 100644 index 803971a96..000000000 --- a/.github/workflows/format-lua.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: formatter-lua - -on: - push: - branches: [ main ] - pull_request: - types: [ labeled ] - -jobs: - formatter: - name: formatter - runs-on: ubuntu-latest - permissions: - contents: write - if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.label.name == 'format') }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - uses: actions/checkout@v3 - with: - ref: ${{ github.head_ref }} - fetch-depth: 0 - - uses: actions/setup-node@v3 - with: - node-version: "16" - - name: Get changed files - id: changed-files - uses: tj-actions/changed-files@v37 - with: - files: | - **/*.lua - !**/*.yml - - name: List all changed files - run: | - for file in ${{ steps.changed-files.outputs.all_changed_files }}; do - echo "$file was changed" - done - - name: Install stylua - if: steps.changed-files.outputs.any_changed == 'true' - uses: JohnnyMorganz/stylua-action@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - version: v0.18.0 - args: -- ${{ steps.changed-files.outputs.all_changed_files }} - - name: Update repo before push - run: | - git pull - - name: Commit changes and push current branch - if: steps.changed-files.outputs.any_changed == 'true' - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_user_name: BPT GITHUB ACTIONS BOT - commit_user_email: bpt-github-actions-bot@users.noreply.github.com - commit_message: :art:Code formatted in *.lua files - file_pattern: '*.lua' - status_options: '--untracked-files=no' \ No newline at end of file diff --git a/.github/workflows/format-prettier.yml b/.github/workflows/format-prettier.yml deleted file mode 100644 index 5f881b3f4..000000000 --- a/.github/workflows/format-prettier.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: formatter-prettier - -on: - push: - branches: [ main ] - pull_request: - types: [ labeled ] - -jobs: - formatter: - name: formatter - runs-on: ubuntu-latest - if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.label.name == 'format') }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - uses: actions/checkout@v3 - with: - ref: ${{ github.head_ref }} - fetch-depth: 0 - - uses: actions/setup-node@v3 - with: - node-version: "16" - - name: Get changed files - id: changed-files - uses: tj-actions/changed-files@v37 - with: - files: | - **/*.{js,html,css} - !**/*.yml - !**/*.min.js - - name: List all changed files - run: | - for file in ${{ steps.changed-files.outputs.all_changed_files }}; do - echo "$file was changed" - done - - name: Get file extensions - if: steps.changed-files.outputs.any_changed == 'true' - id: getext - run: | - import os - files = '${{ steps.changed-files.outputs.all_changed_files }}'.split() - extensions = set('*' + os.path.splitext(file)[1] for file in files) - with open(os.getenv('GITHUB_ENV'), 'a') as f: - f.write(f"CHANGED_EXTENSIONS={' '.join(extensions)}\n") - shell: python - - name: Format changed files with Prettier - if: steps.changed-files.outputs.any_changed == 'true' - run: | - npx prettier --write ${{ steps.changed-files.outputs.all_changed_files }} - - name: Update repo before push - run: | - git pull - - name: Commit changed files and push current branch - if: steps.changed-files.outputs.any_changed == 'true' - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_user_name: BPT GITHUB ACTIONS BOT - commit_user_email: bpt-github-actions-bot@users.noreply.github.com - commit_message: :art:Code formatted in ${{ env.CHANGED_EXTENSIONS }} files - file_pattern: ${{ env.CHANGED_EXTENSIONS }} - status_options: '--untracked-files=no' \ No newline at end of file