Unverified Commit fc6af207 authored by John DiSanti's avatar John DiSanti Committed by GitHub
Browse files

Combine PR bot messages into one (#1299)

parent 064467c9
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -79,12 +79,13 @@ jobs:
      matrix:
        # These correspond to scripts in tools/ci-build/scripts that will be run in the Docker build image
        test:
        - action: check-style-and-lints
        - action: check-client-codegen-integration-tests
        - action: check-client-codegen-unit-tests
        - action: check-sdk-codegen-unit-tests
        - action: check-server-codegen-integration-tests
        - action: check-server-codegen-unit-tests
        - action: check-server-e2e-test
        - action: check-style-and-lints
    steps:
    - uses: actions/checkout@v3
      with:
+101 −14
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@ concurrency:
env:
  java_version: 11
  rust_version: 1.56.1
  rust_toolchain_components: clippy,rustfmt
  apt_dependencies: libssl-dev gnuplot jq

jobs:
  generate-diff:
@@ -27,6 +29,8 @@ jobs:
      id-token: write
      contents: read
      pull-requests: write
    outputs:
      bot-message: ${{ steps.generate-diff.outputs.bot-message }}
    steps:
    - uses: actions/checkout@v2
    - uses: actions/cache@v2
@@ -67,17 +71,6 @@ jobs:
            aws s3 cp tmp-codegen-diff/${{ github.event.pull_request.base.sha }} \
                "s3://${S3_BUCKET_NAME}/codegen-diff/${{ github.event.pull_request.base.sha }}" --recursive
        fi
    - uses: actions/github-script@v5
      # NOTE: if comments on each commit become bothersome, add a check that github.event.pull_request.action == "opened"
      if: ${{ github.head_ref != null }}
      with:
        script: |
          await github.rest.issues.createComment({
            issue_number: context.issue.number,
            owner: context.repo.owner,
            repo: context.repo.repo,
            body: '${{ steps.generate-diff.outputs.bot-message }}'
          })

  generate-doc-preview:
    runs-on: ubuntu-latest
@@ -89,6 +82,8 @@ jobs:
      id-token: write
      contents: read
      pull-requests: write
    outputs:
      bot-message: ${{ steps.generate-preview.outputs.bot-message }}
    steps:
    - uses: actions/checkout@v2
    - uses: actions/cache@v2
@@ -110,6 +105,7 @@ jobs:
        toolchain: ${{ env.rust_version }}
        default: true
    - name: Generate doc preview
      id: generate-preview
      # Only generate three of the smallest services since the doc build can be very large. STS and SSO must be
      # included since aws-config depends on them. Transcribe Streaming and DynamoDB (paginators/waiters) were chosen
      # below to stay small while still representing most features. Combined, they are about ~20MB at time of writing.
@@ -130,6 +126,8 @@ jobs:
        cargo doc --no-deps --all-features
        popd
        ./tools/generate-doc-preview-index.sh ${{ github.event.pull_request.base.sha }}

        echo '::set-output name=bot-message::A [new doc preview](https://d2luzm2xt3nokh.cloudfront.net/docs/'${{ github.event.pull_request.head.sha }}'/index.html) is ready to view.'
    - uses: aws-actions/configure-aws-credentials@v1
      name: Acquire credentials for uploading to S3
      with:
@@ -139,8 +137,95 @@ jobs:
    - name: Upload doc preview to S3
      run: |
        aws s3 cp target/doc "s3://${S3_BUCKET_NAME}/docs/${{ github.event.pull_request.head.sha }}" --recursive
    - uses: actions/github-script@v5
      # NOTE: if comments on each commit become bothersome, add a check that github.event.pull_request.action == "opened"

  generate-server-benchmark:
    name: Generate server benchmark
    runs-on: ubuntu-latest
    outputs:
      bot-message: ${{ steps.run-benchmark.outputs.bot-message }}
    steps:
    - name: Checkout PR
      uses: actions/checkout@v3
      with:
        path: pull-request
    - name: Checkout origin/main
      uses: actions/checkout@v3
      with:
        repository: awslabs/smithy-rs
        path: origin-main
        ref: main
    - name: Checkout wrk
      uses: actions/checkout@v3
      with:
        repository: wg/wrk
        path: wrk-build
        ref: 4.2.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-
        # Pinned to the commit hash of v1.3.0
    - name: Rust Cache
      uses: Swatinem/rust-cache@842ef286fff290e445b90b4002cc9807c3669641
      with:
        sharedKey: ${{ runner.os }}-${{ env.rust_version }}-${{ github.job }}
        target-dir: ./target
    - name: Set up JDK
      uses: actions/setup-java@v1
      with:
        java-version: ${{ env.java_version }}
    - name: Install Rust
      uses: actions-rs/toolchain@v1
      with:
        toolchain: ${{ env.rust_version }}
        components: ${{ env.rust_toolchain_components }}
        default: true
    - name: Install benchmarks dependencies
      run: sudo apt-get update && sudo apt-get install -y ${{ env.apt_dependencies }}
      # Ubuntu 20.04 doesn't have wrk packaged, hence we need to build it 🤦
      # This will go away as soon as GitHub supports Ubuntu 21.10.
    - name: Install wrk
      run: cd wrk-build && make -j8 wrk && sudo cp wrk /usr/local/bin
    - name: Run benchmark
      id: run-benchmark
      run: |
        mkdir -p ~/.wrk-api-bench
        # run the benchmark on origin/main
        pushd origin-main/rust-runtime/aws-smithy-http-server/examples
        make && RUN_BENCHMARKS=1 cargo test --release
        popd

        # run the benchmark on current ref
        pushd pull-request/rust-runtime/aws-smithy-http-server/examples
        make && RUN_BENCHMARKS=1 cargo test --release
        popd
        # Uncomment this for debugging purposes. It will print out the
        # content of all the benchmarks found in the cache + the last one
        # produced by the current run.
        # for x in ~/.wrk-api-bench/*; do echo "Benchmark $x content:"; jq . "$x"; echo; done

        # Ensure the output is available for the PR bot.
        echo "::set-output name=bot-message::$(cat /tmp/smithy_rs_benchmark_deviation.txt)"

  post-bot-comment:
    needs:
    - generate-diff
    - generate-doc-preview
    - generate-server-benchmark
    runs-on: ubuntu-latest
    name: Post bot comment
    permissions:
      id-token: write
      contents: read
      pull-requests: write
    steps:
    - name: Post bot comment
      uses: actions/github-script@v5
      if: ${{ github.head_ref != null }}
      with:
        script: |
@@ -148,5 +233,7 @@ jobs:
            issue_number: context.issue.number,
            owner: context.repo.owner,
            repo: context.repo.repo,
            body: 'A [new doc preview](https://d2luzm2xt3nokh.cloudfront.net/docs/${{ github.event.pull_request.head.sha }}/index.html) is ready to view.'
            body: '${{ needs.generate-diff.outputs.bot-message }}\n\n' +
              '${{ needs.generate-doc-preview.outputs.bot-message }}\n\n' +
              '${{ needs.generate-server-benchmark.outputs.bot-message }}\n\n'
          })
