Data source improvement #1
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: Validate Attack Data on PR | |
| on: | |
| pull_request: | |
| branches: [ master, main ] | |
| types: [opened, synchronize, reopened] | |
| paths: | |
| - 'datasets/**/*.yml' | |
| - 'datasets/**/*.yaml' | |
| - 'bin/validate.py' | |
| - 'bin/dataset_schema.json' | |
| - 'bin/requirements.txt' | |
| jobs: | |
| validate-attack-data: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| # Fetch full history for proper validation | |
| fetch-depth: 0 | |
| lfs: true | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.9' | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r bin/requirements.txt | |
| - name: Validate YAML files | |
| run: | | |
| cd bin | |
| python validate.py ../datasets | |
| env: | |
| PYTHONPATH: ${{ github.workspace }}/bin | |
| - name: Comment PR on failure | |
| if: failure() | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const { owner, repo, number } = context.issue; | |
| await github.rest.issues.createComment({ | |
| owner, | |
| repo, | |
| issue_number: number, | |
| body: '❌ **Attack Data Validation Failed**\n\nThe YAML files in this PR do not pass validation. Please check the workflow logs for detailed error messages and fix the issues before merging.\n\n[View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})' | |
| }); | |
| - name: Comment PR on success | |
| if: success() | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const { owner, repo, number } = context.issue; | |
| await github.rest.issues.createComment({ | |
| owner, | |
| repo, | |
| issue_number: number, | |
| body: '✅ **Attack Data Validation Passed**\n\nAll YAML files in this PR have been successfully validated against the schema.' | |
| }); | |