github.com/0chain/gosdk@v1.17.11/.github/workflows/tests.yml (about)

     1  name: Tests
     2  
     3  concurrency:
     4    group: "${{ github.ref }}"
     5    cancel-in-progress: true
     6  
     7  on:
     8    push:
     9      branches: [ master, staging, sprint* ]
    10    pull_request:
    11    workflow_dispatch:
    12  
    13  env:
    14    ACTIONS_ALLOW_UNSECURE_COMMANDS: true
    15  
    16  jobs:
    17    golangci:
    18      name: "lint"
    19      runs-on: [ arc-runner ]
    20      steps:
    21        - name: Install Packages
    22          run: |
    23            sudo apt update -y
    24            sudo apt -y install build-essential nghttp2 libnghttp2-dev libssl-dev wget
    25  
    26        - name: Set up Go 1.x
    27          uses: actions/setup-go@v3
    28          with:
    29            go-version: 1.21.5
    30  
    31        - uses: actions/checkout@v3
    32  
    33        - name: golangci-lint
    34          uses: golangci/golangci-lint-action@v3
    35          with:
    36            version: v1.57.1
    37            skip-build-cache: true
    38            skip-pkg-cache: true
    39            only-new-issues: true
    40  
    41    go-test:
    42      runs-on: [ arc-runner ]
    43      steps:
    44        - uses: actions/checkout@v2
    45  
    46        - name: Install Packages
    47          run: |
    48            sudo apt update -y
    49            sudo apt -y install build-essential nghttp2 libnghttp2-dev libssl-dev wget
    50  
    51        - name: Set up Go 1.x
    52          uses: actions/setup-go@v3
    53          with:
    54            go-version: 1.21.5
    55  
    56        - name: Install deps
    57          run: |
    58            sudo apt-get update -y && sudo apt-get install build-essential wget containerd docker.io -y
    59  
    60        - name: Run Unit Test
    61          run: make gosdk-test
    62  
    63    system-test:
    64      needs: go-test
    65      runs-on: [ tests-suite ]
    66      steps:
    67        - name: "Get current PR"
    68          uses: jwalton/gh-find-current-pr@v1
    69          id: findPr
    70          with:
    71            github-token: ${{ github.token }}
    72  
    73        - name: "Set PR status as pending"
    74          uses: 0chain/actions/set-pr-status@master
    75          if: steps.findPr.outputs.number
    76          with:
    77            pr_number: ${{ steps.findPr.outputs.pr }}
    78            description: "System tests running with default config..."
    79            state: "pending"
    80            repository: ${{ github.repository }}
    81            status_name: "0Chain System Tests"
    82            target_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
    83            github_token: ${{ github.token }}
    84  
    85        - name: "Setup"
    86          run: |
    87            echo "CURRENT_BRANCH_HEAD=$(echo $(([ -z '${{ github.event.pull_request.head.sha }}' ] && echo  $GITHUB_SHA) || echo '${{ github.event.pull_request.head.sha }}'))" >> $GITHUB_ENV
    88            echo "NETWORK_URL=$(echo dev-${RUNNER_NAME:(-1)}.devnet-0chain.net)" >> $GITHUB_ENV
    89            echo "RUNNER_NUMBER=${RUNNER_NAME:(-1)}" >> $GITHUB_ENV
    90  
    91        - name: 'Setup jq'
    92          uses: dcarbone/install-jq-action@v2.1.0
    93          with:
    94              version: '1.7'
    95              force: 'false'
    96                  
    97        - name: "Create Tenderly virtual testnet"
    98          run: |
    99            echo "TENDERLY_CREATION_INFO=$(curl -X POST \
   100             -H "x-access-key: ${{ secrets.TENDERLY_SECRET }}" \
   101             -H "Content-Type: application/json" \
   102             -d '{"slug":"mainnet-dev-${{ env.RUNNER_NUMBER }}-${{ github.run_id }}","displayName":"mainnet-dev-${{ env.RUNNER_NUMBER }}-${{ github.run_id }}","description":"","visibility":"TEAM","tags":{"purpose":"development"},"networkConfig":{"networkId":"1","blockNumber":"18512782","chainConfig":{"chainId":"1"},"baseFeePerGas":"1"},"explorerConfig":{"enabled":false,"verificationVisibility":"bytecode"},"syncState":false}' \
   103             https://api.tenderly.co/api/v1/account/zus_network/project/project/testnet/container)" >> $GITHUB_ENV
   104  
   105        - name: "Parse Tenderly virtual testnet creation transaction result"
   106          run: |
   107            echo "TENDERLY_VIRTUAL_TESTNET_ID=$(echo '${{ env.TENDERLY_CREATION_INFO }}' | jq -r '.container.id')" >> $GITHUB_ENV
   108            echo "TENDERLY_VIRTUAL_TESTNET_RPC_ID=$(echo '${{ env.TENDERLY_CREATION_INFO }}' | jq -r '.container.connectivityConfig.endpoints[0].id')" >> $GITHUB_ENV
   109  
   110        - name: "Deploy 0Chain"
   111          uses: 0chain/actions/deploy-0chain@master
   112          with:
   113            repo_snapshots_branch: "<CURRENT BRANCH WITH FALLBACK TO CURRENT_SPRINT>"
   114            kube_config: ${{ secrets[format('DEV{0}KC', env.RUNNER_NUMBER)] }}
   115            teardown_condition: "TESTS_PASSED"
   116            custom_go_sdk_version: ${{ env.CURRENT_BRANCH_HEAD }}
   117            SUBGRAPH_API_URL: ${{ secrets.SUBGRAPH_API_URL }}
   118            TENDERLY_VIRTUAL_TESTNET_RPC_ID: ${{ env.TENDERLY_VIRTUAL_TESTNET_RPC_ID }}
   119            graphnode_sc: ${{ secrets.GRAPHNODE_SC }}
   120            graphnode_network: ${{ secrets.GRAPHNODE_NETWORK }}
   121            graphnode_ethereum_node_url: https://virtual.mainnet.rpc.tenderly.co/${{ env.TENDERLY_VIRTUAL_TESTNET_RPC_ID }}
   122            svc_account_secret: ${{ secrets.SVC_ACCOUNT_SECRET }}
   123  
   124        - name: "Run System tests"
   125          uses: 0chain/actions/run-system-tests@master
   126          with:
   127            repo_snapshots_branch: "<CURRENT BRANCH WITH FALLBACK TO CURRENT_SPRINT>"
   128            custom_go_sdk_version: ${{ env.CURRENT_BRANCH_HEAD }}
   129            network: ${{ env.NETWORK_URL }}
   130            svc_account_secret: ${{ secrets.SVC_ACCOUNT_SECRET }}
   131            deploy_report_page: false
   132            archive_results: true
   133            run_flaky_tests: false
   134            retry_failures: true
   135            run_frontend_tests: true
   136            run_smoke_tests: ${{ github.ref != 'refs/heads/staging' && github.base_ref != 'staging' && github.ref != 'refs/heads/master' && github.base_ref != 'master' }}
   137            TENDERLY_VIRTUAL_TESTNET_RPC_ID: ${{ env.TENDERLY_VIRTUAL_TESTNET_RPC_ID }}
   138            DEVOPS_CHANNEL_WEBHOOK_URL: ${{ secrets.DEVOPS_CHANNEL_WEBHOOK_URL }}
   139            S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
   140            S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }}
   141  
   142        - name: "Remove Tenderly virtual testnet"
   143          if: always()
   144          run: |
   145            curl -X DELETE \
   146              -H "x-access-key: ${{ secrets.TENDERLY_SECRET }}" \
   147              -H "Content-Type: application/json" \
   148              https://api.tenderly.co/api/v1/account/zus_network/project/project/testnet/container/${{ env.TENDERLY_VIRTUAL_TESTNET_ID }}
   149  
   150        - name: "Set PR status as ${{ job.status }}"
   151          if: ${{ (success() || failure()) && steps.findPr.outputs.number }}
   152          uses: 0chain/actions/set-pr-status@master
   153          with:
   154            pr_number: ${{ steps.findPr.outputs.pr }}
   155            description: "System tests with default config ${{ job.status }}"
   156            state: ${{ job.status }}
   157            repository: ${{ github.repository }}
   158            status_name: "0Chain System Tests"
   159            target_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
   160            github_token: ${{ github.token }}
   161  
   162    wasm-test:
   163      runs-on: [self-hosted, build]
   164      env:
   165        GOOS: js
   166        GOARCH: wasm
   167      steps:
   168        - uses: actions/checkout@v2
   169  
   170        - name: Set up Go 1.x
   171          uses: actions/setup-go@v3
   172          with:
   173            go-version: 1.21.5
   174        
   175        - uses: actions/setup-node@v2
   176          with:
   177            node-version: 20.11.1
   178  
   179        - name: Setup PATH for wasm
   180          run: echo "${{env.GOROOT}}/misc/wasm" >> $GITHUB_PATH
   181  
   182        - name: Install deps
   183          run: |
   184            # codename=$(lsb_release -c | awk '{print $2}')
   185            # echo "deb http://mirror.genesisadaptive.com/ubuntu/ $codename main" > ./gitaction.list
   186            # echo "deb http://mirror.math.princeton.edu/pub/ubuntu/ $codename main" ./gitaction.list
   187            # echo "deb http://mirror.pit.teraswitch.com/ubuntu/ $codename main" >> ./gitaction.list
   188            # sudo mv -f ./gitaction.list /etc/apt/sources.list.d/
   189  
   190            sudo apt-get update -y && sudo apt-get install build-essential wget -y
   191  
   192        - name: Install herumi's libraries
   193          run: sudo make install-herumi-ubuntu
   194  
   195        - name: Run wasm-test
   196          run: LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH make wasm-test
   197