-
Notifications
You must be signed in to change notification settings - Fork 10
104 lines (90 loc) · 3.17 KB
/
Copy pathchangelog-validation.yml
File metadata and controls
104 lines (90 loc) · 3.17 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
name: Changelog Validation
on:
pull_request:
paths:
- 'CHANGELOG.md'
- '.git-changelog.toml'
- '.changelog-template.md'
- 'dev-tools/release/changelog_manager.py'
- '.github/workflows/changelog-validation.yml'
workflow_dispatch:
jobs:
config:
name: Get Configuration
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
outputs:
default-python-version: ${{ steps.config.outputs.default-python-version }}
steps:
- name: Checkout code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Get project configuration
id: config
uses: ./.github/actions/get-config
setup-cache:
name: Setup Cache
needs: config
uses: ./.github/workflows/cache-management.yml
with:
cache-type: dependencies
cache-key-base: changelog-validation
python-version: ${{ needs.config.outputs.default-python-version }}
validate-changelog:
name: Validate Changelog Format
runs-on: ubuntu-latest
timeout-minutes: 20
needs: [config, setup-cache]
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0 # Need full history for changelog generation
- name: Setup Python and UV
uses: ./.github/actions/setup-uv-cached
with:
cache-key: ${{ needs.setup-cache.outputs.cache-key }}
fail-on-cache-miss: false
- name: Install changelog dependencies
run: |
uv pip install git-changelog
- name: Validate changelog format
run: |
make changelog-validate
- name: Check changelog is up to date
if: github.event_name == 'pull_request'
run: |
echo "Checking if changelog needs updates..."
# Get base branch
BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.sha }}"
# Check if there are commits that should be in changelog
COMMIT_COUNT=$(git rev-list --count "${BASE_SHA}..${HEAD_SHA}")
if [ "$COMMIT_COUNT" -gt 0 ]; then
echo "Found $COMMIT_COUNT new commits"
# Check if changelog was modified
if git diff --name-only "${BASE_SHA}..${HEAD_SHA}" | grep -q "CHANGELOG.md"; then
echo "Changelog was updated"
else
echo "WARNING: New commits found but changelog not updated"
echo "Consider running: make changelog-preview"
# Don't fail - just warn
fi
else
echo "No new commits to check"
fi
- name: Preview changelog changes
if: github.event_name == 'pull_request'
run: |
{
echo "## Changelog Preview"
echo ""
echo "Changes that would be added to changelog:"
echo ""
echo '```markdown'
} >> "$GITHUB_STEP_SUMMARY"
make changelog-preview FROM_COMMIT="${{ github.event.pull_request.base.sha }}" >> "$GITHUB_STEP_SUMMARY" || echo "No changes to preview" >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"