Skip to content

Commit

Permalink
chore: include basic changelog in service spec database upgrade PRs (#…
Browse files Browse the repository at this point in the history
…28324)

Currently it's very difficult to figure out which PR introduced a specific change to the model.

Ideally the changelog would be in a nice narrative form suitable for humans, but in lack of a tool that produces this, the "raw" database diff is better than nothing.

Test-run:
https://github.com/aws/aws-cdk/actions/runs/7168292995
#28326

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
mrgrain authored Dec 11, 2023
1 parent 4c56390 commit 2d17b97
Showing 1 changed file with 70 additions and 4 deletions.
74 changes: 70 additions & 4 deletions .github/workflows/spec-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,19 @@ jobs:
env:
NODE_OPTIONS: "--max-old-space-size=8196 --experimental-worker ${NODE_OPTIONS:-}"

# Install all current dependencies
- name: Yarn Install
run: yarn install --frozen-lockfile

# Upload the current db to be used later
- name: Upload base database
uses: actions/upload-artifact@v3
with:
name: db.base.json.gz
path: node_modules/@aws-cdk/aws-service-spec/db.json.gz
if-no-files-found: error

# Perform the actual upgrade of the relevant packages
- name: Install ncu tool
run: npm -g install lerna npm-check-updates
- name: Run "ncu" for service spec packages
Expand All @@ -36,6 +47,14 @@ jobs:
- name: Install latest version & update lockfile
run: yarn upgrade @aws-cdk/aws-service-spec @aws-cdk/service-spec-importers @aws-cdk/service-spec-types

# Now that we have updated the database, upload the new candidate db
- name: Upload head database
uses: actions/upload-artifact@v3
with:
name: db.head.json.gz
path: node_modules/@aws-cdk/aws-service-spec/db.json.gz
if-no-files-found: error

# Build @aws-cdk/spec2cdk and run L1 gen script to generate base files for new modules
- name: Build @aws-cdk/spec2cdk
run: lerna run build --stream --no-progress --skip-nx-cache --scope @aws-cdk/spec2cdk
Expand All @@ -55,9 +74,51 @@ jobs:
name: update-spec.patch
path: ${{ runner.temp }}/update-spec.patch

diff-db:
needs: update-spec
runs-on: ubuntu-latest
permissions:
contents: write
id-token: none
pull-requests: write
env:
CI: "true"
steps:
- name: Download base database
uses: actions/download-artifact@v3
with:
name: db.base.json.gz
path: base
- name: Download head database
uses: actions/download-artifact@v3
with:
name: db.head.json.gz
path: head
- name: Diff databases
id: diff-db
run: npx --yes --package=@aws-cdk/service-spec-importers@latest -c 'diff-db base/db.json.gz head/db.json.gz' > DIFF || echo "diff-result=true" >> $GITHUB_OUTPUT
continue-on-error: true
- name: Create PR body file
run: |-
echo 'Update AWS Service Spec packages to latest versions' >> PR.md
- name: Add model changelog to PR body file
if: steps.diff-db.outputs.diff-result
run: |-
echo '' >> PR.md
echo '**@aws-cdk/aws-service-spec changes:**' >> PR.md
echo '```' >> PR.md
cat DIFF >> PR.md
echo '```' >> PR.md
- name: Upload PR body file
uses: actions/upload-artifact@v3
with:
name: PR.md
path: PR.md
pr:
name: Create Pull Request
needs: update-spec
needs:
- update-spec
- diff-db
permissions:
contents: write
pull-requests: write
Expand All @@ -75,6 +136,12 @@ jobs:
- name: Apply patch
run: '[ -s ${{ runner.temp }}/update-spec.patch ] && git apply ${{ runner.temp }}/update-spec.patch || echo "Empty patch. Skipping."'

- name: Download PR body file
uses: actions/download-artifact@v3
with:
name: PR.md
path: ${{ runner.temp }}

- name: Make Pull Request
uses: peter-evans/create-pull-request@v5
with:
Expand All @@ -83,11 +150,10 @@ jobs:
author: aws-cdk-automation <aws-cdk-automation@users.noreply.github.com>
commit-message: |-
feat: update AWS Service Spec
AWS Service Spec packages to latest versions.
Update AWS Service Spec packages to latest versions
# Pull Request details
title: "feat: update AWS Service Spec"
body: |-
AWS Service Spec packages to latest versions.
body-path: ${{ runner.temp }}/PR.md
labels: contribution/core,dependencies,auto-approve,pr-linter/exempt-integ-test,pr-linter/exempt-readme,pr-linter/exempt-test
team-reviewers: aws-cdk-team
# Github prevents further Github actions to be run if the default Github token is used.
Expand Down

0 comments on commit 2d17b97

Please sign in to comment.