Skip to content

Commit

Permalink
First attempt rewrite global metrics tracking.
Browse files Browse the repository at this point in the history
Add missing metrics for all other workflows.

fix canaries

force runs test
  • Loading branch information
kyle committed Aug 9, 2023
1 parent c0fd1f8 commit f3bfae0
Show file tree
Hide file tree
Showing 12 changed files with 368 additions and 68 deletions.
79 changes: 67 additions & 12 deletions .github/composite_actions/log_metric/action.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,60 @@
name: Log Metric
description: Log data point to a metric with the provided value. If the metric is not there, it will create one
description: Log data point to a metric with the provided value. If the metric is not there, it will create one.
# To avoid 'Credentials could not be loaded' calling workflows must include:
# permissions:
# id-token: write
# contents: read
inputs:
aws-region:
required: true
description: The AWS region
description: The AWS region.
role-to-assume:
required: true
description: The role to assume in the STS session
metric-name:
description: Name of the metric to track in Cloudwatch.
required: true
value:
description: The role to assume in the STS session.

#value:
# Why we publish value 0 on success: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/publishingMetrics.html#publishingZero
description: Value of the metric to track in Cloudwatch.
# description: Value of the metric to track in Cloudwatch.
# required: true

# Global Metric Dimensions
testType:
description: canary, integration, unit testType.
required: true
category:
description: analytics, api, authenticator, etc.
required: true
dimensions:
description: Dimensions of metric to track in Cloudwatch, in format dimensionName1=value,dimensionName2=value,...
workflowName:
description: The Github Action workflow.yaml file name. ie "AmplifyCanaries".
required: true
# failingStep: Look into getting via code


# FlutterDart Workflows Metric Dimensions
framework:
description: flutter, dart.
required: false
flutterDartChannel:
description: beta, stable.
required: false
dartVersion:
description: 3, 2.19, 2.18, etc.
required: false
flutterVersion:
description: 3.10.6, 3.10.5, etc.
required: false
dartCompiler:
description: dart2js, ddc, dart, dart2wasm.
required: false

# Platform Workflows Metric Dimensions
platform:
description: android, ios, web, linux, windows.
required: false
platformVersion:
description: ios-14.5, ios-16, android-25-x86, etc.
required: false

runs:
using: 'composite'
steps:
Expand All @@ -31,7 +65,28 @@ runs:
aws-region: ${{ inputs.aws-region }}
role-duration-seconds: 900

- name: Check for failure condition
id: check-failure
run: echo "FAILURE_CONDITION=$(some-command || echo 0)" >> $GITHUB_ENV

- name: Set value based on failure condition
id: set-value
run: echo "value=$(if [ $FAILURE_CONDITION -eq 0 ]; then echo 1; else echo 0; fi)" >> $GITHUB_ENV

- name: Run Dart script
# Run a Dart script to put metric data.
run: dart ./tool/send_metric_data.dart ${{ inputs.metric-name }} ${{ inputs.value }} ${{ inputs.dimensions }}
shell: bash
run: dart ./tool/send_metric_data.dart \
"GithubMetric v1.0" \
${{ env.value }} \
${{ inputs.testType }} \
${{ inputs.category }} \
${{ inputs.workflowName }} \
${{ inputs.framework }} \
${{ inputs.flutterDartChannel }} \
${{ inputs.dartVersion }} \
${{ inputs.flutterVersion }} \
${{ inputs.dartCompiler }} \
${{ inputs.platform }} \
${{ inputs.platformVersion }} \
$GITHUB_RUN_ID
shell: bash
72 changes: 28 additions & 44 deletions .github/workflows/amplify_canaries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,18 @@ jobs:
- name: Build Canary (Android)
run: build-support/build_canary.sh apk

- name: Log failing builds
if: ${{ failure() }}
- name: Log success/failure
if: always()
uses: ./.github/composite_actions/log_metric
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: ${{ secrets.AWS_REGION }}
metric-name: BuildCanaryTestFailure
value: 1
dimensions: channel=${{ matrix.channel }}
- name: Log succeeding builds
if: ${{ success() }}
uses: ./.github/composite_actions/log_metric
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: ${{ secrets.AWS_REGION }}
metric-name: BuildCanaryTestFailure
value: 0
dimensions: channel=${{ matrix.channel }}
aws-region: ${{ secrets.AWS_REGION }}
testType: canary
category: all
workflowName: amplify_canaries/build
framework: flutter
flutterDartChannel: ${{ matrix.channel }}
flutterVersion: $${{ matrix.flutter-version }}

