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

chore(repo): Expand CW Metric logging to all tests #3912

Merged
merged 12 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 10 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
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:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switch parameter sent because package-name does not give sufficient information on category information for smithy and other minor categories.

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:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is now computed based on working-directory

description: analytics, api, authenticator, etc.
required: true

# FlutterDart Workflows Metric Dimensions
framework:
Expand Down
425 changes: 237 additions & 188 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.

8 changes: 4 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,8 @@ 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 }}
matrix: ${{ toJson(matrix) != 'null' && toJson(matrix) || '' }}
Copy link
Member

Choose a reason for hiding this comment

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

I'm not following this. Is there a way to write this more clearly in code? If not, can you add a comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, this code can be improved. Updated to:

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

If the matrix value is empty we send a blank {} else we convert to json and send back.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to handle null matrix cases


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
Copy link
Member

Choose a reason for hiding this comment

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

Why is write access needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Setting the permissions to write is required in order to request an OpenID Connect JWT.

https://stackoverflow.com/questions/72183048/what-is-the-permission-scope-of-id-token-in-github-action

Removing this permission causes logging to fail to assume the token.

Copy link
Contributor

Choose a reason for hiding this comment

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

We need a token in order to post the log to cloudwatch, I assume?

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 that's correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This utilizes the same framework that AppSec signed off several months ago when we just started sending Cloudwatch logs from our canaries.

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
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All workflows need these permissions now in order to send the Cloudwatch Metric


# 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
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