Skip to content

Commit d857661

Browse files
committed
[ci] Simplify tmpnet monitoring action
Incorporate the following into the action to simplify usage: - Configure network shutdown delay to ensure a final metrics scrape - Save tmpnet dir as a github artifact
1 parent dd79669 commit d857661

File tree

3 files changed

+23
-21
lines changed

3 files changed

+23
-21
lines changed

.github/actions/run-monitored-tmpnet-cmd/action.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ inputs:
77
required: true
88
filter_by_owner:
99
default: ''
10+
artifact_name:
11+
default: 'tmpnet-data'
1012
prometheus_username:
1113
required: true
1214
prometheus_password:
@@ -65,9 +67,15 @@ runs:
6567
shell: bash
6668
run: ${{ inputs.run }}
6769
env:
70+
TMPNET_DELAY_NETWORK_SHUTDOWN: true # Ensure shutdown waits for a final metrics scrape
6871
GH_REPO: ${{ inputs.repository_owner }}/${{ inputs.repository_name }}
6972
GH_WORKFLOW: ${{ inputs.workflow }}
7073
GH_RUN_ID: ${{ inputs.run_id }}
7174
GH_RUN_NUMBER: ${{ inputs.run_number }}
7275
GH_RUN_ATTEMPT: ${{ inputs.run_attempt }}
7376
GH_JOB_ID: ${{ inputs.job }}
77+
- name: Upload tmpnet network dir
78+
uses: ./.github/actions/upload-tmpnet-artifact
79+
if: always()
80+
with:
81+
name: ${{ inputs.artifact_name }}

.github/workflows/ci.yml

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,13 @@ jobs:
6262
- name: Run e2e tests
6363
uses: ./.github/actions/run-monitored-tmpnet-cmd
6464
with:
65-
run: E2E_SERIAL=1 ./scripts/tests.e2e.sh --delay-network-shutdown
65+
run: E2E_SERIAL=1 ./scripts/tests.e2e.sh
66+
artifact_name: e2e-tmpnet-data
6667
filter_by_owner: avalanchego-e2e
6768
prometheus_username: ${{ secrets.PROMETHEUS_ID || '' }}
6869
prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD || '' }}
6970
loki_username: ${{ secrets.LOKI_ID || '' }}
7071
loki_password: ${{ secrets.LOKI_PASSWORD || '' }}
71-
- name: Upload tmpnet network dir
72-
uses: ./.github/actions/upload-tmpnet-artifact
73-
if: always()
74-
with:
75-
name: e2e-tmpnet-data
7672
e2e_existing_network:
7773
runs-on: ubuntu-latest
7874
steps:
@@ -88,16 +84,12 @@ jobs:
8884
- name: Run e2e tests with existing network
8985
uses: ./.github/actions/run-monitored-tmpnet-cmd
9086
with:
91-
run: E2E_SERIAL=1 ./scripts/tests.e2e.existing.sh --delay-network-shutdown
87+
run: E2E_SERIAL=1 ./scripts/tests.e2e.existing.sh
88+
artifact_name: e2e-existing-network-tmpnet-data
9289
prometheus_username: ${{ secrets.PROMETHEUS_ID || '' }}
9390
prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD || '' }}
9491
loki_username: ${{ secrets.LOKI_ID || '' }}
9592
loki_password: ${{ secrets.LOKI_PASSWORD || '' }}
96-
- name: Upload tmpnet network dir
97-
uses: ./.github/actions/upload-tmpnet-artifact
98-
if: always()
99-
with:
100-
name: e2e-existing-network-tmpnet-data
10193
Upgrade:
10294
runs-on: ubuntu-latest
10395
steps:
@@ -114,15 +106,11 @@ jobs:
114106
uses: ./.github/actions/run-monitored-tmpnet-cmd
115107
with:
116108
run: ./scripts/tests.upgrade.sh
109+
artifact_name: upgrade-tmpnet-data
117110
prometheus_username: ${{ secrets.PROMETHEUS_ID || '' }}
118111
prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD || '' }}
119112
loki_username: ${{ secrets.LOKI_ID || '' }}
120113
loki_password: ${{ secrets.LOKI_PASSWORD || '' }}
121-
- name: Upload tmpnet network dir
122-
uses: ./.github/actions/upload-tmpnet-artifact
123-
if: always()
124-
with:
125-
name: upgrade-tmpnet-data
126114
Lint:
127115
runs-on: ubuntu-latest
128116
steps:

tests/fixture/e2e/flags.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,18 @@ import (
1010
"path/filepath"
1111
"time"
1212

13+
"github.com/spf13/cast"
14+
1315
"github.com/ava-labs/avalanchego/tests/fixture/tmpnet"
1416
)
1517

16-
// Ensure that this value takes into account the scrape_interval
17-
// defined in scripts/run_prometheus.sh.
18-
const networkShutdownDelay = 12 * time.Second
18+
const (
19+
// Ensure that this value takes into account the scrape_interval
20+
// defined in scripts/run_prometheus.sh.
21+
networkShutdownDelay = 12 * time.Second
22+
23+
delayNetworkShutdownEnvName = "TMPNET_DELAY_NETWORK_SHUTDOWN"
24+
)
1925

2026
type FlagVars struct {
2127
avalancheGoExecPath string
@@ -143,7 +149,7 @@ func RegisterFlags() *FlagVars {
143149
flag.BoolVar(
144150
&vars.delayNetworkShutdown,
145151
"delay-network-shutdown",
146-
false,
152+
cast.ToBool(GetEnvWithDefault(delayNetworkShutdownEnvName, "false")),
147153
"[optional] whether to delay network shutdown to allow a final metrics scrape.",
148154
)
149155
flag.BoolVar(

0 commit comments

Comments
 (0)