e2e-android:
runs-on: macos-latest
Expand Down Expand Up @@ -127,24 +121,19 @@ jobs:
# Perform a build to reduce startup time of `flutter test` and prevent timeout
script: cd canaries && flutter build apk --debug && flutter test -d emulator-5554 integration_test/main_test.dart

- name: Log failing android runs
if: ${{ failure() }}
- name: Log success/failure
uses: ./.github/composite_actions/log_metric
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: ${{ secrets.AWS_REGION }}
metric-name: E2ECanaryTestFailure
value: 1
dimensions: channel=${{ matrix.channel }},platform=android
- name: Log succeeding android runs
if: ${{ success() }}
uses: ./.github/composite_actions/log_metric
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: ${{ secrets.AWS_REGION }}
metric-name: E2ECanaryTestFailure
value: 0
dimensions: channel=${{ matrix.channel }},platform=android
testType: canary
category: all
workflowName: amplify_canaries/e2e-android
framework: flutter
flutterDartChannel: ${{ matrix.channel }}
flutterVersion: $${{ matrix.flutter-version }}
platform: android


e2e-ios:
runs-on: macos-13
Expand Down Expand Up @@ -216,21 +205,16 @@ jobs:
flutter build ios --simulator --target=integration_test/main_test.dart
flutter test -d test integration_test/main_test.dart --verbose
- name: Log failing ios runs
if: ${{ failure() }}
- name: Log success/failure
uses: ./.github/composite_actions/log_metric
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: ${{ secrets.AWS_REGION }}
metric-name: E2ECanaryTestFailure
value: 1
dimensions: channel=${{ matrix.channel }},platform=ios
- name: Log succeeding ios runs
if: ${{ success() }}
uses: ./.github/composite_actions/log_metric
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: ${{ secrets.AWS_REGION }}
metric-name: E2ECanaryTestFailure
value: 0
dimensions: channel=${{ matrix.channel }},platform=ios
aws-region: ${{ secrets.AWS_REGION }}
testType: canary
category: all
workflowName: amplify_canaries/e2e-ios
framework: flutter
flutterDartChannel: ${{ matrix.channel }}
flutterVersion: $${{ matrix.flutter-version }}
platform: ios
platformVersion: $${{ matrix.ios-version }}
67 changes: 67 additions & 0 deletions .github/workflows/amplify_integration_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,20 @@ jobs:
target: ${{ matrix.target }}
arch: ${{ matrix.arch }}
script: aft exec --include=${{ matrix.scope }} -- small=true "<AFT_ROOT>/build-support/integ_test.sh" -d emulator-5554 --retries 1

- name: Log success/failure
uses: ./.github/composite_actions/log_metric
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: ${{ secrets.AWS_REGION }}
value: ${{ failure() && '1' || '0' }}
testType: integration
category: ${{ matrix.scope }}
workflowName: ${{ matrix.scope }}/amplify_integration_tests
framework: flutter
flutterDartChannel: stable
platform: android
platformVersion: ${{ matrix.api-level }} ${{ matrix.arch }}

ios:
runs-on: macos-latest
Expand Down Expand Up @@ -126,6 +140,19 @@ jobs:
timeout-minutes: 60
run: aft exec --include=${{ matrix.scope }} -- small=true "<AFT_ROOT>/build-support/integ_test_ios.sh" -d test

- name: Log success/failure
uses: ./.github/composite_actions/log_metric
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: ${{ secrets.AWS_REGION }}
value: ${{ failure() && '1' || '0' }}
testType: integration
category: ${{ matrix.scope }}
workflowName: ${{ matrix.scope }}/amplify_integration_tests
framework: flutter
flutterDartChannel: stable
platform: ios

web:
runs-on: ubuntu-latest
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
Expand Down Expand Up @@ -171,6 +198,20 @@ jobs:
chromedriver --port=4444 &
aft exec --include=${{ matrix.scope }} -- "<AFT_ROOT>/build-support/integ_test.sh" -d web-server
- name: Log success/failure
uses: ./.github/composite_actions/log_metric
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: ${{ secrets.AWS_REGION }}
value: ${{ failure() && '1' || '0' }}
testType: integration
category: ${{ matrix.scope }}
workflowName: ${{ matrix.scope }}/amplify_integration_tests
framework: flutter
flutterDartChannel: stable
platform: web
platformVersion: chrome

