From 9caa1f6b723c62a12364028454dab938fd71a2b9 Mon Sep 17 00:00:00 2001 From: TSRBerry <20988865+TSRBerry@users.noreply.github.com> Date: Sat, 1 Apr 2023 17:51:07 +0200 Subject: [PATCH] Add workflow to automatically apply black formatting & Add dependabot (#27) * Add automatic formatting for pull requests * Add dependabot.yml --- .github/dependabot.yml | 18 ++++++++++++ .github/workflows/formatting.yml | 49 ++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/formatting.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..7a476f4 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,18 @@ +version: 2 + +updates: + - package-ecosystem: github-actions + directory: / + open-pull-requests-limit: 5 + reviewers: + - marysaka + schedule: + interval: weekly + + - package-ecosystem: pip + directory: / + open-pull-requests-limit: 5 + reviewers: + - marysaka + schedule: + interval: weekly \ No newline at end of file diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml new file mode 100644 index 0000000..7547152 --- /dev/null +++ b/.github/workflows/formatting.yml @@ -0,0 +1,49 @@ +name: Check formatting + +on: + pull_request: + +permissions: + contents: write + pull-requests: write + checks: write + +jobs: + black: + name: Python Black + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + + - uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - name: Install black + run: pip install black + + - name: Configure git + run: | + git config --global user.name github-actions[bot] + git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com + + - name: Run black + run: python -m black . + + - name: Check if files have been modified + id: mod_check + run: | + [[ $(git status -s | wc -l) -le 1 ]] \ + && echo "is-dirty=false" >> "$GITHUB_OUTPUT" \ + || echo "is-dirty=true" >> "$GITHUB_OUTPUT" + + - name: Commit and push changes + if: steps.mod_check.outputs.is-dirty == 'true' + run: | + git add . + git commit -m "Apply black formatting" + git push +