Skip to content
Merged
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
50 changes: 48 additions & 2 deletions .github/workflows/update-automation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,52 @@ jobs:
echo "Created PR from ${{ needs.update-automation.outputs.staging-branch }} to $TARGET_BRANCH"
publish-release-lag-metric:
name: Publish Release Lag Metric
runs-on: ubuntu-latest
needs: [update-automation]
if: always()
environment: update-automation-workflow-env
permissions:
id-token: write # Required for OIDC
contents: read
env:
REPOSITORY: ${{ github.repository }}
AWS_ROLE_TO_ASSUME: ${{ secrets.AWS_ROLE_TO_ASSUME }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 1

- name: Use role credentials for metrics
id: aws-creds
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.AWS_ROLE_TO_ASSUME }}
aws-region: us-east-1

- name: Calculate and publish release lag metric
if: steps.aws-creds.outcome == 'success'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if this condition is not meet, how can we detect it? will it be covered by automation update missing alarm?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in the case if metric is missing alarm will also be triggered
treatMissingData: TreatMissingData.BREACHING

run: |
cd third-party-src
SUBMODULE_COMMIT_TIMESTAMP=$(git log -1 --format=%ct)
cd ..
CURRENT_TIMESTAMP=$(date +%s)
SECONDS_BEHIND=$((CURRENT_TIMESTAMP - SUBMODULE_COMMIT_TIMESTAMP))
NORMALIZED_VALUE=$(awk "BEGIN {printf \"%.6f\", $SECONDS_BEHIND / 86400}")
aws cloudwatch put-metric-data \
--namespace "GitHub/Workflows" \
--metric-name "CodeOSSReleaseLag" \
--dimensions "Repository=${{ env.REPOSITORY }},Workflow=UpdateAutomation" \
--value $NORMALIZED_VALUE \
--unit None
echo "Published metric: CodeOSSReleaseLag = $NORMALIZED_VALUE (equivalent to $NORMALIZED_VALUE days behind upstream)"
send-notification:
name: Send Notification
runs-on: ubuntu-latest
Expand Down Expand Up @@ -434,7 +480,7 @@ jobs:
publish-success-metrics:
name: Publish Success Metrics
runs-on: ubuntu-latest
needs: [update-automation, build-and-update-package-locks, generate-oss-attribution, create-pr, send-notification]
needs: [update-automation, build-and-update-package-locks, generate-oss-attribution, create-pr, send-notification, publish-release-lag-metric]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will publish-release-lag-metric execute in parallel with other actions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, to make sure it is run before deciding success and failure metric

environment: update-automation-workflow-env
if: always() && !failure() && !cancelled()
permissions:
Expand Down Expand Up @@ -463,7 +509,7 @@ jobs:
publish-failure-metrics:
name: Publish Failure Metrics
runs-on: ubuntu-latest
needs: [update-automation, build-and-update-package-locks, generate-oss-attribution, create-pr, send-notification]
needs: [update-automation, build-and-update-package-locks, generate-oss-attribution, create-pr, send-notification, publish-release-lag-metric]
environment: update-automation-workflow-env
if: failure()
permissions:
Expand Down
Loading