feat: Update full test to use tycho-test and test on stream of updates #168
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: | |
| 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})$" | tr '\n' ' ' | sed 's/ *$//') | |
| 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] | |
| steps: | |
| - name: Check if tests are needed | |
| id: should-test | |
| run: | | |
| SUBSTREAMS_CHANGED="${{ needs.detect-changes.outputs.substreams-changed }}" | |
| CHANGED_SUBSTREAMS="${{ needs.detect-changes.outputs.changed-substreams }}" | |
| if [[ "$SUBSTREAMS_CHANGED" == "true" && -n "$CHANGED_SUBSTREAMS" ]]; then | |
| echo "should_run=true" >> $GITHUB_OUTPUT | |
| echo "protocols=$CHANGED_SUBSTREAMS" >> $GITHUB_OUTPUT | |
| else | |
| echo "should_run=false" >> $GITHUB_OUTPUT | |
| echo "No substreams changes detected - skipping tests" | |
| fi | |
| - uses: actions/checkout@v4 | |
| if: steps.should-test.outputs.should_run == 'true' | |
| - name: Run tests for changed substreams | |
| if: steps.should-test.outputs.should_run == 'true' | |
| uses: ./.github/actions/substreams-docker | |
| with: | |
| protocols: ${{ steps.should-test.outputs.protocols }} | |
| - name: Skip tests | |
| if: steps.should-test.outputs.should_run != 'true' | |
| run: echo "✓ No changes detected - skipping tests" | |
| 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 }} |