+0 −136
Original line number Diff line number Diff line
name: Server SDK tests and benchmarks
# This job will run the server SDK integration tests amd benchmarks using the Pokémon service model.
on:
  pull_request:
    types:
    - opened
    - reopened
    - synchronize

# Allow one instance of this workflow per pull request, and cancel older runs when new changes are pushed
concurrency:
  group: server-benchmark-yml-${{ github.ref }}
  cancel-in-progress: true

env:
  java_version: 11
  rust_version: 1.56.1
  rust_toolchain_components: clippy,rustfmt
  apt_dependencies: libssl-dev gnuplot jq

jobs:
  run-e2e-integration-test:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - uses: actions/cache@v2
      name: Gradle Cache
      with:
        path: |
          ~/.gradle/caches
          ~/.gradle/wrapper
        key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
        restore-keys: |
          ${{ runner.os }}-gradle-
      # Pinned to the commit hash of v1.3.0
    - uses: Swatinem/rust-cache@842ef286fff290e445b90b4002cc9807c3669641
      with:
        sharedKey: ${{ runner.os }}-${{ env.rust_version }}-${{ github.job }}
        target-dir: ./target
    - name: Set up JDK
      uses: actions/setup-java@v1
      with:
        java-version: ${{ env.java_version }}
    - name: Install Rust
      uses: actions-rs/toolchain@v1
      with:
        toolchain: ${{ env.rust_version }}
        components: ${{ env.rust_toolchain_components }}
        default: true
    - name: Run integration tests
      run: |
        cd rust-runtime/aws-smithy-http-server/examples && \
          make && cargo test

  run-benchmark:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout PR
      uses: actions/checkout@v3
      with:
        path: pull-request
    - name: Checkout origin/main
      uses: actions/checkout@v3
      with:
        repository: awslabs/smithy-rs
        path: origin-main
        ref: main
    - name: Checkout wrk
      uses: actions/checkout@v3
      with:
        repository: wg/wrk
        path: wrk-build
        ref: 4.2.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-
      # Pinned to the commit hash of v1.3.0
    - name: Rust Cache
      uses: Swatinem/rust-cache@842ef286fff290e445b90b4002cc9807c3669641
      with:
        sharedKey: ${{ runner.os }}-${{ env.rust_version }}-${{ github.job }}
        target-dir: ./target
    - name: Set up JDK
      uses: actions/setup-java@v1
      with:
        java-version: ${{ env.java_version }}
    - name: Install Rust
      uses: actions-rs/toolchain@v1
      with:
        toolchain: ${{ env.rust_version }}
        components: ${{ env.rust_toolchain_components }}
        default: true
    - name: Install benchmarks dependencies
      run: sudo apt-get update && sudo apt-get install -y ${{ env.apt_dependencies }}
    # Ubuntu 20.04 doesn't have wrk packaged, hence we need to build it 🤦
    # This will go away as soon as GitHub supports Ubuntu 21.10.
    - name: Install wrk
      run: cd wrk-build && make -j8 wrk && sudo cp wrk /usr/local/bin
    - name: Run benchmark
      id: run-benchmark
      run: |
        mkdir -p ~/.wrk-api-bench
        # run the benchmark on origin/main
        pushd origin-main/rust-runtime/aws-smithy-http-server/examples
        make && RUN_BENCHMARKS=1 cargo test --release
        popd

        # run the benchmark on current ref
        pushd pull-request/rust-runtime/aws-smithy-http-server/examples
        make && RUN_BENCHMARKS=1 cargo test --release
        popd
        # Uncomment this for debugging purposes. It will print out the
        # content of all the benchmarks found in the cache + the last one
        # produced by the current run.
        # for x in ~/.wrk-api-bench/*; do echo "Benchmark $x content:"; jq . "$x"; echo; done

        # Ensure the output is available for the PR bot.
        echo "::set-output name=bot-message::$(cat /tmp/smithy_rs_benchmark_deviation.txt)"
    - name: Post deviation on PR
      uses: actions/github-script@v5
      # NOTE: if comments on each commit become bothersome, add a check that github.event.pull_request.action == "opened"
      if: ${{ github.head_ref != null }}
      with:
        script: |
          await github.rest.issues.createComment({
            issue_number: context.issue.number,
            owner: context.repo.owner,
            repo: context.repo.repo,
            body: '${{ steps.run-benchmark.outputs.bot-message }}'
          })
+2 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ pub(crate) struct PokemonService {
}

impl PokemonService {
    #[allow(dead_code)]
    pub(crate) fn run() -> Self {
        let process = Command::cargo_bin("pokemon_service").unwrap().spawn().unwrap();

@@ -27,6 +28,7 @@ impl Drop for PokemonService {
    }
}

#[allow(dead_code)]
pub fn client() -> Client<
    aws_smithy_client::erase::DynConnector,
    aws_smithy_client::erase::DynMiddleware<aws_smithy_client::erase::DynConnector>,
+1 −0
Original line number Diff line number Diff line
@@ -103,6 +103,7 @@ RUN set -eux; \
        gcc \
        git \
        java-11-amazon-corretto-headless \
        make \
        openssl-devel \
        pkgconfig \
        python3 \
Loading