Model training and evaluation #24
Workflow file for this run
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: Pylint | |
| on: [pull_request] | |
| jobs: | |
| lint-autofix: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: false # Needed for manual push | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install autopep8 | |
| - name: Auto-fix with autopep8 | |
| run: autopep8 --in-place --aggressive --aggressive -r $(git ls-files '*.py') | |
| - name: Commit and push changes | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git fetch origin ${{ github.head_ref }} | |
| git checkout ${{ github.head_ref }} | |
| git add . | |
| if ! git diff --cached --quiet; then | |
| git commit -m "chore: auto-fix Python lint issues" | |
| git rebase origin/${{ github.head_ref }} | |
| git push https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }} HEAD:refs/heads/${{ github.head_ref }} | |
| fi | |
| env: | |
| # Required if using a token for push | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| build: | |
| needs: lint-autofix | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["3.10"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v3 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install pylint | |
| pip install -r requirements.txt | |
| - name: Run Pylint for logs (with score) | |
| if: always() | |
| run: pylint --rcfile=config/.pylintrc $(git ls-files '*.py') --exit-zero | |
| - name: Analysing the code with pylint | |
| run: | | |
| pylint --rcfile=config/.pylintrc $(git ls-files '*.py') --exit-zero --output-format=json > pylint_output.json | |
| - name: Analyze Pylint results | |
| run: | | |
| echo "Analyzing Pylint output..." | |
| ERRORS=$(jq '[.[] | select(.type == "error" or .type == "fatal")] | length' pylint_output.json) | |
| WARNINGS=$(jq '[.[] | select(.type == "warning")] | length' pylint_output.json) | |
| echo "Found $ERRORS errors and $WARNINGS warnings." | |
| if [ "$ERRORS" -gt 0 ]; then | |
| echo "::error ::Pylint found $ERRORS error(s). Failing the build." | |
| exit 1 | |
| else | |
| echo "No critical errors found. Passing!" | |
| fi | |
| - name: Upload Pylint report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pylint-report | |
| path: pylint_output.json | |
| - name: Show Pylint warnings | |
| if: always() | |
| run: | | |
| echo "Warnings:" | |
| jq -r '.[] | select(.type == "warning") | "\(.path):\(.line): \(.message)"' pylint_output.json || true | |
| - name: Show Pylint errors | |
| if: always() | |
| run: | | |
| echo "Errors:" | |
| jq -r '.[] | select(.type == "error" or .type == "fatal") | "\(.path):\(.line): \(.message)"' pylint_output.json || true | |