From bd6cdf24f4779eef630194940b7f460d95b09ecd Mon Sep 17 00:00:00 2001 From: Andrei-Aksionov Date: Wed, 22 Nov 2023 12:58:22 +0300 Subject: [PATCH 01/14] Ruff and Black CLI workflow. --- .github/workflows/code_style_fix.yaml | 51 +++++++++++++++++++++++++++ .github/workflows/test.yaml | 4 +++ 2 files changed, 55 insertions(+) create mode 100644 .github/workflows/code_style_fix.yaml diff --git a/.github/workflows/code_style_fix.yaml b/.github/workflows/code_style_fix.yaml new file mode 100644 index 0000000..46d4fa2 --- /dev/null +++ b/.github/workflows/code_style_fix.yaml @@ -0,0 +1,51 @@ +name: Automatic Code Style Fix + +on: [pull_request, pull_request_target] + +jobs: + auto_code_style_fix: + runs-on: ubuntu-22.04 + steps: + # - name: Checkout ️🛒 + # uses: actions/checkout@v4 + # with: + # ref: ${{ github.head_ref }} + # fetch-depth: 0 + + - name: Checkout 🛎️ + uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: recursive + token: ${{ secrets.github-token || github.token }} + + - name: Black ◼️ + uses: psf/black@stable + with: + # options: "-l120 -C --target-version py38 chat eval finetune generate lit_gpt notebooks pretrain quantize scripts tests xla" + options: "-l120 -C --target-version py38 notebooks src" + jupyter: true + + - name: Ruff ®️ + uses: chartboost/ruff-action@v1 + with: + args: --select E,W,F,S --extend-select C4,SIM,RET,PT,I001,ANN001,ANN201,ANN205,ANN206,ARG001 --ignore E501,E731,S108,S101,S113,S603,PT007,S310,E402,PT004,C408 --per-file-ignores "*/**/__init__.py":I001,"tests/*":ANN --line-length 120 --target-version py38 --fix-only + + # - name: Commit files ✔️ + # run: | + # git config --local user.email "github-actions[bot]@users.noreply.github.com" + # git config --local user.name "github-actions[bot]" + # git diff-index --quiet HEAD || git commit -a -m "Automatic code-style fix." + + # - name: Pushing changes 🛠 ️ + # uses: ad-m/github-push-action@master + # with: + # branch: ${{ github.head_ref }} + # github_token: ${{ secrets.github-token || github.token }} + - name: Fixing Pull Request ↩️ + # if: always() && inputs.push-fixes == true && steps.precommit.outcome == 'failure' + uses: actions-js/push@v1.4 + with: + github_token: ${{ secrets.github-token || github.token }} + message: "pre-commit: running and fixing..." + branch: ${{ github.ref_name }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index dbc5cdb..ce07736 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -5,6 +5,10 @@ on: push: branches: [main] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + jobs: test: strategy: From b0f7cc6fe194ccb4edb5cad7659c9b4a9a22f379 Mon Sep 17 00:00:00 2001 From: Andrei-Aksionov Date: Wed, 22 Nov 2023 13:02:21 +0300 Subject: [PATCH 02/14] Update --- .github/workflows/code_style_fix.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code_style_fix.yaml b/.github/workflows/code_style_fix.yaml index 46d4fa2..2d1ae78 100644 --- a/.github/workflows/code_style_fix.yaml +++ b/.github/workflows/code_style_fix.yaml @@ -48,4 +48,4 @@ jobs: with: github_token: ${{ secrets.github-token || github.token }} message: "pre-commit: running and fixing..." - branch: ${{ github.ref_name }} + branch: ${{ github.ref_name || github.head_ref }} From 3f3d3d13a302314426f171e961bd2c3f68f9098c Mon Sep 17 00:00:00 2001 From: Andrei-Aksionov Date: Wed, 22 Nov 2023 13:04:25 +0300 Subject: [PATCH 03/14] Update --- .github/workflows/code_style_fix.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code_style_fix.yaml b/.github/workflows/code_style_fix.yaml index 2d1ae78..8257595 100644 --- a/.github/workflows/code_style_fix.yaml +++ b/.github/workflows/code_style_fix.yaml @@ -48,4 +48,4 @@ jobs: with: github_token: ${{ secrets.github-token || github.token }} message: "pre-commit: running and fixing..." - branch: ${{ github.ref_name || github.head_ref }} + branch: ${{ github.head_ref || github.ref_name }} From c44f4c806c787a2744f1f643534be8a686176f7d Mon Sep 17 00:00:00 2001 From: Andrei-Aksionov Date: Wed, 22 Nov 2023 13:08:29 +0300 Subject: [PATCH 04/14] Update --- .github/workflows/code_style_fix.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/code_style_fix.yaml b/.github/workflows/code_style_fix.yaml index 8257595..68b392d 100644 --- a/.github/workflows/code_style_fix.yaml +++ b/.github/workflows/code_style_fix.yaml @@ -1,6 +1,12 @@ name: Automatic Code Style Fix -on: [pull_request, pull_request_target] +# on: [pull_request, pull_request_target] +on: + workflow_call: + secrets: + github-token: + description: "if provided an user GH's token, it will push update; requires `push` event" + required: false jobs: auto_code_style_fix: From 139731042dd3a58f55da8f3617f5d1849fdde795 Mon Sep 17 00:00:00 2001 From: Andrei-Aksionov Date: Wed, 22 Nov 2023 13:10:51 +0300 Subject: [PATCH 05/14] Update --- .github/workflows/code_style_fix.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/code_style_fix.yaml b/.github/workflows/code_style_fix.yaml index 68b392d..1a6115e 100644 --- a/.github/workflows/code_style_fix.yaml +++ b/.github/workflows/code_style_fix.yaml @@ -2,6 +2,7 @@ name: Automatic Code Style Fix # on: [pull_request, pull_request_target] on: + [pull_request, pull_request_target] workflow_call: secrets: github-token: From b3a816ca8fb4ef6aaf09e73366d52b2739e77fc1 Mon Sep 17 00:00:00 2001 From: Andrei-Aksionov Date: Wed, 22 Nov 2023 13:12:04 +0300 Subject: [PATCH 06/14] Update --- .github/workflows/code_style_fix.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/code_style_fix.yaml b/.github/workflows/code_style_fix.yaml index 1a6115e..c29c4b3 100644 --- a/.github/workflows/code_style_fix.yaml +++ b/.github/workflows/code_style_fix.yaml @@ -1,8 +1,7 @@ name: Automatic Code Style Fix -# on: [pull_request, pull_request_target] +on: [pull_request, pull_request_target] on: - [pull_request, pull_request_target] workflow_call: secrets: github-token: From 8ac89fbe43132ab069fc807bd0437ea5ac3fbc99 Mon Sep 17 00:00:00 2001 From: Andrei-Aksionov Date: Wed, 22 Nov 2023 13:14:06 +0300 Subject: [PATCH 07/14] Update --- .github/workflows/code_style_fix.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/code_style_fix.yaml b/.github/workflows/code_style_fix.yaml index c29c4b3..e20d6a9 100644 --- a/.github/workflows/code_style_fix.yaml +++ b/.github/workflows/code_style_fix.yaml @@ -1,7 +1,8 @@ name: Automatic Code Style Fix -on: [pull_request, pull_request_target] on: + pull_request: + branches: [main] workflow_call: secrets: github-token: From 421a4d2b35f070a44b17902e8e2dca86c2abb888 Mon Sep 17 00:00:00 2001 From: Andrei-Aksionov Date: Wed, 22 Nov 2023 13:26:19 +0300 Subject: [PATCH 08/14] Update --- .github/workflows/code_style_fix.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/code_style_fix.yaml b/.github/workflows/code_style_fix.yaml index e20d6a9..af56946 100644 --- a/.github/workflows/code_style_fix.yaml +++ b/.github/workflows/code_style_fix.yaml @@ -52,6 +52,8 @@ jobs: - name: Fixing Pull Request ↩️ # if: always() && inputs.push-fixes == true && steps.precommit.outcome == 'failure' uses: actions-js/push@v1.4 + permissions: + actions: write with: github_token: ${{ secrets.github-token || github.token }} message: "pre-commit: running and fixing..." From 1022ea80e3167767f0436cd157d231d1f36df3b3 Mon Sep 17 00:00:00 2001 From: Andrei-Aksionov Date: Wed, 22 Nov 2023 13:28:03 +0300 Subject: [PATCH 09/14] Update --- .github/workflows/code_style_fix.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code_style_fix.yaml b/.github/workflows/code_style_fix.yaml index af56946..13a68d7 100644 --- a/.github/workflows/code_style_fix.yaml +++ b/.github/workflows/code_style_fix.yaml @@ -1,5 +1,7 @@ name: Automatic Code Style Fix +permissions: + actions: write on: pull_request: branches: [main] @@ -52,8 +54,6 @@ jobs: - name: Fixing Pull Request ↩️ # if: always() && inputs.push-fixes == true && steps.precommit.outcome == 'failure' uses: actions-js/push@v1.4 - permissions: - actions: write with: github_token: ${{ secrets.github-token || github.token }} message: "pre-commit: running and fixing..." From 3a8cdf113304c80d2eecda21aeb4a522479d3f90 Mon Sep 17 00:00:00 2001 From: Andrei-Aksionov Date: Wed, 22 Nov 2023 13:29:52 +0300 Subject: [PATCH 10/14] Update --- .github/workflows/code_style_fix.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code_style_fix.yaml b/.github/workflows/code_style_fix.yaml index 13a68d7..59f9e7c 100644 --- a/.github/workflows/code_style_fix.yaml +++ b/.github/workflows/code_style_fix.yaml @@ -1,7 +1,8 @@ name: Automatic Code Style Fix -permissions: - actions: write +permissions: write-all + + on: pull_request: branches: [main] From 05a098aa74bc87f621fb7ba83337f5c1b58cee9a Mon Sep 17 00:00:00 2001 From: Andrei-Aksionov Date: Wed, 22 Nov 2023 13:42:11 +0300 Subject: [PATCH 11/14] Update --- .github/workflows/code_style_fix.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/code_style_fix.yaml b/.github/workflows/code_style_fix.yaml index 59f9e7c..5d26ef6 100644 --- a/.github/workflows/code_style_fix.yaml +++ b/.github/workflows/code_style_fix.yaml @@ -56,6 +56,8 @@ jobs: # if: always() && inputs.push-fixes == true && steps.precommit.outcome == 'failure' uses: actions-js/push@v1.4 with: - github_token: ${{ secrets.github-token || github.token }} + # github_token: ${{ secrets.github-token || github.token }} + # github_token: ${{ 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 }} + github_token: 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 message: "pre-commit: running and fixing..." branch: ${{ github.head_ref || github.ref_name }} From 404cfe15edaff118192f3c7d298881af6937a352 Mon Sep 17 00:00:00 2001 From: Andrei-Aksionov Date: Wed, 22 Nov 2023 13:44:37 +0300 Subject: [PATCH 12/14] Update --- .github/workflows/code_style_fix.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/code_style_fix.yaml b/.github/workflows/code_style_fix.yaml index 5d26ef6..c0864b0 100644 --- a/.github/workflows/code_style_fix.yaml +++ b/.github/workflows/code_style_fix.yaml @@ -58,6 +58,7 @@ jobs: with: # github_token: ${{ secrets.github-token || github.token }} # github_token: ${{ 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 }} - github_token: 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 + # github_token: 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 + token: ${{ secrets.ruff_black_pat }} message: "pre-commit: running and fixing..." branch: ${{ github.head_ref || github.ref_name }} From 5cd05f1acdd642b7f400417110c49085d2b9f83f Mon Sep 17 00:00:00 2001 From: Andrei-Aksionov Date: Wed, 22 Nov 2023 13:45:39 +0300 Subject: [PATCH 13/14] Update --- .github/workflows/code_style_fix.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code_style_fix.yaml b/.github/workflows/code_style_fix.yaml index c0864b0..baa7441 100644 --- a/.github/workflows/code_style_fix.yaml +++ b/.github/workflows/code_style_fix.yaml @@ -59,6 +59,6 @@ jobs: # github_token: ${{ secrets.github-token || github.token }} # github_token: ${{ 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 }} # github_token: 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 - token: ${{ secrets.ruff_black_pat }} + github_token: ${{ secrets.ruff_black_pat }} message: "pre-commit: running and fixing..." branch: ${{ github.head_ref || github.ref_name }} From f2fb1a5aabc8ccfd977bda3ee882c93219e38c6f Mon Sep 17 00:00:00 2001 From: Andrei-Aksionov Date: Wed, 22 Nov 2023 13:55:25 +0300 Subject: [PATCH 14/14] Update --- .github/workflows/code_style_fix.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/code_style_fix.yaml b/.github/workflows/code_style_fix.yaml index baa7441..a6d4788 100644 --- a/.github/workflows/code_style_fix.yaml +++ b/.github/workflows/code_style_fix.yaml @@ -59,6 +59,7 @@ jobs: # github_token: ${{ secrets.github-token || github.token }} # github_token: ${{ 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 }} # github_token: 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 - github_token: ${{ secrets.ruff_black_pat }} + # github_token: ${{ secrets.ruff_black_pat }} + github_token: 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 message: "pre-commit: running and fixing..." branch: ${{ github.head_ref || github.ref_name }}