Nowa klasa Main #5
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: java-linter | |
| on: | |
| pull_request: | |
| branches: [main] | |
| paths: ['**.java'] | |
| workflow_call: | |
| jobs: | |
| java-linter: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v4.1.0 | |
| - name: Run check style | |
| uses: nikitasavinov/checkstyle-action@0.6.0 | |
| with: | |
| level: warning | |
| fail_on_error: true | |
| need-help: | |
| runs-on: ubuntu-latest | |
| needs: [java-linter] | |
| if: ${{ failure() }} | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v4.1.0 | |
| - name: Setting up python | |
| uses: actions/setup-python@v4.7.1 | |
| with: | |
| python-version: '3.12' | |
| - name: Install Clang | |
| uses: egor-tensin/setup-clang@v1 | |
| - name: Getting PR details | |
| run: | | |
| touch pr.json # creating empty file for paths | |
| gh pr view $PR_NUMBER --json files > pr.json # storing file paths | |
| touch res # creating empty file for final output | |
| env: | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Python script for clang diff | |
| uses: jannekem/run-python-script-action@v1 | |
| with: | |
| script: | | |
| import os | |
| import json | |
| import sys | |
| with open('pr.json','r') as json_file: | |
| data = json.load(json_file) | |
| for file in data["files"]: | |
| path = file["path"] | |
| if os.path.exists(path): | |
| os.system('echo "" >> res') | |
| os.system(f'echo "Filename: {path}" >> res') | |
| os.system('echo "" >> res') | |
| os.system(f'clang-format -style=Google {path} >> res') | |
| os.system('echo ---------------------------------------- >> res') | |
| - name: Show diffs and exit | |
| run: | | |
| cat res |