Skip to content

Daily Lines of Code Report #174

Daily Lines of Code Report

Daily Lines of Code Report #174

name: Daily Lines of Code Report
on:
schedule:
# Every day at UTC midnight (Slack is posted daily; Telegram only Mon)
- cron: "0 0 * * *"
workflow_dispatch:
inputs:
slack_channel:
description: "Slack channel to post to"
required: true
default: "test"
type: choice
options:
- test
- prod
permissions:
contents: read
actions: write
env:
# Work around frequent libgit2/submodule fetch flakiness in CI.
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
CARGO_NET_RETRY: "10"
jobs:
loc:
name: Count ethrex loc and generate report
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup Rust Environment
uses: ./.github/actions/setup-rust
- name: Restore cache
id: cache-loc-report
uses: actions/cache/restore@v4
with:
path: tooling/loc/loc_report.json
key: loc-report-${{ github.ref_name }}-${{ github.run_id }}
restore-keys: |
loc-report-${{ github.ref_name }}-
- name: Rename cached loc_report.json to loc_report.json.old
if: steps.cache-loc-report.outputs.cache-hit != ''
run: mv tooling/loc/loc_report.json tooling/loc/loc_report.json.old
- name: Generate the loc report
run: |
cd tooling/loc && make loc
- name: Tailscale
uses: tailscale/github-action@v4
with:
oauth-client-id: ${{ vars.TS_OAUTH_CLIENT_ID }}
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
tags: tag:ci
- name: Forward Prometheus over Tailscale SSH
run: |
mkdir -p ~/.ssh/
retries=5; until ssh-keyscan ethrex-grafana >> ~/.ssh/known_hosts || [ $retries -eq 0 ]; do ((retries--)); sleep 5; done
ssh -NL 9090:localhost:9090 app@ethrex-grafana &
echo $! > /tmp/ts-ssh.pid
sleep 2
- name: Generate the combined report
env:
PERF_PROMETHEUS_URL: http://localhost:9090
PERF_PROMETHEUS_RANGE: 24h
PERF_PROMETHEUS_QUERY: >-
label_replace(avg_over_time(gigagas{instance=~"ethrex-mainnet-1(:[0-9]+)?"}[24h]), "client", "ethrex", "", "")
or label_replace(rate(reth_consensus_engine_beacon_new_payload_gas_per_second_sum{instance=~"reth-mainnet-1(:[0-9]+)?"}[24h]) / rate(reth_consensus_engine_beacon_new_payload_gas_per_second_count{instance=~"reth-mainnet-1(:[0-9]+)?"}[24h]) / 1e9, "client", "reth", "", "")
or label_replace(avg_over_time(nethermind_mgas_per_sec{instance=~"nethermind-mainnet-1(:[0-9]+)?"}[24h]) / 1000, "client", "nethermind", "", "")
or label_replace(avg_over_time(chain_mgasps{instance=~"geth-mainnet-1(:[0-9]+)?",quantile="0.5"}[24h]) / 1000, "client", "geth", "", "")
or label_replace(avg_over_time(chain_mgasps{instance=~"geth-mainnet-1(:[0-9]+)?",quantile="0.999"}[24h]) / 1000, "client", "geth", "", "")
BLOCK_TIME_PROMETHEUS_RANGE: 24h
BLOCK_TIME_PROMETHEUS_QUERY: >-
label_replace(
(
sum by (method, instance) (
increase(rpc_request_duration_seconds_sum{
job="ethrex L1",
instance=~"ethrex-mainnet-1:3701",
method="engine_newPayloadV4",
namespace="engine"
}[24h])
)
/
sum by (method, instance) (
increase(rpc_request_duration_seconds_count{
job="ethrex L1",
instance=~"ethrex-mainnet-1:3701",
method="engine_newPayloadV4",
namespace="engine"
}[24h])
)
) * 10e2,
"client",
"ethrex",
"",
""
)
or label_replace(
avg_over_time(
(
max without (BuildTimestamp,Commit,Version) (
nethermind_last_block_processing_time_in_ms{instance="nethermind-mainnet-1:6060"}
)
)[24h:]
),
"client",
"nethermind",
"",
""
)
or label_replace(
rate(reth_consensus_engine_beacon_new_payload_latency_sum{instance="reth-mainnet-1:6060"}[24h])
/ rate(reth_consensus_engine_beacon_new_payload_latency_count{instance="reth-mainnet-1:6060"}[24h])
* 1000,
"client",
"reth",
"",
""
)
or label_replace(
avg_over_time(
(
(rpc_duration_engine_newPayloadV4_success{instance="geth-mainnet-1:6060",quantile="0.999"} / 1e6) > 0
)[24h:15s]
),
"client",
"geth",
"",
""
)
or label_replace(
avg_over_time(
(
(rpc_duration_engine_newPayloadV4_success{instance="geth-mainnet-1:6060",quantile="0.5"} / 1e6) > 0
)[24h:15s]
),
"client",
"geth",
"",
""
)
run: |
bash .github/scripts/generate_combined_report.sh
- name: Stop Tailscale SSH tunnel
if: always()
run: |
if [[ -f /tmp/ts-ssh.pid ]]; then
kill "$(cat /tmp/ts-ssh.pid)" || true
fi
- name: Save new loc_report.json to cache
if: success()
uses: actions/cache/save@v4
with:
path: tooling/loc/loc_report.json
key: loc-report-${{ github.ref_name }}-${{ github.run_id }}
- name: Post results in summary
run: |
cat tooling/daily_report/daily_report_github.txt >> "$GITHUB_STEP_SUMMARY"
- name: Post results to Slack
env:
SLACK_WEBHOOKS: >
${{ github.event_name == 'schedule' && secrets.ETHREX_GENERAL_SLACK_WEBHOOK
|| (inputs.slack_channel == 'prod' && secrets.ETHREX_GENERAL_SLACK_WEBHOOK)
|| secrets.ETHREX_TEST_SLACK_WEBHOOK
}}
run: |
for webhook in $SLACK_WEBHOOKS; do
bash .github/scripts/publish_performance.sh "$webhook" tooling/daily_report/daily_report_slack.json
done
- name: Post results to Telegram
env:
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TELEGRAM_ETHREX_CHAT_ID: >-
${{ (github.event_name == 'schedule' || inputs.slack_channel == 'prod')
&& secrets.TELEGRAM_ETHREX_CHAT_ID
|| secrets.TELEGRAM_ETHREX_TEST_CHAT_ID
}}
run: |
# For scheduled runs, only post to Telegram on Monday
if [[ "${{ github.event_name }}" == "schedule" ]]; then
day_of_week=$(date -u +%u) # 1=Monday .. 7=Sunday
if [[ "$day_of_week" != "1" ]]; then
echo "Skipping Telegram post (only sent on Monday)"
exit 0
fi
fi
bash .github/scripts/publish_telegram.sh tooling/daily_report/daily_report_telegram.txt