Chore refactor ep20 #1453
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: codegen diff preview | |
# This job will generate a codegen output diff comparing the target base ref with current HEAD ref and push it to S3 | |
# and comment on GitHub PR with a link to the HTML output. | |
on: | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
permissions: | |
id-token: write | |
contents: read | |
pull-requests: write | |
# Allow one instance of this workflow per pull request, and cancel older runs when new changes are pushed | |
concurrency: | |
group: ci-codegen-diff-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
JAVA_VERSION: 11 | |
BUILDER_VERSION: v0.8.22 | |
BUILDER_SOURCE: releases | |
BUILDER_HOST: https://d19elf31gohf1l.cloudfront.net | |
PACKAGE_NAME: aws-sdk-kotlin | |
RUN: ${{ github.run_id }}-${{ github.run_number }} | |
DIFF2HTML_VERSION: 5.2.5 | |
# Below is the set of services that are generated for codegen preview | |
# These are carefully selected to exercise every Smithy protocol. | |
# - @awsJson1_0: dynamodb | |
# - @awsJson1_1: codebuild | |
# - @awsQuery: sts | |
# - @ec2Query: ec2 | |
# - @restJson1: polly | |
# - @restXml: s3 | |
PREVIEW_SERVICES: +dynamodb,+codebuild,+sts,+ec2,+polly,+s3 | |
jobs: | |
generate-codegen-diff: | |
runs-on: ubuntu-latest | |
name: Generate diff and upload to S3 | |
outputs: | |
bot-message: ${{ steps.generate-diff.outputs.codegen-diff-msg }} | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- uses: actions/cache@v2 | |
name: Gradle Cache | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Set up JDK | |
uses: actions/setup-java@v1 | |
with: | |
java-version: ${{ env.JAVA_VERSION }} | |
- name: Install and build deps | |
# abuse crt builder to download and build upstream dependencies like smithy-kotlin | |
run: | | |
npm install -g diff2html-cli@${{ env.DIFF2HTML_VERSION }} | |
python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" | |
chmod a+x builder.pyz | |
./builder.pyz build -p ${{ env.PACKAGE_NAME }} --variant codegen-preview | |
- name: Generate diff | |
id: generate-diff | |
run: | | |
# codegen-diff-revisions requires a clean index, set-upstream-versions.py can modify local repo state | |
# we don't push these branches/commits anywhere so just commit it if necessary and move on | |
if ! git diff --quiet gradle.properties | |
then | |
echo "gradle.properties is dirty, committing before generating diffs" | |
git add gradle.properties | |
PRE_COMMIT_ALLOW_NO_CONFIG=1 git \ | |
-c "user.name=GitHub Action (generated code preview)" \ | |
-c "[email protected]" \ | |
commit -m "codegen diff autocommit" --allow-empty | |
fi | |
.github/scripts/codegen-diff-revisions.py \ | |
--bootstrap ${{ env.PREVIEW_SERVICES }} \ | |
--head-sha ${{ github.event.pull_request.head.sha }} \ | |
. ${{ github.event.pull_request.base.sha }} | |
echo "codegen-diff-msg<<EOF" >> $GITHUB_OUTPUT | |
cat ./tmp-codegen-diff/bot-message) >> $GITHUB_OUTPUT | |
echo "EOF" >> $GITHUB_OUTPUT | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }} | |
aws-region: us-west-2 | |
- name: Upload diff to S3 | |
run: | | |
if [[ -d ./tmp-codegen-diff/${{ github.event.pull_request.base.sha }} ]]; then | |
aws s3 cp ./tmp-codegen-diff/${{ github.event.pull_request.base.sha }} \ | |
"s3://${{ secrets.CDN_S3_BUCKET_NAME }}/codegen-diff/${{ github.event.pull_request.base.sha }}" --recursive | |
fi | |
# TODO - generate doc preview for N services and upload and link as well | |
post-bot-comment: | |
name: Post bot comment | |
runs-on: ubuntu-latest | |
needs: | |
- generate-codegen-diff | |
steps: | |
- name: Post bot comment | |
uses: actions/github-script@v5 | |
with: | |
script: | | |
await github.rest.issues.createComment({ | |
issue_number: ${{ github.event.number }}, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: '${{ needs.generate-codegen-diff.outputs.bot-message }}\n\n' | |
}) |