Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated metric namespace #70

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 40 additions & 25 deletions .github/workflows/auto-approve.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,60 +18,75 @@ jobs:
actions: read
checks: read
if: contains(github.event.pull_request.labels.*.name, 'auto-approve') && contains('hakenmt,github-bot', github.event.pull_request.user.login)

env:
SHA: ${{ github.event.pull_request.head.sha }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TIMEOUT: 600
INTERVAL: 10
WORKFLOW_NAME: build
TERMINATING_STATUS: "completed,action_required,cancelled,failure,neutral,skipped,stale,success,timed_out"

outputs:
RUN_ID: ${{ steps.wait-for-build.outputs.run_id }}
RUN_NUMBER: ${{ steps.wait-for-build.outputs.run_number }}
WORKFLOW_ID: ${{ steps.wait-for-build.outputs.workflow_id }}
CONCLUSION: ${{ steps.wait-for-build.outputs.conclusion }}

steps:
- name: wait-for-build
- name: Wait for Build to Complete
id: wait-for-build
env:
SHA: ${{ github.event.pull_request.head.sha }}
GH_TOKEN: ${{ github.token }}
TIMEOUT: 600
INTERVAL: 10
run: |
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]')
# Fetch latest workflow run matching SHA and workflow name
WORKFLOW_RUN=$(gh api /repos/${{ github.repository }}/actions/runs \
--jq ".workflow_runs | map(select(.head_sha == \"$SHA\" and .name == \"$WORKFLOW_NAME\")) | first")

if [ -z "$WORKFLOW_RUN" ]; then
echo "No build workflow run found for the latest commit."
echo "No build workflow run found for commit $SHA."
else
STATUS=$(echo "$WORKFLOW_RUN" | jq -r '.conclusion')
RUN_NUMBER=$(echo "$WORKFLOW_RUN" | jq -r '.run_number')
RUN_ID=$(echo "$WORKFLOW_RUN" | jq -r '.id')
WORKFLOW_ID=$(echo "$WORKFLOW_RUN" | jq -r '.workflow_id')

echo "Build workflow status: $STATUS"

if [[ ${TERMINATING_STATUS[@]} =~ "$STATUS" ]]; then
echo "Build workflow finished."
echo "conclusion=$STATUS" >> $GITHUB_OUTPUT
if [[ ",$TERMINATING_STATUS," == *",$STATUS,"* ]]; then
echo "Build workflow finished with conclusion: $STATUS"
{
echo "conclusion=$STATUS"
echo "run_id=$RUN_ID"
echo "run_number=$RUN_NUMBER"
echo "workflow_id=$WORKFLOW_ID"
} >> "$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
ELAPSED=$(( $(date +%s) - START_TIME ))
if [ $ELAPSED -ge $TIMEOUT ]; then
echo "Timeout reached. Build workflow did not succeed within $TIMEOUT seconds."
echo "conclusion=timed_out" >> $GITHUB_OUTPUT
echo "conclusion=timed_out" >> "$GITHUB_OUTPUT"
break
fi

# Wait for the specified interval before checking again
sleep $INTERVAL
done

- name: fail
- name: Fail If Build Did Not Succeed
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 }}"
echo "❌ Build workflow failed. Conclusion: ${{ steps.wait-for-build.outputs.conclusion }}"
exit 1

- name: auto-approve
- name: Auto-Approve PR
id: auto-approve
uses: hmarr/[email protected]
if: contains('success,neutral,skipped', steps.wait-for-build.outputs.conclusion)
with:
github-token: ${{ github.token }}
github-token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ jobs:
contents: read
#runs-on: codebuild-AwsLabsMultiAZWorkshopArm64GithubRunner-${{ github.run_id }}-${{ github.run_attempt }}
runs-on: ubuntu-24.04-arm

env:
CDK_LOCATION: "cdk"
PROJECT_NAME: ${{ github.event.repository.name }}
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: 0
BUILD_APP: false
USE_CODEBUILD: false

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,63 @@ permissions: {}