# TODO(dnys1): Re-enable with self-hosted runners
# macos:
# runs-on: macos-latest
Expand Down Expand Up @@ -257,6 +298,19 @@ jobs:
flutter config --enable-linux-desktop
aft exec --include=${{ matrix.scope }} -- "<AFT_ROOT>/build-support/integ_test.sh" -d linux
- name: Log success/failure
uses: ./.github/composite_actions/log_metric
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: ${{ secrets.AWS_REGION }}
value: ${{ failure() && '1' || '0' }}
testType: integration
category: ${{ matrix.scope }}
workflowName: ${{ matrix.scope }}/amplify_integration_tests
framework: flutter
flutterDartChannel: stable
platform: linux

windows:
runs-on: windows-latest
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
Expand Down Expand Up @@ -301,3 +355,16 @@ jobs:
run: |
flutter config --enable-windows-desktop
dart pub global run aft exec --include=${{ matrix.scope }} -- flutter test integration_test/main_test.dart -d windows
- name: Log success/failure
uses: ./.github/composite_actions/log_metric
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: ${{ secrets.AWS_REGION }}
value: ${{ failure() && '1' || '0' }}
testType: integration
category: ${{ matrix.scope }}
workflowName: ${{ matrix.scope }}/amplify_integration_tests
framework: flutter
flutterDartChannel: stable
platform: windows
17 changes: 17 additions & 0 deletions .github/workflows/dart_dart2js.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,20 @@ jobs:
if: "always() && steps.bootstrap.conclusion == 'success'"
run: dart run build_runner test --release --delete-conflicting-outputs -- -p ${{ matrix.browser }}
working-directory: ${{ inputs.working-directory }}

- name: Log success/failure
uses: ./.github/composite_actions/log_metric
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: ${{ secrets.AWS_REGION }}
value: ${{ failure() && '1' || '0' }}
testType: canary
category: ${{ working-directory }}
workflowName: ${{ package-name }}/dart_dart2js
framework: dart
flutterDartChannel: ${{ matrix.sdk }}
dartCompiler: dart2js
platform: web
# 'chrome/firefox'
platformVersion: $${{ matrix.browser }}

16 changes: 16 additions & 0 deletions .github/workflows/dart_ddc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,19 @@ jobs:
if: "always() && steps.bootstrap.conclusion == 'success'"
run: dart run build_runner test --delete-conflicting-outputs -- -p ${{ matrix.browser }}
working-directory: ${{ inputs.working-directory }}

- name: Log success/failure
uses: ./.github/composite_actions/log_metric
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: ${{ secrets.AWS_REGION }}
value: ${{ failure() && '1' || '0' }}
testType: canary
category: ${{ working-directory }}
workflowName: ${{ package-name }}/dart_ddc
framework: dart
flutterDartChannel: ${{ matrix.sdk }}
dartCompiler: dart2js
platform: web
# 'chrome/firefox'
platformVersion: $${{ matrix.browser }}
13 changes: 13 additions & 0 deletions .github/workflows/dart_native.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,16 @@ jobs:
if: "always() && steps.bootstrap.conclusion == 'success'"
run: dart test --exclude-tags=build
working-directory: ${{ inputs.working-directory }}

- name: Log success/failure
uses: ./.github/composite_actions/log_metric
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: ${{ secrets.AWS_REGION }}
value: ${{ failure() && '1' || '0' }}
testType: unit test
category: ${{ working-directory }}
workflowName: ${{ package-name }}/dart_native
framework: dart
flutterDartChannel: stable
dartCompiler: dart
14 changes: 14 additions & 0 deletions .github/workflows/dart_vm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,17 @@ jobs:
if: "always() && steps.bootstrap.conclusion == 'success' && steps.testCheck.outputs.hasTests == 'true' && matrix.sdk != 'stable'"
run: dart test --exclude-tags=build
working-directory: ${{ inputs.working-directory }}

- name: Log success/failure
uses: ./.github/composite_actions/log_metric
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: ${{ secrets.AWS_REGION }}
value: ${{ failure() && '1' || '0' }}
testType: unit test
category: ${{ working-directory }}
workflowName: ${{ package-name }}/dart_vm
framework: dart
flutterDartChannel: ${{ matrix.sdk }}
dartCompiler: dart

13 changes: 13 additions & 0 deletions .github/workflows/flutter_android.build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,16 @@ jobs:
- name: Build for Android
run: flutter build apk --debug --verbose
working-directory: ${{ inputs.working-directory }}

- name: Log success/failure
uses: ./.github/composite_actions/log_metric
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: ${{ secrets.AWS_REGION }}
value: ${{ failure() && '1' || '0' }}
testType: unit test
category: ${{ working-directory }}
workflowName: ${{ package-name }}/flutter_android.build
framework: flutter
flutterDartChannel: ${{ matrix.channel }}
platform: android
Loading

0 comments on commit f3bfae0

Please sign in to comment.