Add Phase A product workspace and pipeline control-plane (pipeline app, docs, env-driven settings, tests) #237
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Fix Pylint Errors with Black | ||
| on: | ||
| push: | ||
| branches: | ||
| - '!main' | ||
| pull_request: | ||
| env: | ||
| NO_COMMIT: false | ||
| jobs: | ||
| fix_pylint_errors: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Set branch name | ||
| run: | | ||
| if [ "${{ github.event_name }}" == "pull_request" ]; then | ||
| branch_name="${{ github.event.pull_request.head.ref }}" | ||
| else | ||
| branch_name="${{ github.ref }}" | ||
| fi | ||
| echo "BRANCH_NAME=${branch_name}" >> $GITHUB_ENV | ||
| - name: Checkout code | ||
| uses: actions/checkout@v2 | ||
| with: | ||
| ref: ${{ env.BRANCH_NAME }} | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v2 | ||
| with: | ||
| python-version: 3.11.x | ||
| - name: Install dependencies | ||
| run: | | ||
| pip install black pylint pylint-json2html | ||
| - name: Run Black | ||
| run: | | ||
| black . | ||
| - name: Check for Pylint errors | ||
| run: | | ||
| mkdir _pylint_reports | ||
| pylint --rcfile=.pylintrc --exit-zero --persistent=n --output-format=json:_pylint_reports/pylint_report.json,colorized --reports=yes $(git ls-files '*.py') | ||
| pylint-json2html -o _pylint_reports/pylint_report.html -e utf-8 _pylint_reports/pylint_report.json | ||
| - name: Upload pylint reports after fixing errors | ||
| uses: actions/upload-artifact@v2 | ||
| with: | ||
| name: pylint_reports | ||
| path: _pylint_reports | ||
| - name: Download artifacts | ||
| uses: actions/download-artifact@v2 | ||
| with: | ||
| name: pylint_reports | ||
| - name: Commit changes | ||
| id: commit_changes | ||
| run: | | ||
| git config --global user.email "action@github.com" | ||
| git config --global user.name "GitHub Action" | ||
| git add . | ||
| if [ -z "$(git status --porcelain)" ]; then | ||
| echo "No changes to commit." | ||
| echo "NO_COMMIT=true" >> $GITHUB_ENV | ||
| exit 0 | ||
| fi | ||
| git commit -m "Fix Pylint errors with Black" | ||
| - name: Push changes | ||
| id: push_changes | ||
| if: ${{ env.NO_COMMIT != 'true' }} | ||
| uses: ad-m/github-push-action@master | ||
| with: | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| branch: ${{ env.BRANCH_NAME }} | ||
| - name: Comment on Pull Request | ||
| if: (${{ env.NO_COMMIT }} != 'true') && (${{ github.event_name }} == 'pull_request') | ||
|
Check warning on line 83 in .github/workflows/pylint-auto.yml
|
||
| uses: actions/github-script@v2 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| with: | ||
| script: | | ||
| if (process.env.NO_COMMIT !== 'true') { | ||
| const result = await github.pulls.list({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| head: context.sha, | ||
| }); | ||
| if (result.data.length) { | ||
| const pullRequest = result.data[0]; | ||
| await github.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: pullRequest.number, | ||
| body: 'Linting errors observed and fixed 🎉. Please pull the latest changes!!', | ||
| }); | ||
| } | ||
| } | ||