|
| 1 | +name: API Changelog Check |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened, synchronize, reopened, labeled, unlabeled] |
| 6 | + paths: |
| 7 | + - 'codegen/aws-models/**' |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +jobs: |
| 13 | + check-changelog: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-changelog') }} |
| 16 | + steps: |
| 17 | + - name: Checkout repository |
| 18 | + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 |
| 19 | + with: |
| 20 | + fetch-depth: 0 |
| 21 | + |
| 22 | + - name: Get changed model files |
| 23 | + id: changed-models |
| 24 | + run: | |
| 25 | + changed_models=$(git diff --name-only origin/${{ github.base_ref }}...HEAD -- 'codegen/aws-models/*.json' | xargs -I {} basename {} .json) |
| 26 | + echo "models<<EOF" >> $GITHUB_OUTPUT |
| 27 | + echo "$changed_models" >> $GITHUB_OUTPUT |
| 28 | + echo "EOF" >> $GITHUB_OUTPUT |
| 29 | +
|
| 30 | + - name: Check for changelog entries |
| 31 | + run: | |
| 32 | + missing_changelogs="" |
| 33 | +
|
| 34 | + while IFS= read -r service; do |
| 35 | + [ -z "$service" ] && continue |
| 36 | +
|
| 37 | + changelog_dir="clients/aws-sdk-${service}/.changes/next-release" |
| 38 | +
|
| 39 | + if [ ! -d "$changelog_dir" ]; then |
| 40 | + missing_changelogs="${missing_changelogs}\n - ${service} (directory does not exist: ${changelog_dir})" |
| 41 | + continue |
| 42 | + fi |
| 43 | +
|
| 44 | + # Check for valid changelog JSON files with required fields |
| 45 | + valid_entry_found=false |
| 46 | + for file in "$changelog_dir"/*.json; do |
| 47 | + [ -e "$file" ] || continue |
| 48 | + if jq -e '.type and .description' "$file" > /dev/null 2>&1; then |
| 49 | + valid_entry_found=true |
| 50 | + break |
| 51 | + fi |
| 52 | + done |
| 53 | +
|
| 54 | + if [ "$valid_entry_found" = false ]; then |
| 55 | + missing_changelogs="${missing_changelogs}\n - ${service} (no valid changelog entry in ${changelog_dir})" |
| 56 | + fi |
| 57 | + done <<< "${{ steps.changed-models.outputs.models }}" |
| 58 | +
|
| 59 | + if [ -n "$missing_changelogs" ]; then |
| 60 | + printf "::error::Missing changelog entries for the following services:%b\n" "$missing_changelogs" |
| 61 | + echo "" |
| 62 | + echo "Please add a changelog entry in clients/aws-sdk-<service>/.changes/next-release/ for each modified model." |
| 63 | + echo "Entry must be a JSON file with 'type' and 'description' fields." |
| 64 | + exit 1 |
| 65 | + fi |
| 66 | +
|
| 67 | + echo "All modified models have corresponding changelog entries." |
0 commit comments