adding the python script and github action for validation also adding… #1
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: Lint | |
| on: | |
| pull_request: | |
| env: | |
| GIT_USERNAME: ${{ github.actor }} | |
| GIT_PASSWORD: ${{ secrets.GITHUB_TOKEN }} | |
| FIX_COMMIT_MESSAGE: Fixed /hook_tools/lint.py lints | |
| jobs: | |
| validate-content: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.head_ref }} | |
| fetch-depth: 0 | |
| submodules: true | |
| - name: Set base commit (pull request) | |
| run: | | |
| echo "GITHUB_BASE_COMMIT=${{ github.event.pull_request.base.sha }}" >> $GITHUB_ENV | |
| echo "GITHUB_CURRENT_COMMIT=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV | |
| if: github.ref != 'refs/heads/main' | |
| - name: Set base commit (main) | |
| run: | | |
| echo "GITHUB_BASE_COMMIT=${{ github.event.before }}" >> $GITHUB_ENV | |
| echo "GITHUB_CURRENT_COMMIT=${{ github.event.after }}" >> $GITHUB_ENV | |
| if: github.ref == 'refs/heads/main' | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.8' | |
| - name: Validate content structure | |
| run: | | |
| cd utils | |
| python validate_content.py | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v2 | |
| with: | |
| ref: ${{ github.head_ref }} | |
| fetch-depth: 0 | |
| submodules: true | |
| - name: Pull container | |
| run: ./utils/lint --only-pull-image | |
| - name: Validate lint | |
| run: | | |
| echo "Running lint validation..." | |
| if ! ./utils/lint \ | |
| --command-name="utils/lint" \ | |
| --diagnostics-output=github \ | |
| validate --all; then | |
| echo "❌ Lint errors detected." | |
| echo "💡 Please run the following locally to fix them:" | |
| echo "" | |
| echo " ./utils/lint fix --all" | |
| echo " git commit -am 'Fix lints'" | |
| echo " git push" | |
| echo "" | |
| exit 1 | |
| fi |