Skip to content

Commit

Permalink
chore(repo): Expand CW Metric logging to all tests (#3912)
Browse files Browse the repository at this point in the history
* chore(repo): Update Metric Logging Logic

1. Take working-directory instead of package-name to find category
2. Matrix is not required in cases when matrix does not exist
3. Remove category input, will be calculated using working-directory input instead.
4. Refactory Github API response parse logic to use generated class files

Generated workflows now need additional permissions and inherit secrets to enable their sub workflow calls to be authorized to log metrics.
  • Loading branch information
fjnoyp authored Oct 10, 2023
1 parent 12fc814 commit 40f20fc
Show file tree
Hide file tree
Showing 94 changed files with 998 additions and 363 deletions.
8 changes: 2 additions & 6 deletions .github/composite_actions/log_cw_metric/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ inputs:
github-token:
required: true
description: Github token for requesting failing steps.
package-name:
description: The name of the package being tested
working-directory:
description: The working directory relative to the repo root.
required: true
matrix:
description: The matrix of the workflow
required: true

# Global Metric Dimensions
metric-name:
Expand All @@ -22,9 +21,6 @@ inputs:
test-type:
description: canary, integration, unit testType.
required: true
category:
description: analytics, api, authenticator, etc.
required: true

# FlutterDart Workflows Metric Dimensions
framework:
Expand Down
517 changes: 289 additions & 228 deletions .github/composite_actions/log_cw_metric/dist/main.cjs

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions .github/composite_actions/log_cw_metric/dist/main.cjs.map

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions .github/composite_actions/log_cw_metric_wrapper/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ inputs:
test-type:
description: canary, e2e, unit
required: true
package-name:
description: The name of the package being tested
working-directory:
description: The working directory relative to the repo root.
required: true

# FlutterDart Workflows Metric Dimensions
Expand Down Expand Up @@ -85,8 +85,10 @@ runs:

metric-name: "github_metric_1.0"
test-type: ${{ inputs.test-type }}
package-name: ${{ inputs.package-name }}
matrix: ${{ toJson(matrix) }}
working-directory: ${{ inputs.working-directory }}

# Sending a null value will cause the action to fail so we must send an empty string here.
matrix: ${{ matrix == '' && '{}' || toJSON(matrix) }}

framework: ${{ inputs.framework }}
flutter-dart-channel: ${{ inputs.flutter-dart-channel }}
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/amplify_analytics_pinpoint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ defaults:
run:
shell: bash

permissions: read-all
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: read

# Cancels in-progress job when there is another push to same ref.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow
Expand All @@ -89,6 +92,7 @@ concurrency:
jobs:
test:
uses: ./.github/workflows/flutter_vm.yaml
secrets: inherit
with:
package-name: amplify_analytics_pinpoint
working-directory: packages/analytics/amplify_analytics_pinpoint
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/amplify_analytics_pinpoint_android.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ on:
defaults:
run:
shell: bash
permissions: read-all
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: read

# Cancels in-progress job when there is another push to same ref.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow
Expand All @@ -29,6 +32,7 @@ concurrency:
jobs:
android:
uses: ./.github/workflows/flutter_android.yaml
secrets: inherit
with:
example-directory: packages/analytics/amplify_analytics_pinpoint/example
package-name: amplify_analytics_pinpoint
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/amplify_analytics_pinpoint_dart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ defaults:
run:
shell: bash

permissions: read-all
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: read

# Cancels in-progress job when there is another push to same ref.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow
Expand All @@ -85,24 +88,28 @@ concurrency:
jobs:
test:
uses: ./.github/workflows/dart_vm.yaml
secrets: inherit
with:
package-name: amplify_analytics_pinpoint_dart
working-directory: packages/analytics/amplify_analytics_pinpoint_dart
native_test:
needs: test
uses: ./.github/workflows/dart_native.yaml
secrets: inherit
with:
package-name: amplify_analytics_pinpoint_dart
working-directory: packages/analytics/amplify_analytics_pinpoint_dart
ddc_test:
needs: test
uses: ./.github/workflows/dart_ddc.yaml
secrets: inherit
with:
package-name: amplify_analytics_pinpoint_dart
working-directory: packages/analytics/amplify_analytics_pinpoint_dart
dart2js_test:
needs: test
uses: ./.github/workflows/dart_dart2js.yaml
secrets: inherit
with:
package-name: amplify_analytics_pinpoint_dart
working-directory: packages/analytics/amplify_analytics_pinpoint_dart
1 change: 1 addition & 0 deletions .github/workflows/amplify_analytics_pinpoint_example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ concurrency:
jobs:
test:
uses: ./.github/workflows/flutter_vm.yaml
secrets: inherit
with:
package-name: amplify_analytics_pinpoint_example
working-directory: packages/analytics/amplify_analytics_pinpoint/example
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/amplify_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ defaults:
run:
shell: bash

permissions: read-all
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: read

# Cancels in-progress job when there is another push to same ref.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow
Expand All @@ -77,6 +80,7 @@ concurrency:
jobs:
test:
uses: ./.github/workflows/flutter_vm.yaml
secrets: inherit
with:
package-name: amplify_api
working-directory: packages/api/amplify_api
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/amplify_api_dart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ defaults:
run:
shell: bash

permissions: read-all
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: read

# Cancels in-progress job when there is another push to same ref.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow
Expand All @@ -61,24 +64,28 @@ concurrency:
jobs:
test:
uses: ./.github/workflows/dart_vm.yaml
secrets: inherit
with:
package-name: amplify_api_dart
working-directory: packages/api/amplify_api_dart
native_test:
needs: test
uses: ./.github/workflows/dart_native.yaml
secrets: inherit
with:
package-name: amplify_api_dart
working-directory: packages/api/amplify_api_dart
ddc_test:
needs: test
uses: ./.github/workflows/dart_ddc.yaml
secrets: inherit
with:
package-name: amplify_api_dart
working-directory: packages/api/amplify_api_dart
dart2js_test:
needs: test
uses: ./.github/workflows/dart_dart2js.yaml
secrets: inherit
with:
package-name: amplify_api_dart
working-directory: packages/api/amplify_api_dart
1 change: 1 addition & 0 deletions .github/workflows/amplify_api_example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ concurrency:
jobs:
test:
uses: ./.github/workflows/flutter_vm.yaml
secrets: inherit
with:
package-name: amplify_api_example
working-directory: packages/api/amplify_api/example
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/amplify_auth_cognito.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ defaults:
run:
shell: bash

permissions: read-all
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: read

# Cancels in-progress job when there is another push to same ref.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow
Expand All @@ -105,6 +108,7 @@ concurrency:
jobs:
test:
uses: ./.github/workflows/flutter_vm.yaml
secrets: inherit
with:
package-name: amplify_auth_cognito
working-directory: packages/auth/amplify_auth_cognito
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/amplify_auth_cognito_android.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ on:
defaults:
run:
shell: bash
permissions: read-all
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: read

# Cancels in-progress job when there is another push to same ref.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow
Expand All @@ -29,6 +32,7 @@ concurrency:
jobs:
android:
uses: ./.github/workflows/flutter_android.yaml
secrets: inherit
with:
example-directory: packages/auth/amplify_auth_cognito/example
package-name: amplify_auth_cognito
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/amplify_auth_cognito_dart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ defaults:
run:
shell: bash

permissions: read-all
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: read

# Cancels in-progress job when there is another push to same ref.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow
Expand All @@ -87,12 +90,14 @@ concurrency:
jobs:
test:
uses: ./.github/workflows/dart_vm.yaml
secrets: inherit
with:
package-name: amplify_auth_cognito_dart
working-directory: packages/auth/amplify_auth_cognito_dart
native_test:
needs: test
uses: ./.github/workflows/dart_native.yaml
secrets: inherit
with:
package-name: amplify_auth_cognito_dart
working-directory: packages/auth/amplify_auth_cognito_dart
1 change: 1 addition & 0 deletions .github/workflows/amplify_auth_cognito_example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ concurrency:
jobs:
test:
uses: ./.github/workflows/flutter_vm.yaml
secrets: inherit
with:
package-name: amplify_auth_cognito_example
working-directory: packages/auth/amplify_auth_cognito/example
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/amplify_auth_cognito_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ defaults:
run:
shell: bash

permissions: read-all
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: read

# Cancels in-progress job when there is another push to same ref.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow
Expand All @@ -97,24 +100,28 @@ concurrency:
jobs:
test:
uses: ./.github/workflows/dart_vm.yaml
secrets: inherit
with:
package-name: amplify_auth_cognito_test
working-directory: packages/auth/amplify_auth_cognito_test
native_test:
needs: test
uses: ./.github/workflows/dart_native.yaml
secrets: inherit
with:
package-name: amplify_auth_cognito_test
working-directory: packages/auth/amplify_auth_cognito_test
ddc_test:
needs: test
uses: ./.github/workflows/dart_ddc.yaml
secrets: inherit
with:
package-name: amplify_auth_cognito_test
working-directory: packages/auth/amplify_auth_cognito_test
dart2js_test:
needs: test
uses: ./.github/workflows/dart_dart2js.yaml
secrets: inherit
with:
package-name: amplify_auth_cognito_test
working-directory: packages/auth/amplify_auth_cognito_test
6 changes: 5 additions & 1 deletion .github/workflows/amplify_authenticator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ defaults:
run:
shell: bash

permissions: read-all
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: read

# Cancels in-progress job when there is another push to same ref.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow
Expand All @@ -109,6 +112,7 @@ concurrency:
jobs:
test:
uses: ./.github/workflows/flutter_vm.yaml
secrets: inherit
with:
package-name: amplify_authenticator
working-directory: packages/authenticator/amplify_authenticator
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/amplify_authenticator_example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ concurrency:
jobs:
test:
uses: ./.github/workflows/flutter_vm.yaml
secrets: inherit
with:
package-name: amplify_authenticator_example
working-directory: packages/authenticator/amplify_authenticator/example
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/amplify_canaries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}

test-type: canary
package-name: amplify_canaries
working-directory: canaries

framework: flutter
flutter-dart-channel: ${{ matrix.channel }}
Expand Down Expand Up @@ -139,7 +139,7 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}

test-type: canary
package-name: amplify_canaries
working-directory: canaries

framework: flutter
flutter-dart-channel: ${{ matrix.channel }}
Expand Down Expand Up @@ -217,7 +217,7 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}

test-type: canary
package-name: amplify_canaries
working-directory: canaries

framework: flutter
flutter-dart-channel: ${{ matrix.channel }}
Expand Down
Loading

0 comments on commit 40f20fc

Please sign in to comment.