Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Update Black checking process and fix output in PR

Syrus Dark27d9b039f1ad
diff --git a/.github/workflows/black-pr.yml b/.github/workflows/black-pr.yml
new file mode 100644
index 000000000..3e4bab4e2
--- /dev/null
+++ b/.github/workflows/black-pr.yml
@@ -0,0 +1,70 @@
+name: black-check
+on:
+ pull_request:
+ branches:
+ - master
+
+jobs:
+ check-format:
+ runs-on: windows-latest
+ steps:
+ - name: Set up Python
+ uses: actions/setup-python@v2
+ with:
+ python-version: 3.8
+
+ - name: Checkout the repository
+ shell: bash
+ run: |
+ prnum=$(python -c "import json;print(json.load(open(r'${GITHUB_EVENT_PATH}'))['number'])")
+ git init
+ git remote add origin https://github.com/ManimCommunity/manim.git
+ git fetch origin pull/${prnum}/head:pr-${prnum}
+ git checkout pr-${prnum}
+
+ - name: Install black
+ run: pip install black
+
+ - name: Get files
+ id: files-changes-in-pr
+ shell: powershell
+ run: |
+ #echo "$(gc "$env:GITHUB_EVENT_PATH")"
+ $payload = gc "$env:GITHUB_EVENT_PATH" | ConvertFrom-Json
+ $commitEndpoint=$($payload.pull_request._links.commits.href)
+ echo "$commitEndpoint"
+ $commits = Invoke-WebRequest -Uri "$commitEndpoint" | ConvertFrom-Json
+ bash -c "git diff --name-only HEAD HEAD~$($commits.count)>/d/changes.txt"
+
+ - name: Run Black on top of latest commit
+ shell: bash
+ run: |
+ printf "Checking Files"
+ printf $(</d/changes.txt)
+ printf "\n"
+ content=$(</d/changes.txt)
+ while read file
+ do
+ if [ $(python -c "print('${file}'[-2:])") == "py" ]
+ then
+ black --diff $file
+ fi
+ done </d/changes.txt
+ while read file
+ do
+ if [ $(python -c "print('${file}'[-2:])") == "py" ]
+ then
+ black $file
+ fi
+ done </d/changes.txt
+
+ - name: Check File and Report the Files Not formatted
+ shell: powershell
+ run: |
+ if ( $(bash -c "git diff --name-only") -eq "" -or $(bash -c "git diff --name-only") -eq $null ){
+ echo 'All files Changed are formatted Correctly'
+ } else {
+ echo 'These files need formatting.'
+ echo "The Filed changed are `n`n $(git ls-files -m)"
+ exit 1
+ }
\ No newline at end of file
diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml
index 9178896a9..6c3eed182 100644
--- a/.github/workflows/black.yml
+++ b/.github/workflows/black.yml
@@ -24,14 +24,12 @@ jobs:
- name: Black
run: |
black manim tests example_scenes
-
- name: Check for modified files
shell: bash
id: git-check
run: |
echo ::set-output name=modified::$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)
- echo ::set-output name=filechange::$(git ls-files -m)
-
+ git ls-files -m>/d/diffmod.txt
- name: Print Black Version if Failed
shell: bash
if: steps.git-check.outputs.modified == 'true'
@@ -45,7 +43,6 @@ jobs:
git checkout -B "$pushBranch"
git add .
git commit -m "Running Black On Master"
-
- name: Push branch
if: steps.git-check.outputs.modified == 'true'
shell: bash
@@ -55,25 +52,24 @@ jobs:
date=$(python -c "import time;print(time.localtime().tm_mday)")
pushBranch="black-${blackVersion}-${date}"
git push -u origin "${pushBranch}" --force
-
- name: Make a PR
if: steps.git-check.outputs.modified == 'true'
env:
access_token: ${{ secrets.GITHUB_TOKEN }}
- file_change: ${{ steps.git-check.outputs.filechange }}
run: |
$blackVer = black --version
$blackVersion = python -c "print('$($blackVer)'.split()[2])"
$date = python -c "import time;print(time.localtime().tm_mday)"
$pushBranch="black-$($blackVersion)-$($date)"
+ $filechange=(gc "D:/diffmod.txt").split() -join "`n`n"
$postContents = @{title="Automated PR: Autoformat with black";
- head="ManimCommunity:$($pushBranch)";
+ head="naveen521kk:$($pushBranch)";
base="master";
- body="This an automated pull requests. Files Changed are `n `n ```````n$($env:file_change)`n``````"
+ body="This an automated pull requests. Files Changed are `n `n ```````n$($filechange)`n``````"
} | ConvertTo-Json -Compress
echo "$postContents"
Invoke-WebRequest `
-Method POST `
-Headers @{ "Accept" = "application/vnd.github.v3+json"; "Authorization"= "token $($env:access_token)"}`
- -Uri https://api.github.com/repos/ManimCommunity/manim/pulls `
- -Body "$($postContents)"
+ -Uri https://api.github.com/repos/naveen521kk/manim/pulls `
+ -Body "$($postContents)"
\ No newline at end of file
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 591519858..d4e0a296e 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -8,29 +8,6 @@ on:
- master
jobs:
- format:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout the repository
- uses: actions/checkout@v2
-
- - name: Set up Python
- uses: actions/setup-python@v2
- with:
- python-version: 3.8
-
- - name: Install black
- run: pip install black
-
- - name: Check manim formatting
- run: black --check --diff manim
-
- - name: Check tests formatting
- run: black --check --diff tests
-
- - name: Check examples formatting
- run: black --check --diff example_scenes
-
test:
runs-on: ${{ matrix.os }}
strategy: