diff --git a/.github/actions/run-with-gh-env/action.yml b/.github/actions/run-with-gh-env/action.yml new file mode 100644 index 000000000000..21c6affbdc71 --- /dev/null +++ b/.github/actions/run-with-gh-env/action.yml @@ -0,0 +1,33 @@ +name: 'Run a shell command with github env vars set' +description: 'Run the provided command with github env vars set (helpful for enabling monitoring of tmpnet networks)' + +inputs: + run: + description: "the bash command to run" + required: true + repo: + 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_id: + default: ${{ github.job }} + + +runs: + using: composite + steps: + - name: Run command + shell: bash + run: ${{ inputs.run }} + env: + 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 }} diff --git a/.github/actions/start-monitoring-tmpnet-networks/action.yml b/.github/actions/start-monitoring-tmpnet-networks/action.yml new file mode 100644 index 000000000000..c1514a34949b --- /dev/null +++ b/.github/actions/start-monitoring-tmpnet-networks/action.yml @@ -0,0 +1,44 @@ +name: 'Start monitoring tmpnet networks' +description: 'Start collectors for logs and metrics from tmpnet networks' + +inputs: + owner: + description: "the owner the metrics link should filter by" + default: "" + job: + default: ${{ github.job }} + run_id: + default: ${{ github.run_id }} + run_attempt: + default: ${{ github.run_attempt }} + prometheus_id: + required: true + prometheus_password: + required: true + loki_id: + required: true + loki_password: + required: true + +runs: + using: composite + steps: + - name: Start prometheus + shell: bash + run: bash -x ./scripts/run_prometheus.sh + env: + PROMETHEUS_ID: ${{ inputs.prometheus_id }} + PROMETHEUS_PASSWORD: ${{ inputs.prometheus_password }} + - name: Start promtail + 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 + shell: bash + run: .github/actions/start-monitoring-tmpnet-networks/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%7Cava-labs%2Favalanchego&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.owner }} diff --git a/.github/workflows/notify-metrics-availability.sh b/.github/actions/start-monitoring-tmpnet-networks/notify-metrics-availability.sh similarity index 100% rename from .github/workflows/notify-metrics-availability.sh rename to .github/actions/start-monitoring-tmpnet-networks/notify-metrics-availability.sh diff --git a/.github/actions/upload-tmpnet-artifact/action.yml b/.github/actions/upload-tmpnet-artifact/action.yml new file mode 100644 index 000000000000..8912cda11ed2 --- /dev/null +++ b/.github/actions/upload-tmpnet-artifact/action.yml @@ -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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 68ee2585a3b7..08107298d770 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 }} @@ -59,49 +56,25 @@ jobs: - name: Build AvalancheGo Binary shell: bash run: ./scripts/build.sh -r - - name: Start prometheus + - name: Start monitoring tmpnet networks # 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 + uses: ./.github/actions/start-monitoring-tmpnet-networks + with: + owner: avalanchego-e2e + prometheus_id: ${{ secrets.PROMETHEUS_ID }} + prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD }} + loki_id: ${{ secrets.LOKI_ID }} + loki_password: ${{ secrets.LOKI_PASSWORD }} - 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-with-gh-env + with: + run: E2E_SERIAL=1 ./scripts/tests.e2e.sh --delay-network-shutdown - 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: @@ -110,48 +83,24 @@ jobs: - name: Build AvalancheGo Binary shell: bash run: ./scripts/build.sh -r - - name: Start prometheus + - name: Start monitoring tmpnet networks # 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 }} + uses: ./.github/actions/start-monitoring-tmpnet-networks + with: + prometheus_id: ${{ secrets.PROMETHEUS_ID }} + prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD }} + loki_id: ${{ secrets.LOKI_ID }} + loki_password: ${{ secrets.LOKI_PASSWORD }} - 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-with-gh-env + with: + run: E2E_SERIAL=1 ./scripts/tests.e2e.existing.sh --delay-network-shutdown - 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: @@ -160,48 +109,24 @@ jobs: - name: Build AvalancheGo Binary shell: bash run: ./scripts/build.sh - - name: Start prometheus + - name: Start monitoring tmpnet networks # 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 }} + uses: ./.github/actions/start-monitoring-tmpnet-networks + with: + prometheus_id: ${{ secrets.PROMETHEUS_ID }} + prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD }} + loki_id: ${{ secrets.LOKI_ID }} + loki_password: ${{ secrets.LOKI_PASSWORD }} - 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-with-gh-env + with: + run: ./scripts/tests.upgrade.sh - 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: