Skip to content

Commit 4bc0fbb

Browse files
authored
misc: collect ci metrics (#1694)
* collect CI metric * use workflow from repotools * use bash * set up kat * configure credentials * use mac compatible format * bump repo tools version * cleanup * permission * always calculate duration
1 parent ea7fa00 commit 4bc0fbb

File tree

3 files changed

+112
-3
lines changed

3 files changed

+112
-3
lines changed

.github/workflows/codebuild-ci.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ jobs:
4343
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
4444
runs-on: ubuntu-latest
4545
steps:
46+
- name: Set start timestamp
47+
id: start
48+
run: printf 'timestamp=%(%s)T\n' >> "$GITHUB_OUTPUT"
4649
- name: Verify PRs are not running malicious code
4750
if: ${{ (inputs.aws-sdk-kotlin-pr != '' || inputs.smithy-kotlin-pr != '') && inputs.check-pr == false }}
4851
run: |
@@ -53,6 +56,8 @@ jobs:
5356
with:
5457
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }}
5558
aws-region: us-west-2
59+
- name: Setup kat
60+
uses: aws/aws-kotlin-repo-tools/.github/actions/setup-kat@main
5661
- name: Run E2E Tests
5762
id: e2e-tests
5863
uses: aws-actions/aws-codebuild-run-build@v1
@@ -68,11 +73,33 @@ jobs:
6873
echo "cancelling in-progress build: id=$BUILD_ID"
6974
aws codebuild stop-build --id $BUILD_ID
7075
fi
76+
- name: Calculate duration
77+
id: end
78+
if: always()
79+
run: |
80+
printf -v now '%(%s)T'
81+
duration=$(( now - ${{ steps.start.outputs.timestamp }} ))
82+
echo "duration=$duration" >> "$GITHUB_OUTPUT"
83+
- name: Emit metrics
84+
if: always() # run this step even if previous steps failed or the job is canceled
85+
uses: aws/aws-kotlin-repo-tools/.github/actions/emit-metrics@main
86+
with:
87+
namespace: CI Metrics
88+
dimensions: |
89+
Product=aws-sdk-kotlin
90+
JobName=${{ github.job }}
91+
Branch=${{ github.base_ref || github.ref_name }}
92+
metrics: |
93+
WorkflowSucceeded:${{ job.status == 'success' && '1' || '0' }}:Count
94+
WorkflowDuration:${{ steps.end.outputs.duration }}:Seconds
7195
7296
service-check-batch-and-artifact-size-metrics:
7397
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
7498
runs-on: ubuntu-latest
7599
steps:
100+
- name: Set start timestamp
101+
id: start
102+
run: printf 'timestamp=%(%s)T\n' >> "$GITHUB_OUTPUT"
76103
- name: Verify PRs are not running malicious code
77104
if: ${{ (inputs.aws-sdk-kotlin-pr != '' || inputs.smithy-kotlin-pr != '') && inputs.check-pr == false }}
78105
run: |
@@ -85,6 +112,8 @@ jobs:
85112
with:
86113
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }}
87114
aws-region: us-west-2
115+
- name: Setup kat
116+
uses: aws/aws-kotlin-repo-tools/.github/actions/setup-kat@main
88117
- name: Configure Gradle
89118
uses: aws/aws-kotlin-repo-tools/.github/actions/configure-gradle@main
90119
- name: Run Service Check Batch and Calculate Artifact Size Metrics
@@ -155,6 +184,25 @@ jobs:
155184
echo If this is expected please add the 'acknowledge-artifact-size-increase' label to this pull request.
156185
exit 1
157186
}
187+
- name: Calculate duration
188+
id: end
189+
if: always()
190+
run: |
191+
printf -v now '%(%s)T'
192+
duration=$(( now - ${{ steps.start.outputs.timestamp }} ))
193+
echo "duration=$duration" >> "$GITHUB_OUTPUT"
194+
- name: Emit metrics
195+
if: always() # run this step even if previous steps failed or the job is canceled
196+
uses: aws/aws-kotlin-repo-tools/.github/actions/emit-metrics@main
197+
with:
198+
namespace: CI Metrics
199+
dimensions: |
200+
Product=aws-sdk-kotlin
201+
JobName=${{ github.job }}
202+
Branch=${{ github.base_ref || github.ref_name }}
203+
metrics: |
204+
WorkflowSucceeded:${{ job.status == 'success' && '1' || '0' }}:Count
205+
WorkflowDuration:${{ steps.end.outputs.duration }}:Seconds
158206
159207
release-artifact-size-metrics:
160208
if: github.event_name == 'release'

.github/workflows/continuous-integration.yml

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ on:
44
pull_request:
55
workflow_dispatch:
66

