fix: add cooldown mechanism for event triggers with 5 min default value #845
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: Run Unit Tests | |
| on: | |
| pull_request: | |
| # Only run tests when PR to staging of main and these files are changed | |
| branches: | |
| - main | |
| - staging | |
| paths: | |
| - "core/**" | |
| - "pkg/**" | |
| - "aggregator/**" | |
| - "operator/**" | |
| - "model/**" | |
| - "cmd/**" | |
| - "version/**" | |
| - "config/**" | |
| - "go.mod" | |
| - "go.sum" | |
| - "!scripts/**" | |
| - "!**.md" | |
| - "!.github/**" | |
| - "!docs/**" | |
| workflow_dispatch: | |
| inputs: | |
| branch: | |
| description: "Branch to run tests against" | |
| required: true | |
| type: string | |
| force_run: | |
| description: "Force run tests even if only scripts changed" | |
| required: false | |
| type: boolean | |
| default: false | |
| jobs: | |
| check-changes: | |
| name: Check Changed Files | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should_run: ${{ steps.check.outputs.should_run }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 # Fetch all history for comparing changes | |
| ref: ${{ github.event.inputs.branch || github.ref }} | |
| - name: Check if relevant files changed | |
| id: check | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ github.event.inputs.force_run }}" = "true" ]; then | |
| echo "should_run=true" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| # Get the base branch for comparison | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| BASE_BRANCH="${{ github.base_ref }}" | |
| else | |
| BASE_BRANCH="main" # Default to main for manual runs | |
| fi | |
| # Get list of changed files | |
| CHANGED_FILES=$(git diff --name-only origin/$BASE_BRANCH...HEAD) | |
| # Check if any changes are in relevant directories | |
| RELEVANT_CHANGES=$(echo "$CHANGED_FILES" | grep -E '\.go$|go\.mod|go\.sum|^core/|^pkg/|^aggregator/|^operator/|^model/|^cmd/|^version/|^config/') | |
| if [ -n "$RELEVANT_CHANGES" ]; then | |
| echo "should_run=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "should_run=false" >> $GITHUB_OUTPUT | |
| echo "No relevant changes found. Skipping tests." | |
| fi | |
| lint: | |
| name: Lint | |
| needs: check-changes | |
| if: needs.check-changes.outputs.should_run == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| ref: ${{ github.event.inputs.branch || github.ref }} | |
| - name: Setup test configuration | |
| uses: ./.github/actions/setup-test-config | |
| with: | |
| chain-endpoint: ${{ vars.CHAIN_ENDPOINT }} | |
| bundler-rpc: ${{ vars.BUNDLER_RPC }} | |
| tenderly-account: ${{ vars.TENDERLY_ACCOUNT }} | |
| tenderly-project: ${{ vars.TENDERLY_PROJECT }} | |
| controller-private-key: ${{ secrets.CONTROLLER_PRIVATE_KEY }} | |
| tenderly-access-key: ${{ secrets.TENDERLY_ACCESS_KEY }} | |
| owner-eoa: ${{ vars.OWNER_EOA }} | |
| moralis-api-key: ${{ secrets.MORALIS_API_KEY }} | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: "1.24" | |
| - name: Cache golangci-lint binary | |
| uses: actions/cache@v3 | |
| with: | |
| path: $(go env GOPATH)/bin/golangci-lint | |
| key: golangci-lint-v1.55.2 | |
| # - name: Install golangci-lint | |
| # run: | | |
| # if [ ! -f "$(go env GOPATH)/bin/golangci-lint" ]; then | |
| # curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2 | |
| # fi | |
| # - name: Run golangci-lint | |
| # run: $(go env GOPATH)/bin/golangci-lint run ./... | |
| test: | |
| environment: Test | |
| name: Unit Test | |
| needs: check-changes | |
| if: needs.check-changes.outputs.should_run == 'true' | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| test: | |
| - aggregator | |
| - core/taskengine | |
| - core/taskengine/trigger | |
| - core/taskengine/macros | |
| - pkg/timekeeper | |
| - pkg/graphql | |
| - pkg/byte4 | |
| - pkg/erc4337/preset | |
| - core/backup | |
| - core/migrator | |
| - migrations | |
| - operator | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| ref: ${{ github.event.inputs.branch || github.ref }} | |
| - name: Setup test configuration | |
| uses: ./.github/actions/setup-test-config | |
| with: | |
| chain-endpoint: ${{ vars.CHAIN_ENDPOINT }} | |
| bundler-rpc: ${{ vars.BUNDLER_RPC }} | |
| tenderly-account: ${{ vars.TENDERLY_ACCOUNT }} | |
| tenderly-project: ${{ vars.TENDERLY_PROJECT }} | |
| controller-private-key: ${{ secrets.CONTROLLER_PRIVATE_KEY }} | |
| tenderly-access-key: ${{ secrets.TENDERLY_ACCESS_KEY }} | |
| owner-eoa: ${{ vars.OWNER_EOA }} | |
| moralis-api-key: ${{ secrets.MORALIS_API_KEY }} | |
| - name: Run Go test | |
| run: | | |
| cd ./${{ matrix.test }} | |
| go test . -v -short |