Skip to content

Commit 934606f

Browse files
authored
Merge pull request #1037 from splunk/gha_fix
Don't checkout things we don't need
2 parents 05cda58 + 7a647d0 commit 934606f

File tree

1 file changed

+91
-93
lines changed

1 file changed

+91
-93
lines changed

.github/workflows/validate.yml

Lines changed: 91 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Validate Attack Data
22

33
on:
44
pull_request:
5-
branches: [ master, main ]
5+
branches: [master, main]
66
types: [opened, synchronize, reopened]
77
paths:
88
- 'datasets/**/*.yml'
@@ -11,7 +11,7 @@ on:
1111
- 'bin/dataset_schema.json'
1212
- 'bin/requirements.txt'
1313
push:
14-
branches: [ master, main ]
14+
branches: [master, main]
1515
paths:
1616
- 'datasets/**/*.yml'
1717
- 'datasets/**/*.yaml'
@@ -27,97 +27,95 @@ permissions:
2727
jobs:
2828
validate-attack-data:
2929
runs-on: ubuntu-latest
30-
30+
3131
steps:
32-
- name: Checkout repository
33-
uses: actions/checkout@v4
34-
with:
35-
lfs: true
36-
37-
- name: Set up Python
38-
uses: actions/setup-python@v4
39-
with:
40-
python-version: '3.9'
41-
cache: 'pip'
42-
43-
- name: Install dependencies
44-
run: |
45-
python -m pip install --upgrade pip
46-
pip install -r bin/requirements.txt
47-
48-
# Validate all YAML files
49-
- name: Validate all YAML files
50-
run: |
51-
python bin/validate.py
52-
env:
53-
PYTHONPATH: ${{ github.workspace }}/bin
54-
55-
# PR-specific success/failure handling
56-
- name: Comment PR on validation failure
57-
if: failure() && github.event_name == 'pull_request'
58-
uses: actions/github-script@v7
59-
with:
60-
script: |
61-
const { owner, repo, number } = context.issue;
62-
63-
const body = `❌ **Attack Data Validation Failed**
64-
65-
The YAML files in this PR do not pass validation. Please check the workflow logs for detailed error messages and fix the issues before merging.
66-
67-
[View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})`;
68-
69-
await github.rest.issues.createComment({
70-
owner,
71-
repo,
72-
issue_number: number,
73-
body: body
74-
});
75-
76-
- name: Comment PR on validation success
77-
if: success() && github.event_name == 'pull_request'
78-
uses: actions/github-script@v7
79-
with:
80-
script: |
81-
const { owner, repo, number } = context.issue;
82-
83-
const body = `✅ **Attack Data Validation Passed**
84-
85-
All YAML files in this PR have been successfully validated against the schema.
86-
87-
Ready for review and merge! 🚀`;
88-
89-
await github.rest.issues.createComment({
90-
owner,
91-
repo,
92-
issue_number: number,
93-
body: body
94-
});
95-
96-
# Push-specific failure handling (create issue)
97-
- name: Create issue on validation failure (Push)
98-
if: failure() && github.event_name == 'push'
99-
uses: actions/github-script@v7
100-
with:
101-
script: |
102-
const title = `🚨 Attack Data Validation Failed - ${new Date().toISOString().split('T')[0]}`;
103-
const body = `**Validation failed on push to ${context.ref}**
104-
105-
Commit: ${context.sha}
106-
107-
The YAML files in the datasets directory do not pass validation. This indicates that invalid data has been merged into the main branch.
108-
109-
**Action Required:**
110-
1. Review the [failed workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
111-
2. Fix the validation errors
112-
3. Create a hotfix PR to resolve the issues
113-
`;
114-
115-
await github.rest.issues.create({
116-
owner: context.repo.owner,
117-
repo: context.repo.repo,
118-
title: title,
119-
body: body,
120-
labels: ['bug', 'validation-failure', 'high-priority']
121-
});
32+
- name: Checkout repository
33+
uses: actions/checkout@v4
34+
with:
35+
lfs: false
36+
37+
- name: Set up Python
38+
uses: actions/setup-python@v4
39+
with:
40+
python-version: '3.9'
41+
cache: 'pip'
42+
43+
- name: Install dependencies
44+
run: |
45+
python -m pip install --upgrade pip
46+
pip install -r bin/requirements.txt
47+
48+
# Validate all YAML files
49+
- name: Validate all YAML files
50+
run: |
51+
python bin/validate.py
52+
env:
53+
PYTHONPATH: ${{ github.workspace }}/bin
54+
55+
# PR-specific success/failure handling
56+
- name: Comment PR on validation failure
57+
if: failure() && github.event_name == 'pull_request'
58+
uses: actions/github-script@v7
59+
with:
60+
script: |
61+
const { owner, repo, number } = context.issue;
62+
63+
const body = `❌ **Attack Data Validation Failed**
64+
65+
The YAML files in this PR do not pass validation. Please check the workflow logs for detailed error messages and fix the issues before merging.
66+
67+
[View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})`;
68+
69+
await github.rest.issues.createComment({
70+
owner,
71+
repo,
72+
issue_number: number,
73+
body: body
74+
});
75+
76+
- name: Comment PR on validation success
77+
if: success() && github.event_name == 'pull_request'
78+
uses: actions/github-script@v7
79+
with:
80+
script: |
81+
const { owner, repo, number } = context.issue;
82+
83+
const body = `✅ **Attack Data Validation Passed**
84+
85+
All YAML files in this PR have been successfully validated against the schema.
86+
87+
Ready for review and merge! 🚀`;
88+
89+
await github.rest.issues.createComment({
90+
owner,
91+
repo,
92+
issue_number: number,
93+
body: body
94+
});
95+
96+
# Push-specific failure handling (create issue)
97+
- name: Create issue on validation failure (Push)
98+
if: failure() && github.event_name == 'push'
99+
uses: actions/github-script@v7
100+
with:
101+
script: |
102+
const title = `🚨 Attack Data Validation Failed - ${new Date().toISOString().split('T')[0]}`;
103+
const body = `**Validation failed on push to ${context.ref}**
104+
105+
Commit: ${context.sha}
106+
107+
The YAML files in the datasets directory do not pass validation. This indicates that invalid data has been merged into the main branch.
122108
109+
**Action Required:**
110+
1. Review the [failed workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
111+
2. Fix the validation errors
112+
3. Create a hotfix PR to resolve the issues
113+
`;
123114
115+
await github.rest.issues.create({
116+
owner: context.repo.owner,
117+
repo: context.repo.repo,
118+
title: title,
119+
body: body,
120+
labels: ['bug', 'validation-failure', 'high-priority']
121+
});

0 commit comments

Comments
 (0)