7-
permissions: { }
8-
7+
permissions:
8+
id-token: write
9+
contents: read
910
# Allow one instance of this workflow per pull request, and cancel older runs when new changes are pushed
1011
concurrency:
1112
group: ci-pr-${{ github.ref }}
@@ -29,6 +30,9 @@ jobs:
2930
- 17
3031
- 21
3132
steps:
33+
- name: Set start timestamp
34+
id: start
35+
run: printf 'timestamp=%(%s)T\n' >> "$GITHUB_OUTPUT"
3236
- name: Checkout sources
3337
uses: actions/checkout@v4
3438
with:
@@ -39,13 +43,39 @@ jobs:
3943
uses: aws/aws-kotlin-repo-tools/.github/actions/configure-gradle@main
4044
with:
4145
working-directory: ./aws-sdk-kotlin
46+
- name: Configure AWS Credentials
47+
uses: aws-actions/configure-aws-credentials@v4
48+
with:
49+
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }}
50+
aws-region: us-west-2
51+
- name: Setup kat
52+
uses: aws/aws-kotlin-repo-tools/.github/actions/setup-kat@main
4253
- name: Test
4354
working-directory: ./aws-sdk-kotlin
4455
shell: bash
4556
run: |
4657
pwd
4758
ls -lsa
4859
./gradlew -Ptest.java.version=${{ matrix.java-version }} jvmTest --stacktrace
60+
- name: Calculate duration
61+
id: end
62+
if: always()
63+
run: |
64+
printf -v now '%(%s)T'
65+
duration=$(( now - ${{ steps.start.outputs.timestamp }} ))
66+
echo "duration=$duration" >> "$GITHUB_OUTPUT"
67+
- name: Emit metrics
68+
if: always() # run this step even if previous steps failed or the job is canceled
69+
uses: aws/aws-kotlin-repo-tools/.github/actions/emit-metrics@main
70+
with:
71+
namespace: CI Metrics
72+
dimensions: |
73+
Product=aws-sdk-kotlin
74+
JobName=${{ github.job }}(${{ matrix.java-version }})
75+
Branch=${{ github.base_ref || github.ref_name }}
76+
metrics: |
77+
WorkflowSucceeded:${{ job.status == 'success' && '1' || '0' }}:Count
78+
WorkflowDuration:${{ steps.end.outputs.duration }}:Seconds
4979
- name: Save Test Reports
5080
if: failure()
5181
uses: actions/upload-artifact@v4
@@ -60,12 +90,23 @@ jobs:
6090
matrix:
6191
os: [ ubuntu-latest, macos-latest, windows-latest ]
6292
steps:
93+
- name: Set start timestamp
94+
id: start
95+
shell: bash
96+
run: echo "timestamp=$(date +%s)" >> "$GITHUB_OUTPUT"
6397
- name: Checkout sources
6498
uses: actions/checkout@v4
6599
with:
66100
path: 'aws-sdk-kotlin'
67101
- name: Setup Build
68102
uses: ./aws-sdk-kotlin/.github/actions/setup-build
103+
- name: Configure AWS Credentials
104+
uses: aws-actions/configure-aws-credentials@v4
105+
with:
106+
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }}
107+
aws-region: us-west-2
108+
- name: Setup kat
109+
uses: aws/aws-kotlin-repo-tools/.github/actions/setup-kat@main
69110
- name: Configure Gradle - smithy-kotlin
70111
uses: aws/aws-kotlin-repo-tools/.github/actions/configure-gradle@main
71112
with:
@@ -99,6 +140,26 @@ jobs:
99140
./gradlew apiCheck
100141
./gradlew test jvmTest
101142
./gradlew testAllProtocols
143+
- name: Calculate duration
144+
id: end
145+
if: always()
146+
shell: bash
147+
run: |
148+
now=$(date +%s)
149+
duration=$(( now - ${{ steps.start.outputs.timestamp }} ))
150+
echo "duration=$duration" >> "$GITHUB_OUTPUT"
151+
- name: Emit metrics
152+
if: always() # run this step even if previous steps failed or the job is canceled
153+
uses: aws/aws-kotlin-repo-tools/.github/actions/emit-metrics@main
154+
with:
155+
namespace: CI Metrics
156+
dimensions: |
157+
Product=aws-sdk-kotlin
158+
JobName=${{ github.job }}(${{ matrix.os }})
159+
Branch=${{ github.base_ref || github.ref_name }}
160+
metrics: |
161+
WorkflowSucceeded:${{ job.status == 'success' && '1' || '0' }}:Count
162+
WorkflowDuration:${{ steps.end.outputs.duration }}:Seconds
102163
- name: Save Test Reports
103164
if: failure()
104165
uses: actions/upload-artifact@v4

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ksp-version = "2.2.0-2.0.2" # Keep in sync with kotlin-version
44

55
dokka-version = "2.0.0"
66

7-
aws-kotlin-repo-tools-version = "0.4.54"
7+
aws-kotlin-repo-tools-version = "0.4.58"
88

99
# libs
1010
coroutines-version = "1.10.2"

0 commit comments

Comments
 (0)