jobs:
review:

env:
SHA: ${{ github.event.pull_request.head.sha }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

outputs:
RUN_ID: ${{ steps.wait-for-build.outputs.run_id }}
RUN_NUMBER: ${{ steps.wait-for-build.outputs.run_number }}
WORKFLOW_ID: ${{ steps.wait-for-build.outputs.workflow_id }}
CONCLUSION: ${{ steps.wait-for-build.outputs.conclusion }}

runs-on: ubuntu-latest
steps:
- name: Wait for Build to Complete
id: wait-for-build
run: |
START_TIME=$(date +%s)

while true; do
# Fetch latest workflow run matching SHA and workflow name
WORKFLOW_RUN=$(gh api /repos/${{ github.repository }}/actions/runs \
--jq --arg sha "$SHA" --arg workflow_name "$WORKFLOW_NAME" \
'.workflow_runs | map(select(.head_sha == $sha and .name == $workflow_name)) | first')

if [ -z "$WORKFLOW_RUN" ]; then
echo "No build workflow run found for commit $SHA."
else
STATUS=$(echo "$WORKFLOW_RUN" | jq -r '.conclusion')
RUN_NUMBER=$(echo "$WORKFLOW_RUN" | jq -r '.run_number')
RUN_ID=$(echo "$WORKFLOW_RUN" | jq -r '.id')
WORKFLOW_ID=$(echo "$WORKFLOW_RUN" | jq -r '.workflow_id')

echo "Build workflow status: $STATUS"

if [[ ",$TERMINATING_STATUS," == *",$STATUS,"* ]]; then
echo "Build workflow finished with conclusion: $STATUS"
{
echo "conclusion=$STATUS"
echo "run_id=$RUN_ID"
echo "run_number=$RUN_NUMBER"
echo "workflow_id=$WORKFLOW_ID"
} >> "$GITHUB_OUTPUT"
break
fi
fi

# Check if timeout has been reached
ELAPSED=$(( $(date +%s) - START_TIME ))
if [ $ELAPSED -ge $TIMEOUT ]; then
echo "Timeout reached. Build workflow did not succeed within $TIMEOUT seconds."
echo "conclusion=timed_out" >> "$GITHUB_OUTPUT"
break
fi

sleep $INTERVAL
done

- name: Set approval status
id: check_approval
run: |
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,22 @@ jobs:
env:
BUCKET: ${{ secrets.BUCKET }}
PROJECT_NAME: ${{ github.event.repository.name }}
RUN_ID: ${{ github.event.workflow_run.id }}
RUN_NUMBER: ${{ github.event.workflow_run.run_number }}

steps:
- name: Get run data
run: |
BUILD_RUN_ID=$(gh run view $RUN_ID --json jobs --jq '.jobs[].outputs.RUN_ID')
echo $BUILD_RUN_ID
echo "BUILD_RUN_ID=$BUILD_RUN_ID" >> $GITHUB_ENV

- name: Get workshop content
uses: actions/download-artifact@v4
with:
name: ContentArtifact
github-token: ${{ github.token }}
run-id: ${{ github.env.BUILD_RUN_ID }}

- name: Upload to S3
id: s3
Expand Down
2 changes: 1 addition & 1 deletion cdk/Configs/cw-agent-config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"metrics": {
"namespace": "multi-az/frontend",
"namespace": "multi-az-workshop/frontend",
"append_dimensions": {
"AutoScalingGroupName": "${aws:AutoScalingGroupName}",
"InstanceId": "${aws:InstanceId}"
Expand Down
2 changes: 1 addition & 1 deletion cdk/Configs/cw-agent-onebox-config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"metrics": {
"namespace": "multi-az/frontend/onebox",
"namespace": "multi-az-workshop/frontend/onebox",
"append_dimensions": {
"AutoScalingGroupName": "${aws:AutoScalingGroupName}",
"InstanceId": "${aws:InstanceId}"
Expand Down
Loading