name: On Demand VRFV2 Smoke Test (Ethereum clients)
on:
  workflow_dispatch:
    inputs:
      base64Config:
        description: base64-ed config
        required: true
        type: string 
      test_secrets_override_key:
        description: 'Key to run tests with custom test secrets'
        required: false
        type: string 
        
jobs:
  vrfv2_smoke_test:
    name: VRFV2 Smoke Test with custom EL client client
    environment: integration
    runs-on: ubuntu22.04-8cores-32GB
    permissions:
      checks: write
      pull-requests: write
      id-token: write
      contents: read
    env:
      TEST_LOG_LEVEL: debug
      REF_NAME: ${{ github.head_ref || github.ref_name }}
    steps:      
      - name: Checkout code
        uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
        with:
          fetch-depth: 0    
      - name: Mask base64 config
        run: |
          BASE64_CONFIG_OVERRIDE=$(jq -r '.inputs.base64Config' $GITHUB_EVENT_PATH)
          echo ::add-mask::$BASE64_CONFIG_OVERRIDE
          echo "BASE64_CONFIG_OVERRIDE=$BASE64_CONFIG_OVERRIDE" >> $GITHUB_ENV
      - name: Parse base64 config
        uses: ./.github/actions/setup-parse-base64-config
        with:
          base64Config: ${{ env.BASE64_CONFIG_OVERRIDE }}  
      - name: Send details to Step Summary
        shell: bash
        run: |
          echo "### chainlink image used for this test run :link:" >>$GITHUB_STEP_SUMMARY
          echo "\`${{ env.CHAINLINK_IMAGE }}\`" >>$GITHUB_STEP_SUMMARY
          echo "### chainlink-tests image tag for this test run :ship:" >>$GITHUB_STEP_SUMMARY
          echo "\`${GITHUB_SHA}\`" >>$GITHUB_STEP_SUMMARY
          echo "### Networks on which test was run" >>$GITHUB_STEP_SUMMARY
          echo "\`${{ env.NETWORKS }}\`" >>$GITHUB_STEP_SUMMARY
          echo "### Execution client used" >>$GITHUB_STEP_SUMMARY
          echo "\`${{ env.ETH2_EL_CLIENT }}\`" >>$GITHUB_STEP_SUMMARY          
      - name: Run Tests
        uses: smartcontractkit/chainlink-github-actions/chainlink-testing-framework/run-tests@2967f2287bd3f3ddbac7b476e9568993df01796e # v2.3.27
        with:
          test_command_to_run: cd ./integration-tests && go test -timeout 30m -count=1 -json -run TestVRFv2Basic ./smoke/vrfv2_test.go 2>&1 | tee /tmp/gotest.log | gotestloghelper -ci -singlepackage -hidepassingtests=false -hidepassinglogs
          test_download_vendor_packages_command: cd ./integration-tests && go mod download
          test_secrets_override_base64: ${{ secrets[inputs.test_secrets_override_key] }}
          cl_repo: ${{ env.CHAINLINK_IMAGE }}
          cl_image_tag: ${{ env.CHAINLINK_VERSION }}
          aws_registries: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}
          artifacts_name: vrf-test-logs
          artifacts_location: ./integration-tests/smoke/logs/
          token: ${{ secrets.GITHUB_TOKEN }}
          go_mod_path: ./integration-tests/go.mod
          should_cleanup: false
          QA_AWS_REGION: ${{ secrets.QA_AWS_REGION }}
          QA_AWS_ROLE_TO_ASSUME: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }}          
          QA_KUBECONFIG: ""
          DEFAULT_CHAINLINK_IMAGE: ${{ env.CHAINLINK_IMAGE }}
          DEFAULT_LOKI_TENANT_ID: ${{ secrets.GRAFANA_INTERNAL_TENANT_ID }}
          DEFAULT_LOKI_ENDPOINT: https://${{ secrets.GRAFANA_INTERNAL_HOST }}/loki/api/v1/push
          DEFAULT_LOKI_BASIC_AUTH: ${{ secrets.GRAFANA_INTERNAL_BASIC_AUTH }}
          DEFAULT_GRAFANA_BASE_URL: "http://localhost:8080/primary"
          DEFAULT_GRAFANA_DASHBOARD_URL: "/d/ddf75041-1e39-42af-aa46-361fe4c36e9e/ci-e2e-tests-logs"
          DEFAULT_GRAFANA_BEARER_TOKEN: ${{ secrets.GRAFANA_INTERNAL_URL_SHORTENER_TOKEN }}