diff --git a/.github/workflows/ci_test_java.yml b/.github/workflows/ci_test_java.yml index e48506bdc..ba04cba39 100644 --- a/.github/workflows/ci_test_java.yml +++ b/.github/workflows/ci_test_java.yml @@ -45,6 +45,7 @@ jobs: - uses: actions/checkout@v5 with: + ref: benchmark submodules: recursive - name: Setup Dafny diff --git a/.github/workflows/performance-benchmarks-go.yml b/.github/workflows/performance-benchmarks-go.yml new file mode 100644 index 000000000..d56f7e8a5 --- /dev/null +++ b/.github/workflows/performance-benchmarks-go.yml @@ -0,0 +1,139 @@ +# This workflow performs benchmark testing in Go. +name: Performance Benchmarks Go + +on: + workflow_call: + inputs: + dafny: + description: "The Dafny version to run" + required: true + type: string + regenerate-code: + description: "Regenerate code using smithy-dafny" + required: false + default: false + type: boolean + mpl-version: + description: "MPL version to use" + required: false + type: string + mpl-head: + description: "Running on MPL HEAD" + required: false + default: false + type: boolean +jobs: + testGo: + strategy: + fail-fast: false + matrix: + library: [DynamoDbEncryption] + benchmark-dir: [db-esdk-performance-testing/benchmarks] + os: [ubuntu-22.04, macos-15-intel] + go-version: ["1.23", "1.24", "1.25"] + runs-on: ${{ matrix.os }} + permissions: + id-token: write + contents: read + steps: + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v5 + with: + aws-region: us-west-2 + role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-DDBEC-Dafny-Role-us-west-2 + role-session-name: DDBEC-Performance-Benchmarks-Go + + - name: Support longpaths + run: | + git config --global core.longpaths true + + - uses: actions/checkout@v5 + with: + ref: benchmark + submodules: recursive + - name: Init Submodules + shell: bash + run: | + git submodule update --init --recursive submodules/smithy-dafny + git submodule update --init --recursive submodules/MaterialProviders + + - name: Create temporary global.json + run: echo '{"sdk":{"rollForward":"latestFeature","version":"6.0.0"}}' > ./global.json + + - name: Setup Java 17 for codegen + uses: actions/setup-java@v5 + with: + distribution: "corretto" + java-version: "17" + + - name: Update MPL submodule if using MPL HEAD + if: ${{ inputs.mpl-head == true }} + working-directory: submodules/MaterialProviders + run: | + git checkout main + git pull + git submodule update --init --recursive + git rev-parse HEAD + + - name: Update project.properties if using MPL HEAD + if: ${{ inputs.mpl-head == true }} + run: | + sed "s/mplDependencyJavaVersion=.*/mplDependencyJavaVersion=${{inputs.mpl-version}}/g" project.properties > project.properties2; mv project.properties2 project.properties + + - name: Install Go + uses: actions/setup-go@v6 + with: + go-version: ${{ matrix.go-version }} + + - name: Setup Dafny + uses: dafny-lang/setup-dafny-action@v1.8.0 + with: + dafny-version: ${{ inputs.dafny }} + + - name: Install Smithy-Dafny codegen dependencies + uses: ./.github/actions/install_smithy_dafny_codegen_dependencies + + - name: Build ${{ matrix.library }} implementation + shell: bash + working-directory: ./ + run: | + ls + + - name: Build ${{ matrix.library }} implementation + shell: bash + working-directory: ./${{ matrix.library }} + run: | + # This works because `node` is installed by default on GHA runners + CORES=$(node -e 'console.log(os.cpus().length)') + make transpile_go CORES=$CORES + + - name: Run Performance Benchmarks - Quick Mode + shell: bash + working-directory: ./${{matrix.benchmark-dir}}/go + run: | + go run . --config ../../config/test-scenarios.yaml --quick + + - name: Parse and Format Logs + working-directory: ./${{matrix.benchmark-dir}}/results/raw-data/ + run: | + LOG_FILE="go_results.json" + UPLOAD_FILE="cloudwatch_logs.json" + TIMESTAMP=$(date +%s%3N) + jq -c --arg ts "$(date +%s)000" '.results[] as $result | .metadata as $meta | {timestamp: ($ts | tonumber), message: ({metadata: $meta, result: $result} | tostring)}' $LOG_FILE > $UPLOAD_FILE + + - name: Upload logs to CloudWatch + working-directory: ./${{matrix.benchmark-dir}}/results/raw-data/ + run: | + LOG_FILE="cloudwatch_logs.json" + LOG_GROUP="aws-dbesdk-performance-benchmarks" + LOG_STREAM="go/quick_benchmarks/${{ github.workflow }}/${{ github.run_id }}" + + # Create log stream (ignore if exists) + aws logs create-log-stream \ + --log-group-name "$LOG_GROUP" \ + --log-stream-name "$LOG_STREAM" 2>/dev/null || true + + aws logs put-log-events \ + --log-group-name "$LOG_GROUP" \ + --log-stream-name "$LOG_STREAM" \ + --log-events file://$LOG_FILE \ No newline at end of file diff --git a/.github/workflows/performance-benchmarks.yml b/.github/workflows/performance-benchmarks.yml new file mode 100644 index 000000000..157ad1d9e --- /dev/null +++ b/.github/workflows/performance-benchmarks.yml @@ -0,0 +1,32 @@ +# This workflow runs every day 09:00 UTC (1AM PST) +name: Performance Benchmarks + +on: + pull_request: + paths: + - ".github/workflows/performance-benchmarks.yml" + schedule: + - cron: "00 09 * * *" + +jobs: + getVersion: + # Don't run the cron builds on forks + if: github.event_name != 'schedule' || github.repository_owner == 'aws' + uses: ./.github/workflows/dafny_version.yml + performance-benchmarks-go: + needs: getVersion + uses: ./.github/workflows/performance-benchmarks-go.yml + with: + dafny: ${{needs.getVersion.outputs.version}} + notify: + needs: + [ + getVersion, + performance-benchmarks-go + ] + if: ${{ failure() }} + uses: aws/aws-cryptographic-material-providers-library/.github/workflows/slack-notification.yml@main + with: + message: "Performance Benchmarks failed on `${{ github.repository }}`. View run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_CI }}