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

[ci] Simplify tmpnet monitoring action #3736

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
17 changes: 17 additions & 0 deletions .github/actions/install-nix/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: 'Install nix'
description: 'Install nix and populate the store for the repo flake'

inputs:
github_token:
description: "github token to authenticate with to avoid being rate-limited"
default: ${{ github.token }}
required: false

runs:
using: composite
steps:
- uses: cachix/install-nix-action@v30
with:
github_access_token: ${{ inputs.github_token }}
- run: nix develop --command echo "dependencies installed"
shell: bash
18 changes: 16 additions & 2 deletions .github/actions/run-monitored-tmpnet-cmd/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ description: 'Run the provided command in an environment configured to monitor t

inputs:
run:
description: "the bash command to run"
description: "the bash script to run e.g. ./scripts/my-script.sh"
required: true
run_env:
description: 'a string containing env vars for the command e.g. "MY_VAR1=foo MY_VAR2=bar"'
default: ''
filter_by_owner:
default: ''
artifact_prefix:
default: ''
prometheus_username:
required: true
prometheus_password:
Expand Down Expand Up @@ -36,6 +41,9 @@ inputs:
runs:
using: composite
steps:
# Ensure promtail and prometheus are available
- name: Install nix
uses: ./.github/actions/install-nix
- name: Start prometheus
# Only run for the original repo; a forked repo won't have access to the monitoring credentials
if: (inputs.prometheus_username != '')
Expand Down Expand Up @@ -63,11 +71,17 @@ runs:
FILTER_BY_OWNER: ${{ inputs.filter_by_owner }}
- name: Run command
shell: bash
run: ${{ inputs.run }}
run: ${{ inputs.run_env }} ${{ inputs.run }}
env:
TMPNET_DELAY_NETWORK_SHUTDOWN: true # Ensure shutdown waits for a final metrics scrape
GH_REPO: ${{ inputs.repository_owner }}/${{ inputs.repository_name }}
GH_WORKFLOW: ${{ inputs.workflow }}
GH_RUN_ID: ${{ inputs.run_id }}
GH_RUN_NUMBER: ${{ inputs.run_number }}
GH_RUN_ATTEMPT: ${{ inputs.run_attempt }}
GH_JOB_ID: ${{ inputs.job }}
- name: Upload tmpnet network dir
uses: ./.github/actions/upload-tmpnet-artifact
if: always()
with:
name: ${{ inputs.artifact_prefix }}-tmpnet-data
41 changes: 8 additions & 33 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,78 +51,55 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-go-for-project
- uses: cachix/install-nix-action@v30
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
# TODO(marun) Maybe figure out how to use `nix build` somehow i.e. make the default shell double as the default package
- run: nix develop --command echo "dependencies installed"
- name: Build AvalancheGo Binary
shell: bash
run: ./scripts/build.sh -r
- name: Run e2e tests
uses: ./.github/actions/run-monitored-tmpnet-cmd
with:
run: E2E_SERIAL=1 ./scripts/tests.e2e.sh --delay-network-shutdown
run: ./scripts/tests.e2e.sh
run_env: E2E_SERIAL=1
artifact_prefix: e2e
filter_by_owner: avalanchego-e2e
prometheus_username: ${{ secrets.PROMETHEUS_ID || '' }}
prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD || '' }}
loki_username: ${{ secrets.LOKI_ID || '' }}
loki_password: ${{ secrets.LOKI_PASSWORD || '' }}
- name: Upload tmpnet network dir
uses: ./.github/actions/upload-tmpnet-artifact
if: always()
with:
name: e2e-tmpnet-data
e2e_existing_network:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-go-for-project
- uses: cachix/install-nix-action@v30
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- run: nix develop --command echo "dependencies installed"
- name: Build AvalancheGo Binary
shell: bash
run: ./scripts/build.sh -r
- name: Run e2e tests with existing network
uses: ./.github/actions/run-monitored-tmpnet-cmd
with:
run: E2E_SERIAL=1 ./scripts/tests.e2e.existing.sh --delay-network-shutdown
run: ./scripts/tests.e2e.existing.sh
run_env: E2E_SERIAL=1
artifact_prefix: e2e-existing-network
prometheus_username: ${{ secrets.PROMETHEUS_ID || '' }}
prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD || '' }}
loki_username: ${{ secrets.LOKI_ID || '' }}
loki_password: ${{ secrets.LOKI_PASSWORD || '' }}
- name: Upload tmpnet network dir
uses: ./.github/actions/upload-tmpnet-artifact
if: always()
with:
name: e2e-existing-network-tmpnet-data
Upgrade:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-go-for-project
- uses: cachix/install-nix-action@v30
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- run: nix develop --command echo "dependencies installed"
- name: Build AvalancheGo Binary
shell: bash
run: ./scripts/build.sh
- name: Run e2e tests
uses: ./.github/actions/run-monitored-tmpnet-cmd
with:
run: ./scripts/tests.upgrade.sh
artifact_prefix: upgrade
prometheus_username: ${{ secrets.PROMETHEUS_ID || '' }}
prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD || '' }}
loki_username: ${{ secrets.LOKI_ID || '' }}
loki_password: ${{ secrets.LOKI_PASSWORD || '' }}
- name: Upload tmpnet network dir
uses: ./.github/actions/upload-tmpnet-artifact
if: always()
with:
name: upgrade-tmpnet-data
Lint:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -243,9 +220,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-go-for-project
- uses: cachix/install-nix-action@v30
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: ./.github/actions/install-nix
- run: nix develop --command echo "dependencies installed"
- name: Run e2e tests
shell: bash
Expand Down
14 changes: 10 additions & 4 deletions tests/fixture/e2e/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@ import (
"path/filepath"
"time"

"github.com/spf13/cast"

"github.com/ava-labs/avalanchego/tests/fixture/tmpnet"
)

// Ensure that this value takes into account the scrape_interval
// defined in scripts/run_prometheus.sh.
const networkShutdownDelay = 12 * time.Second
const (
// Ensure that this value takes into account the scrape_interval
// defined in scripts/run_prometheus.sh.
networkShutdownDelay = 12 * time.Second

delayNetworkShutdownEnvName = "TMPNET_DELAY_NETWORK_SHUTDOWN"
)

type FlagVars struct {
avalancheGoExecPath string
Expand Down Expand Up @@ -143,7 +149,7 @@ func RegisterFlags() *FlagVars {
flag.BoolVar(
&vars.delayNetworkShutdown,
"delay-network-shutdown",
false,
cast.ToBool(GetEnvWithDefault(delayNetworkShutdownEnvName, "false")),
"[optional] whether to delay network shutdown to allow a final metrics scrape.",
)
flag.BoolVar(
Expand Down
Loading