Skip to content

Commit

Permalink
[ci] Simplify ci monitoring with custom actions
Browse files Browse the repository at this point in the history
  • Loading branch information
marun committed Jul 9, 2024
1 parent 2af3890 commit 2144e36
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 115 deletions.
72 changes: 72 additions & 0 deletions .github/actions/run-monitored-tmpnet-cmd/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: 'Run the provided command in an environment configured to monitor tmpnet networks'
description: 'Run the provided command in an environment configured to monitor tmpnet networks'

inputs:
run:
description: "the bash command to run"
required: true
url_encoded_repo:
# TODO(marun) Process github.repository into this url-encoded form
default: 'ava-labs%2Favalanchego'
filter_by_owner:
default: ''
prometheus_id:
required: true
prometheus_password:
required: true
loki_id:
required: true
loki_password:
required: true
# The following inputs need never be provided by the caller. They
# default to context values that the action's steps are unable to
# acccess directly.
repository:
default: ${{ github.repository }}
workflow:
default: ${{ github.workflow }}
run_id:
default: ${{ github.run_id }}
run_number:
default: ${{ github.run_number }}
run_attempt:
default: ${{ github.run_attempt }}
job:
default: ${{ github.job }}

runs:
using: composite
steps:
- name: Start prometheus
# Only run for the original repo; a forked repo won't have access to the monitoring credentials
if: (inputs.prometheus_id != '')
shell: bash
run: bash -x ./scripts/run_prometheus.sh
env:
PROMETHEUS_ID: ${{ inputs.prometheus_id }}
PROMETHEUS_PASSWORD: ${{ inputs.prometheus_password }}
- name: Start promtail
if: (inputs.prometheus_id != '')
shell: bash
run: bash -x ./scripts/run_promtail.sh
env:
LOKI_ID: ${{ inputs.loki_id }}
LOKI_PASSWORD: ${{ inputs.loki_password }}
- name: Notify of metrics availability
if: (inputs.prometheus_id != '')
shell: bash
run: .github/actions/run-monitored-tmpnet-cmd/notify-metrics-availability.sh
env:
GRAFANA_URL: https://grafana-experimental.avax-dev.network/d/kBQpRdWnk/avalanche-main-dashboard?orgId=1&refresh=10s&var-filter=is_ephemeral_node%7C%3D%7Cfalse&var-filter=gh_repo%7C%3D%7C${{ inputs.url_encoded_repo }}&var-filter=gh_run_id%7C%3D%7C${{ inputs.run_id }}&var-filter=gh_run_attempt%7C%3D%7C${{ inputs.run_attempt }}
GH_JOB_ID: ${{ inputs.job }}
FILTER_BY_OWNER: ${{ inputs.filter_by_owner }}
- name: Run command
shell: bash
run: ${{ inputs.run }}
env:
GH_REPO: ${{ inputs.repository }}
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 }}
20 changes: 20 additions & 0 deletions .github/actions/upload-tmpnet-artifact/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: 'Upload an artifact of tmpnet data'
description: 'Upload an artifact of data in the ~/.tmpnet path'

inputs:
name:
description: "the name of the artifact to upload"
required: true

runs:
using: composite
steps:
- name: Upload tmpnet data
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.name }}
path: |
~/.tmpnet/networks
~/.tmpnet/prometheus/prometheus.log
~/.tmpnet/promtail/promtail.log
if-no-files-found: error
140 changes: 25 additions & 115 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
grafana_url: https://grafana-experimental.avax-dev.network/d/kBQpRdWnk/avalanche-main-dashboard?orgId=1&refresh=10s&var-filter=is_ephemeral_node%7C%3D%7Cfalse&var-filter=gh_repo%7C%3D%7Cava-labs%2Favalanchego&var-filter=gh_run_id%7C%3D%7C${{ github.run_id }}&var-filter=gh_run_attempt%7C%3D%7C${{ github.run_attempt }}

