test: add ci workflow for substreams tests

This commit is contained in:
adrian
2025-09-10 11:52:16 +02:00
committed by Adrian Benavides
parent 183c034204
commit e1d0c58e64
151 changed files with 154 additions and 151 deletions

View File

@@ -0,0 +1,49 @@
name: Build Docker Images
description: Build Docker images
inputs:
protocols:
required: true
description: Protocols to test
runs:
using: "composite"
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build db image
run: |
docker buildx build \
--cache-from type=local,src=/tmp/.buildx-cache \
--cache-to type=local,dest=/tmp/.buildx-cache \
-f protocol-testing/postgres.Dockerfile \
-t protocol-testing-db:latest \
--load .
shell: bash
- name: Build test-runner image
run: |
docker buildx build \
--cache-from type=local,src=/tmp/.buildx-cache \
--cache-to type=local,dest=/tmp/.buildx-cache \
-f protocol-testing/run.Dockerfile \
-t protocol-testing-test-runner:latest \
--load .
shell: bash
- name: Run protocol tests
env:
PROTOCOLS: ${{ inputs.protocols }}
RPC_URL: ${{ env.RPC_URL }}
SUBSTREAMS_API_TOKEN: ${{ env.SUBSTREAMS_API_TOKEN }}
run: |
docker compose up --abort-on-container-exit --exit-code-from test-runner
shell: bash
working-directory: protocol-testing

90
.github/workflows/substreams.tests.yaml vendored Normal file
View File

@@ -0,0 +1,90 @@
name: Substreams Tests
env:
RPC_URL: ${{ secrets.RPC_URL }}
SUBSTREAMS_API_TOKEN: ${{ secrets.SUBSTREAMS_API_TOKEN }}
AUTH_API_KEY: ${{ secrets.AUTH_API_KEY }}
EXCLUDED_SUBSTREAMS: target|crates|ethereum-template-factory|ethereum-template-singleton
on:
workflow_dispatch:
pull_request:
paths:
- 'substreams/**'
jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
protocol-testing-changed: ${{ steps.protocol-testing-files-changed.outputs.any_changed }}
substreams-changed: ${{ steps.substreams-files-changed.outputs.any_changed }}
all-substreams: ${{ steps.all_substreams.outputs.all_substreams }}
changed-substreams: ${{ steps.changes.outputs.changed_substreams }}
steps:
- uses: actions/checkout@v4
- name: Check if any files changed under protocol-testing
id: protocol-testing-files-changed
uses: tj-actions/changed-files@v35
with:
files: protocol-testing/**
- name: Check if any files changed under substreams
id: substreams-files-changed
uses: tj-actions/changed-files@v35
with:
files: substreams/**
- name: Get all substreams folders
id: all_substreams
run: |
FOLDERS=$(find substreams -mindepth 1 -maxdepth 1 -type d \
-exec basename {} \; | sort | \
grep -v -E "^(${EXCLUDED_SUBSTREAMS})$" | \
tr '\n' ' ')
if [ -z "$FOLDERS" ]; then
echo "No substreams folders found"
else
echo "Substreams folders: $FOLDERS"
fi
echo "all_substreams=$FOLDERS" >> $GITHUB_OUTPUT
- name: Fetch full git history
if: steps.substreams-files-changed.outputs.any_changed == 'true'
run: git fetch --unshallow || true
- name: Get changed substreams folders
id: changes
if: steps.substreams-files-changed.outputs.any_changed == 'true'
run: |
CHANGED=$(git diff --name-only origin/main ${{ github.sha }} | \
grep '^substreams/' | awk -F'/' '{print $2}' | sort -u | \
grep -v -E "^(${EXCLUDED_SUBSTREAMS})$")
if [ -z "$CHANGED" ]; then
echo "No changed substreams"
else
echo "Changed substreams: $CHANGED"
fi
echo "changed_substreams=$CHANGED" >> $GITHUB_OUTPUT
test-changed:
runs-on: ubuntu-latest
needs: [detect-changes]
if: needs.detect-changes.outputs.substreams-changed == 'true' && needs.detect-changes.outputs.changed-substreams != ''
steps:
- uses: actions/checkout@v4
- name: Run tests for changed substreams
uses: ./.github/actions/substreams-docker
with:
protocols: ${{ needs.detect-changes.outputs.changed-substreams }}
test-all:
runs-on: ubuntu-latest
needs: [detect-changes]
if: github.event_name == 'workflow_dispatch'
steps:
- uses: actions/checkout@v4
- name: Run all protocol-testing tests
uses: ./.github/actions/substreams-docker
with:
protocols: ${{ needs.detect-changes.outputs.all-substreams }}