-
Notifications
You must be signed in to change notification settings - Fork 7
101 lines (87 loc) · 3.28 KB
/
Copy pathtest-playbooks.yml
File metadata and controls
101 lines (87 loc) · 3.28 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
name: Test Playbooks
on:
workflow_dispatch:
inputs:
playbook_id:
description: 'Specific playbook ID to test (leave empty to test all changed playbooks)'
required: false
type: string
pull_request:
paths:
- 'playbooks/**'
jobs:
detect-changes:
name: Detect Changed Playbooks
runs-on: ubuntu-latest
outputs:
playbooks: ${{ steps.detect.outputs.playbooks }}
has_playbooks: ${{ steps.detect.outputs.has_playbooks }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect changed playbooks
id: detect
run: |
if [ -n "${{ github.event.inputs.playbook_id }}" ]; then
# Manual trigger with specific playbook
echo "playbooks=[\"${{ github.event.inputs.playbook_id }}\"]" >> $GITHUB_OUTPUT
echo "has_playbooks=true" >> $GITHUB_OUTPUT
else
# Detect changed playbooks from PR
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} -- 'playbooks/core/*' 'playbooks/supplemental/*' 2>/dev/null || echo "")
# Extract unique playbook IDs
PLAYBOOK_IDS=$(echo "$CHANGED_FILES" | grep -E '^playbooks/(core|supplemental)/[^/]+/' | sed 's|playbooks/[^/]*/\([^/]*\)/.*|\1|' | sort -u | jq -R -s -c 'split("\n") | map(select(length > 0))')
if [ "$PLAYBOOK_IDS" = "[]" ] || [ -z "$PLAYBOOK_IDS" ]; then
echo "playbooks=[]" >> $GITHUB_OUTPUT
echo "has_playbooks=false" >> $GITHUB_OUTPUT
else
echo "playbooks=$PLAYBOOK_IDS" >> $GITHUB_OUTPUT
echo "has_playbooks=true" >> $GITHUB_OUTPUT
fi
fi
- name: Display detected playbooks
run: |
echo "Playbooks to test: ${{ steps.detect.outputs.playbooks }}"
test-playbooks-windows:
name: Test Playbooks (Windows)
needs: detect-changes
if: needs.detect-changes.outputs.has_playbooks == 'true'
runs-on: [self-hosted, Windows, halo]
strategy:
fail-fast: false
matrix:
playbook: ${{ fromJson(needs.detect-changes.outputs.playbooks) }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install test dependencies
run: |
python -m pip install --upgrade pip
pip install pyyaml
- name: Extract and run tests
id: run_tests
shell: powershell
run: |
python .github/scripts/run_playbook_tests.py --playbook "${{ matrix.playbook }}" --platform windows
- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.playbook }}-windows
path: test-results/
if-no-files-found: ignore
- name: Test Summary
if: always()
shell: powershell
run: |
$summary = @"
### Test Results for ``${{ matrix.playbook }}`` (Windows)
See the test artifacts for detailed logs.
"@
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value $summary