jobs:
Unit:
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -59,49 +56,19 @@ jobs:
- name: Build AvalancheGo Binary
shell: bash
run: ./scripts/build.sh -r
- name: Start prometheus
# Only run for the original repo; a forked repo won't have access to the monitoring credentials
if: (github.event_name != 'pull_request') || (github.event.pull_request.head.repo.full_name == github.repository)
shell: bash
run: bash -x ./scripts/run_prometheus.sh
env:
PROMETHEUS_ID: ${{ secrets.PROMETHEUS_ID }}
PROMETHEUS_PASSWORD: ${{ secrets.PROMETHEUS_PASSWORD }}
- name: Start promtail
if: (github.event_name != 'pull_request') || (github.event.pull_request.head.repo.full_name == github.repository)
shell: bash
run: bash -x ./scripts/run_promtail.sh
env:
LOKI_ID: ${{ secrets.LOKI_ID }}
LOKI_PASSWORD: ${{ secrets.LOKI_PASSWORD }}
- name: Notify of metrics availability
if: (github.event_name != 'pull_request') || (github.event.pull_request.head.repo.full_name == github.repository)
shell: bash
run: .github/workflows/notify-metrics-availability.sh
env:
GRAFANA_URL: ${{ env.grafana_url }}
GH_JOB_ID: ${{ github.job }}
FILTER_BY_OWNER: avalanchego-e2e
- name: Run e2e tests
shell: bash
run: E2E_SERIAL=1 ./scripts/tests.e2e.sh --delay-network-shutdown
env:
GH_REPO: ${{ github.repository }}
GH_WORKFLOW: ${{ github.workflow }}
GH_RUN_ID: ${{ github.run_id }}
GH_RUN_NUMBER: ${{ github.run_number }}
GH_RUN_ATTEMPT: ${{ github.run_attempt }}
GH_JOB_ID: ${{ github.job }}
uses: ./.github/actions/run-monitored-tmpnet-cmd
with:
run: E2E_SERIAL=1 ./scripts/tests.e2e.sh --delay-network-shutdown
prometheus_id: ${{ secrets.PROMETHEUS_ID || '' }}
prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD || '' }}
loki_id: ${{ secrets.LOKI_ID || '' }}
loki_password: ${{ secrets.LOKI_PASSWORD || '' }}
- name: Upload tmpnet network dir
uses: actions/upload-artifact@v4
uses: ./.github/actions/upload-tmpnet-artifact
if: always()
with:
name: e2e-tmpnet-data
path: |
~/.tmpnet/networks
~/.tmpnet/prometheus/prometheus.log
~/.tmpnet/promtail/promtail.log
if-no-files-found: error
e2e_existing_network:
runs-on: ubuntu-latest
steps:
Expand All @@ -110,48 +77,19 @@ jobs:
- name: Build AvalancheGo Binary
shell: bash
run: ./scripts/build.sh -r
- name: Start prometheus
# Only run for the original repo; a forked repo won't have access to the monitoring credentials
if: (github.event_name != 'pull_request') || (github.event.pull_request.head.repo.full_name == github.repository)
shell: bash
run: bash -x ./scripts/run_prometheus.sh
env:
PROMETHEUS_ID: ${{ secrets.PROMETHEUS_ID }}
PROMETHEUS_PASSWORD: ${{ secrets.PROMETHEUS_PASSWORD }}
- name: Start promtail
if: (github.event_name != 'pull_request') || (github.event.pull_request.head.repo.full_name == github.repository)
shell: bash
run: bash -x ./scripts/run_promtail.sh
env:
LOKI_ID: ${{ secrets.LOKI_ID }}
LOKI_PASSWORD: ${{ secrets.LOKI_PASSWORD }}
- name: Notify of metrics availability
if: (github.event_name != 'pull_request') || (github.event.pull_request.head.repo.full_name == github.repository)
shell: bash
run: .github/workflows/notify-metrics-availability.sh
env:
GRAFANA_URL: ${{ env.grafana_url }}
GH_JOB_ID: ${{ github.job }}
- name: Run e2e tests with existing network
shell: bash
run: E2E_SERIAL=1 ./scripts/tests.e2e.existing.sh --delay-network-shutdown
env:
GH_REPO: ${{ github.repository }}
GH_WORKFLOW: ${{ github.workflow }}
GH_RUN_ID: ${{ github.run_id }}
GH_RUN_NUMBER: ${{ github.run_number }}
GH_RUN_ATTEMPT: ${{ github.run_attempt }}
GH_JOB_ID: ${{ github.job }}
uses: ./.github/actions/run-monitored-tmpnet-cmd
with:
run: E2E_SERIAL=1 ./scripts/tests.e2e.existing.sh --delay-network-shutdown
prometheus_id: ${{ secrets.PROMETHEUS_ID || '' }}
prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD || '' }}
loki_id: ${{ secrets.LOKI_ID || '' }}
loki_password: ${{ secrets.LOKI_PASSWORD || '' }}
- name: Upload tmpnet network dir
uses: actions/upload-artifact@v4
uses: ./.github/actions/upload-tmpnet-artifact
if: always()
with:
name: e2e-existing-network-tmpnet-data
path: |
~/.tmpnet/networks
~/.tmpnet/prometheus/prometheus.log
~/.tmpnet/promtail/promtail.log
if-no-files-found: error
Upgrade:
runs-on: ubuntu-latest
steps:
Expand All @@ -160,48 +98,20 @@ jobs:
- name: Build AvalancheGo Binary
shell: bash
run: ./scripts/build.sh
- name: Start prometheus
# Only run for the original repo; a forked repo won't have access to the monitoring credentials
if: (github.event_name != 'pull_request') || (github.event.pull_request.head.repo.full_name == github.repository)
shell: bash
run: bash -x ./scripts/run_prometheus.sh
env:
PROMETHEUS_ID: ${{ secrets.PROMETHEUS_ID }}
PROMETHEUS_PASSWORD: ${{ secrets.PROMETHEUS_PASSWORD }}
- name: Start promtail
if: (github.event_name != 'pull_request') || (github.event.pull_request.head.repo.full_name == github.repository)
shell: bash
run: bash -x ./scripts/run_promtail.sh
env:
LOKI_ID: ${{ secrets.LOKI_ID }}
LOKI_PASSWORD: ${{ secrets.LOKI_PASSWORD }}
- name: Notify of metrics availability
if: (github.event_name != 'pull_request') || (github.event.pull_request.head.repo.full_name == github.repository)
shell: bash
run: .github/workflows/notify-metrics-availability.sh
env:
GRAFANA_URL: ${{ env.grafana_url }}
GH_JOB_ID: ${{ github.job }}
- name: Run e2e tests
shell: bash
run: ./scripts/tests.upgrade.sh
env:
GH_REPO: ${{ github.repository }}
GH_WORKFLOW: ${{ github.workflow }}
GH_RUN_ID: ${{ github.run_id }}
GH_RUN_NUMBER: ${{ github.run_number }}
GH_RUN_ATTEMPT: ${{ github.run_attempt }}
GH_JOB_ID: ${{ github.job }}
uses: ./.github/actions/run-monitored-tmpnet-cmd
with:
run: ./scripts/tests.upgrade.sh
filter_by_owner: avalanchego-e2e
prometheus_id: ${{ secrets.PROMETHEUS_ID || '' }}
prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD || '' }}
loki_id: ${{ secrets.LOKI_ID || '' }}
loki_password: ${{ secrets.LOKI_PASSWORD || '' }}
- name: Upload tmpnet network dir
uses: actions/upload-artifact@v4
uses: ./.github/actions/upload-tmpnet-artifact
if: always()
with:
name: upgrade-tmpnet-data
path: |
~/.tmpnet/networks
~/.tmpnet/prometheus/prometheus.log
~/.tmpnet/promtail/promtail.log
if-no-files-found: error
Lint:
runs-on: ubuntu-latest
steps:
Expand Down

0 comments on commit 2144e36

Please sign in to comment.