-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (113 loc) · 4.63 KB
/
validate.yml
File metadata and controls
128 lines (113 loc) · 4.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: Validate detections
# Two jobs, one workflow:
#
# * validate — the load-bearing PR gate. Runs lint --strict (with
# live pre-PR schema refresh), plan, deps check, version-bump
# check, and references URL check on every PR touching detections.
#
# * lint-regression — catches lint regressions outside of PR flow:
# push to main (force-push / admin merge bypass), nightly cron
# (a tightened rule may flag previously-clean detections), and
# manual dispatch with --fail-on-warn for ad-hoc audits.
#
# Formerly two separate workflows (validate.yml + lint.yml). Merged
# because both build the same .NET/KQL strict-lint wrapper; the
# shared composite action (.github/actions/lint-strict) eliminates
# the duplication.
on:
pull_request:
paths:
- 'detections/**'
- 'contentops/**'
- 'config/**'
- '.github/workflows/validate.yml'
push:
branches: [main]
paths:
- 'detections/**'
schedule:
- cron: '0 8 * * *'
workflow_dispatch:
inputs:
fail_on_warn:
description: "Fail on warnings (manual dispatch only)."
required: false
default: false
type: boolean
permissions:
contents: read
# OIDC token exchange for the optional pre-PR schema refresh step
# in the validate job; the federated credential is gated on the
# `automation` environment so fork PRs fail-soft (continue-on-error
# + the CLI itself falls back to baseline on auth failure).
id-token: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# ── PR gate ──────────────────────────────────────────────────────
validate:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 15
environment: automation
env:
AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
PIPELINE_WORKSPACE_ID: ${{ vars.PIPELINE_WORKSPACE_ID }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
# check_version_bump.py needs the merge-base to diff against.
fetch-depth: 0
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: "3.12"
cache: pip
- name: Install dependencies
run: pip install -r requirements.txt && pip install -e .
# --- Kusto.Language strict-lint wrapper (G1) ----------------------
# Composite action: .NET 8 SDK, NuGet cache, kql_strict.dll build,
# optional pre-PR schema refresh, then contentops lint --strict.
# See .github/actions/lint-strict/action.yml.
- name: Lint strict (build + schema refresh + lint)
uses: ./.github/actions/lint-strict
with:
path: detections
pre-pr-refresh: 'true'
- name: contentops plan (dependency check enforced)
# The plan step blocks merge on dependency-graph violations.
# No --skip-deps-check here on purpose — that's the gate.
run: contentops plan --path detections/
- name: version-bump check
run: |
python scripts/check_version_bump.py "origin/${{ github.base_ref }}"
- name: References URL check (added URLs only)
# PR-time fast path: HEAD-checks ONLY URLs newly introduced by
# this PR's diff. The full corpus is HEAD-checked weekly by
# `references-check.yml`. Without this PR-time check a dead
# link sails through review and only fails the next Saturday.
# Fork PRs hit the same path (no OIDC needed — outbound HTTP only).
run: |
set -euo pipefail
python scripts/check_references.py \
--diff-base "origin/${{ github.base_ref }}" \
--format text
# ── Post-merge / nightly / manual ────────────────────────────────
lint-regression:
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: "3.12"
cache: pip
- name: Install dependencies
run: pip install -r requirements.txt && pip install -e .
- name: Lint strict (build + lint)
uses: ./.github/actions/lint-strict
with:
path: detections
fail-on-warn: ${{ inputs.fail_on_warn == true && 'true' || 'false' }}