Skip to content

Commit cdfa225

Browse files
authored
CI: Add AWS instance type to stats (#4687)
* CI: Add AWS instance type to stats * Update scripts * Collect stats * Create dedicated GitHub action * Revert "Create dedicated GitHub action" This reverts commit cd28afa. * Add fallback value
1 parent 7c4f388 commit cdfa225

File tree

5 files changed

+49
-0
lines changed

5 files changed

+49
-0
lines changed

.github/actions/collect-runner-stats/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ inputs:
1717
required: false
1818
type: string
1919
default: ''
20+
aws_instance_type:
21+
required: false
22+
type: string
23+
default: ''
2024

2125
outputs:
2226
job_id:
@@ -54,6 +58,7 @@ runs:
5458
CXX_COMPILER: ${{ inputs.cxx_compiler }}
5559
BUILD_CONFIG: ${{ inputs.build_config }}
5660
BUILD_SYSTEM: ${{ inputs.build_system }}
61+
AWS_INSTANCE_TYPE: ${{ inputs.aws_instance_type }}
5762
STATS_FILE: "${{ runner.temp }}/RunnerSysStats-${{ steps.fetch_job_id.outputs.job_id }}.json"
5863
run: ""
5964

.github/workflows/build-test-emscripten.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,25 @@ jobs:
5151
mkdir ${GITHUB_WORKSPACE}
5252
fi
5353
54+
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
55+
- name: Get AWS instance type
56+
run: |
57+
TOKEN=$(curl -fsS --max-time 2 \
58+
-X PUT "http://169.254.169.254/latest/api/token" \
59+
-H "X-aws-ec2-metadata-token-ttl-seconds: 10" || true)
60+
61+
AWS_INSTANCE_TYPE=$(curl -fsS --max-time 2 \
62+
-H "X-aws-ec2-metadata-token: $TOKEN" \
63+
"http://169.254.169.254/latest/meta-data/instance-type" || true)
64+
65+
# if not an EC2 instance
66+
if [[ -z "$AWS_INSTANCE_TYPE" ]]; then
67+
AWS_INSTANCE_TYPE="self-hosted"
68+
fi
69+
70+
echo "AWS_INSTANCE_TYPE=$AWS_INSTANCE_TYPE" >> $GITHUB_ENV
71+
echo $AWS_INSTANCE_TYPE
72+
5473
- name: Checkout
5574
uses: actions/checkout@v4
5675

@@ -63,6 +82,7 @@ jobs:
6382
target_arch: wasm
6483
cxx_compiler: emcc
6584
build_config: Release
85+
aws_instance_type: ${{ env.AWS_INSTANCE_TYPE }}
6686

6787
- name: Checkout third-party submodules
6888
run: |

.github/workflows/build-test-ubuntu-arm64.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,25 @@ jobs:
6969
mv ${GITHUB_WORKSPACE} ${GITHUB_WORKSPACE}_${RANDOM}
7070
mkdir ${GITHUB_WORKSPACE}
7171
fi
72+
73+
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
74+
- name: Get AWS instance type
75+
run: |
76+
TOKEN=$(curl -fsS --max-time 2 \
77+
-X PUT "http://169.254.169.254/latest/api/token" \
78+
-H "X-aws-ec2-metadata-token-ttl-seconds: 10" || true)
79+
80+
AWS_INSTANCE_TYPE=$(curl -fsS --max-time 2 \
81+
-H "X-aws-ec2-metadata-token: $TOKEN" \
82+
"http://169.254.169.254/latest/meta-data/instance-type" || true)
83+
84+
# if not an EC2 instance
85+
if [[ -z "$AWS_INSTANCE_TYPE" ]]; then
86+
AWS_INSTANCE_TYPE="self-hosted"
87+
fi
88+
89+
echo "AWS_INSTANCE_TYPE=$AWS_INSTANCE_TYPE" >> $GITHUB_ENV
90+
echo $AWS_INSTANCE_TYPE
7291
7392
- name: Checkout
7493
uses: actions/checkout@v4
@@ -82,6 +101,7 @@ jobs:
82101
target_arch: arm64
83102
cxx_compiler: ${{ matrix.cxx-compiler }}
84103
build_config: ${{ matrix.config }}
104+
aws_instance_type: ${{ env.AWS_INSTANCE_TYPE }}
85105

86106
- name: Checkout third-party submodules
87107
run: |

scripts/devops/collect_ci_stats.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def parse_job(job: dict):
5656
'runner_cpu_count': runner_stats['cpu_count'],
5757
'runner_ram_mb': runner_stats['ram_mb'],
5858
'build_system': runner_stats['build_system'],
59+
'aws_instance_type': runner_stats['aws_instance_type'],
5960
}
6061
except:
6162
print("Something went wrong while parsing the job/runner info. Debug info:")

scripts/devops/collect_runner_sys_stats.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ def get_compiler_id(compiler_path):
6262
if not build_system:
6363
build_system = "msbuild" if compiler_id.startswith("msvc") else "cmake"
6464

65+
aws_instance_type = os.environ.get('AWS_INSTANCE_TYPE', '').lower()
66+
6567
results = {
6668
'target_os': os.environ.get('TARGET_OS'),
6769
'target_arch': os.environ.get('TARGET_ARCH'),
@@ -70,6 +72,7 @@ def get_compiler_id(compiler_path):
7072
'cpu_count': cpu_count,
7173
'ram_mb': ram_amount,
7274
'build_system': build_system,
75+
'aws_instance_type': aws_instance_type or None,
7376
}
7477
with open(os.environ['STATS_FILE'], 'w') as f:
7578
json.dump(results, f)

0 commit comments

Comments
 (0)