From ed871b6c37c23e371da2f07d736cb23150b8d8cf Mon Sep 17 00:00:00 2001 From: Michael Haken Date: Mon, 24 Feb 2025 14:53:38 -0500 Subject: [PATCH 1/8] updated onebox cw config --- cdk/Configs/cw-agent-onebox-config.json | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/cdk/Configs/cw-agent-onebox-config.json b/cdk/Configs/cw-agent-onebox-config.json index c1b74bc..f789885 100644 --- a/cdk/Configs/cw-agent-onebox-config.json +++ b/cdk/Configs/cw-agent-onebox-config.json @@ -37,7 +37,7 @@ }, "logs": { "metrics_collected": { - "emf": {} + "emf": {} }, "logs_collected": { "files": { @@ -45,29 +45,35 @@ { "file_path": "/var/log/cfn-init-cmd.log", "log_group_name": "cfn-init-cmd.log", - "log_stream_name": "${aws:InstanceId}", + "log_stream_name": "{instance_id}", "timestamp_format": "%H: %M: %S%y%b%-d" }, { "file_path": "/var/log/cfn-init.log", "log_group_name": "cfn-init.log", - "log_stream_name": "${aws:InstanceId}", + "log_stream_name": "{instance_id}", "timestamp_format": "%H: %M: %S%y%b%-d" }, { "file_path": "/var/log/cloud-init-output.log", "log_group_name": "cloud-init-output.log", - "log_stream_name": "${aws:InstanceId}", + "log_stream_name": "{instance_id}", "timestamp_format": "%H: %M: %S%y%b%-d" }, { "file_path": "/var/log/cloud-init.log", "log_group_name": "cloud-init.log", - "log_stream_name": "${aws:InstanceId}", + "log_stream_name": "{instance_id}", "timestamp_format": "%H: %M: %S%y%b%-d" } ] } } + }, + "traces": { + "traces_collected": { + "xray": {}, + "otlp": {} + } } } \ No newline at end of file From d1535129b5ed6cd8b43b0b69d0aa503d997dc0fc Mon Sep 17 00:00:00 2001 From: Michael Haken Date: Mon, 24 Feb 2025 17:32:20 -0500 Subject: [PATCH 2/8] updating workflow --- .github/workflows/auto-approve.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/auto-approve.yml b/.github/workflows/auto-approve.yml index bd92fcf..2f87e6d 100644 --- a/.github/workflows/auto-approve.yml +++ b/.github/workflows/auto-approve.yml @@ -17,6 +17,16 @@ jobs: pull-requests: write if: contains(github.event.pull_request.labels.*.name, 'auto-approve') && (github.event.pull_request.user.login == 'hakenmt' || github.event.pull_request.user.login == 'github-bot') steps: + - name: Wait for build to succeed + uses: fountainhead/action-wait-for-check@v1.2.0 + id: wait-for-build + with: + token: ${{ github.token }} + checkName: build + ref: ${{ github.event.pull_request.head.sha || github.sha }}, + timeoutSeconds: 900 + - uses: hmarr/auto-approve-action@v2.2.1 + if: steps.wait-for-build.outputs.conclusion == 'success' || steps.wait-for-build.outputs.conclusion == 'neutral' with: - github-token: ${{ github.token }} + github-token: ${{ secrets.PAT_TOKEN }} From 5b8b600357ed0dcbb5e2c7299bd74b7e1899eff5 Mon Sep 17 00:00:00 2001 From: Michael Haken Date: Mon, 24 Feb 2025 17:37:18 -0500 Subject: [PATCH 3/8] updated auto approve workflow --- .github/workflows/auto-approve.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/auto-approve.yml b/.github/workflows/auto-approve.yml index 2f87e6d..5509812 100644 --- a/.github/workflows/auto-approve.yml +++ b/.github/workflows/auto-approve.yml @@ -23,10 +23,12 @@ jobs: with: token: ${{ github.token }} checkName: build - ref: ${{ github.event.pull_request.head.sha || github.sha }}, + ref: ${{ github.event.pull_request.head.sha }}, timeoutSeconds: 900 - - uses: hmarr/auto-approve-action@v2.2.1 + - name: auto-approve + id: auto-approve + uses: hmarr/auto-approve-action@v2.2.1 if: steps.wait-for-build.outputs.conclusion == 'success' || steps.wait-for-build.outputs.conclusion == 'neutral' with: github-token: ${{ secrets.PAT_TOKEN }} From 5ecbd89133e6cbba761c211ef27acc89508cf720 Mon Sep 17 00:00:00 2001 From: Michael Haken Date: Mon, 24 Feb 2025 21:25:43 -0500 Subject: [PATCH 4/8] checking sha values --- .github/workflows/auto-approve.yml | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/auto-approve.yml b/.github/workflows/auto-approve.yml index 5509812..bbaaf72 100644 --- a/.github/workflows/auto-approve.yml +++ b/.github/workflows/auto-approve.yml @@ -17,18 +17,23 @@ jobs: pull-requests: write if: contains(github.event.pull_request.labels.*.name, 'auto-approve') && (github.event.pull_request.user.login == 'hakenmt' || github.event.pull_request.user.login == 'github-bot') steps: - - name: Wait for build to succeed - uses: fountainhead/action-wait-for-check@v1.2.0 - id: wait-for-build - with: - token: ${{ github.token }} - checkName: build - ref: ${{ github.event.pull_request.head.sha }}, - timeoutSeconds: 900 + - name: tmp + run: | + echo ${{ github.event.pull_request.head.sha }} + echo ${{ github.sha }} + + #- name: Wait for build to succeed + # uses: fountainhead/action-wait-for-check@v1.2.0 + # id: wait-for-build + # with: + # token: ${{ github.token }} + # checkName: build + # ref: ${{ github.event.pull_request.head.sha }}, + # timeoutSeconds: 600 - name: auto-approve id: auto-approve uses: hmarr/auto-approve-action@v2.2.1 - if: steps.wait-for-build.outputs.conclusion == 'success' || steps.wait-for-build.outputs.conclusion == 'neutral' + #if: contains('success,neutral', steps.wait-for-build.outputs.conclusion) with: github-token: ${{ secrets.PAT_TOKEN }} From 757ff6d72f0e703022185faa2045be833f012058 Mon Sep 17 00:00:00 2001 From: Michael Haken Date: Mon, 24 Feb 2025 21:29:17 -0500 Subject: [PATCH 5/8] updated --- .github/workflows/auto-approve.yml | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/.github/workflows/auto-approve.yml b/.github/workflows/auto-approve.yml index bbaaf72..721a670 100644 --- a/.github/workflows/auto-approve.yml +++ b/.github/workflows/auto-approve.yml @@ -17,23 +17,18 @@ jobs: pull-requests: write if: contains(github.event.pull_request.labels.*.name, 'auto-approve') && (github.event.pull_request.user.login == 'hakenmt' || github.event.pull_request.user.login == 'github-bot') steps: - - name: tmp - run: | - echo ${{ github.event.pull_request.head.sha }} - echo ${{ github.sha }} - - #- name: Wait for build to succeed - # uses: fountainhead/action-wait-for-check@v1.2.0 - # id: wait-for-build - # with: - # token: ${{ github.token }} - # checkName: build - # ref: ${{ github.event.pull_request.head.sha }}, - # timeoutSeconds: 600 + - name: Wait for build to succeed + uses: fountainhead/action-wait-for-check@v1.2.0 + id: wait-for-build + with: + token: ${{ github.token }} + checkName: build + ref: ${{ github.event.pull_request.head.sha }}, + timeoutSeconds: 600 - name: auto-approve id: auto-approve uses: hmarr/auto-approve-action@v2.2.1 #if: contains('success,neutral', steps.wait-for-build.outputs.conclusion) with: - github-token: ${{ secrets.PAT_TOKEN }} + github-token: ${{ github.token }} From b5f2b69d7bb42940408862e7a2044ce52c55282c Mon Sep 17 00:00:00 2001 From: Michael Haken Date: Mon, 24 Feb 2025 22:14:44 -0500 Subject: [PATCH 6/8] new wait for build logic --- .github/workflows/auto-approve.yml | 59 ++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 8 deletions(-) diff --git a/.github/workflows/auto-approve.yml b/.github/workflows/auto-approve.yml index 721a670..68c634d 100644 --- a/.github/workflows/auto-approve.yml +++ b/.github/workflows/auto-approve.yml @@ -17,18 +17,61 @@ jobs: pull-requests: write if: contains(github.event.pull_request.labels.*.name, 'auto-approve') && (github.event.pull_request.user.login == 'hakenmt' || github.event.pull_request.user.login == 'github-bot') steps: - - name: Wait for build to succeed - uses: fountainhead/action-wait-for-check@v1.2.0 + #- name: Wait for build to succeed + # uses: fountainhead/action-wait-for-check@v1.2.0 + # id: wait-for-build + # with: + # token: ${{ github.token }} + # checkName: build + # ref: ${{ github.event.pull_request.head.sha }}, + # timeoutSeconds: 600 + + - name: wait-for-build id: wait-for-build - with: - token: ${{ github.token }} - checkName: build - ref: ${{ github.event.pull_request.head.sha }}, - timeoutSeconds: 600 + env: + SHA: ${{ github.event.pull_request.head.sha }} + run: | + # Set timeout and interval + TIMEOUT=600 + INTERVAL=10 + START_TIME=$(date +%s) + TERMINATING_STATUS=("completed" "action_required" "cancelled" "failure" "neutral" "skipped" "stale" "success" "timed_out" ) + + while true; do + # Get the latest build workflow run for this PR + WORKFLOW_RUN=$(gh api repos/${{ github.repository }}/actions/runs?head_sha=$SHA \ + --jq '.workflow_runs | map(select(.head_sha == "${{ github.event.pull_request.head.sha }}" and .name == "build"))[0]') + + if [ -z "$WORKFLOW_RUN" ]; then + echo "No build workflow run found for the latest commit." + else + STATUS=$(echo "$WORKFLOW_RUN" | jq -r '.conclusion') + + if [[ ${TERMINATING_STATUS[@]} =~ "$STATUS" ]]; then + echo "Build workflow finished." + echo "conclusion=$STATUS" >> $GITHUB_OUTPUT + break + else + echo "Build workflow status: $STATUS. Waiting for success..." + fi + fi + + # Check if timeout has been reached + CURRENT_TIME=$(date +%s) + ELAPSED_TIME=$((CURRENT_TIME - START_TIME)) + if [ $ELAPSED_TIME -ge $TIMEOUT ]; then + echo "Timeout reached. Build workflow did not succeed within $TIMEOUT seconds." + echo "conclusion=timed_out" >> $GITHUB_OUTPUT + break + fi + + # Wait for the specified interval before checking again + sleep $INTERVAL + done - name: auto-approve id: auto-approve uses: hmarr/auto-approve-action@v2.2.1 - #if: contains('success,neutral', steps.wait-for-build.outputs.conclusion) + if: contains('success,neutral,skipped', steps.wait-for-build.outputs.conclusion) with: github-token: ${{ github.token }} From 0483f3628067f71b8e20fd1e5369322b5c86adf4 Mon Sep 17 00:00:00 2001 From: Michael Haken Date: Mon, 24 Feb 2025 22:17:18 -0500 Subject: [PATCH 7/8] trying new logic --- .github/workflows/auto-approve.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/auto-approve.yml b/.github/workflows/auto-approve.yml index 68c634d..028ccf9 100644 --- a/.github/workflows/auto-approve.yml +++ b/.github/workflows/auto-approve.yml @@ -15,6 +15,8 @@ jobs: runs-on: ubuntu-latest permissions: pull-requests: write + actions: read + checks: read if: contains(github.event.pull_request.labels.*.name, 'auto-approve') && (github.event.pull_request.user.login == 'hakenmt' || github.event.pull_request.user.login == 'github-bot') steps: #- name: Wait for build to succeed @@ -30,6 +32,7 @@ jobs: id: wait-for-build env: SHA: ${{ github.event.pull_request.head.sha }} + GH_TOKEN: ${{ github.token }} run: | # Set timeout and interval TIMEOUT=600 From ae8ebfc793a0725358122fe4360a82a7a57658ff Mon Sep 17 00:00:00 2001 From: Michael Haken Date: Mon, 24 Feb 2025 22:59:08 -0500 Subject: [PATCH 8/8] updated workflows --- .github/workflows/auto-approve.yml | 25 +++++++++++-------------- .github/workflows/test.yml | 2 +- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/.github/workflows/auto-approve.yml b/.github/workflows/auto-approve.yml index 028ccf9..3a5c4c0 100644 --- a/.github/workflows/auto-approve.yml +++ b/.github/workflows/auto-approve.yml @@ -17,32 +17,22 @@ jobs: pull-requests: write actions: read checks: read - if: contains(github.event.pull_request.labels.*.name, 'auto-approve') && (github.event.pull_request.user.login == 'hakenmt' || github.event.pull_request.user.login == 'github-bot') + if: contains(github.event.pull_request.labels.*.name, 'auto-approve') && contains('hakenmt,github-bot', github.event.pull_request.user.login) steps: - #- name: Wait for build to succeed - # uses: fountainhead/action-wait-for-check@v1.2.0 - # id: wait-for-build - # with: - # token: ${{ github.token }} - # checkName: build - # ref: ${{ github.event.pull_request.head.sha }}, - # timeoutSeconds: 600 - - name: wait-for-build id: wait-for-build env: SHA: ${{ github.event.pull_request.head.sha }} GH_TOKEN: ${{ github.token }} + TIMEOUT: 600 + INTERVAL: 10 run: | - # Set timeout and interval - TIMEOUT=600 - INTERVAL=10 START_TIME=$(date +%s) TERMINATING_STATUS=("completed" "action_required" "cancelled" "failure" "neutral" "skipped" "stale" "success" "timed_out" ) while true; do # Get the latest build workflow run for this PR - WORKFLOW_RUN=$(gh api repos/${{ github.repository }}/actions/runs?head_sha=$SHA \ + WORKFLOW_RUN=$(gh api /repos/${{ github.repository }}/actions/runs?head_sha=$SHA \ --jq '.workflow_runs | map(select(.head_sha == "${{ github.event.pull_request.head.sha }}" and .name == "build"))[0]') if [ -z "$WORKFLOW_RUN" ]; then @@ -72,6 +62,13 @@ jobs: sleep $INTERVAL done + - name: fail + id: fail + if: ${{ !contains('success,neutral,skipped', steps.wait-for-build.outputs.conclusion) }} + run: | + echo "Did not reach successful build workflow state. Conclusion: ${{ steps.wait-for-build.outputs.conclusion }}" + exit 1 + - name: auto-approve id: auto-approve uses: hmarr/auto-approve-action@v2.2.1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 824b879..2288302 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,7 +1,7 @@ name: test on: workflow_run: - workflows: ["review"] + workflows: ["review", "auto-approve"] types: - completed