github.com/ethersphere/bee/v2@v2.2.0/.github/workflows/beekeeper.yml (about)

     1  name: Beekeeper
     2  
     3  on:
     4    repository_dispatch:
     5      types: [trigger-beekeeper, beekeeper]
     6    pull_request:
     7      branches:
     8        - "**"
     9  
    10  env:
    11    K3S_VERSION: "v1.22.17+k3s1"
    12    REPLICA: 3
    13    RUN_TYPE: "PR RUN"
    14    SETUP_CONTRACT_IMAGE: "ethersphere/bee-localchain"
    15    SETUP_CONTRACT_IMAGE_TAG: "0.9.1"
    16    BEELOCAL_BRANCH: "main"
    17    BEEKEEPER_BRANCH: "master"
    18    BEEKEEPER_METRICS_ENABLED: false
    19    REACHABILITY_OVERRIDE_PUBLIC: true
    20    BATCHFACTOR_OVERRIDE_PUBLIC: 2
    21    TIMEOUT: 30m
    22    BUCKET_NAME: swarm-beekeeper-artifacts
    23    AWS_ACCESS_KEY_ID: ${{ secrets.DO_AWS_ACCESS_KEY_ID }}
    24    AWS_SECRET_ACCESS_KEY: ${{ secrets.DO_AWS_SECRET_ACCESS_KEY }}
    25    AWS_EC2_METADATA_DISABLED: true
    26    AWS_ENDPOINT: fra1.digitaloceanspaces.com
    27    VERTAG: ${GITHUB_RUN_ID}
    28  jobs:
    29    init:
    30      name: Init
    31      runs-on: ubuntu-latest
    32      outputs:
    33        msg: ${{ steps.commit.outputs.msg }}
    34      steps:
    35        - name: Checkout
    36          uses: actions/checkout@v4
    37          if: github.event.action != 'beekeeper'
    38          with:
    39            fetch-depth: 0
    40        - name: Checkout
    41          uses: actions/checkout@v4
    42          if: github.event.action == 'beekeeper'
    43          with:
    44            fetch-depth: 0
    45            ref: ${{ github.event.client_payload.ref }}
    46        - name: Setup Go
    47          uses: actions/setup-go@v5
    48          with:
    49            cache: false
    50            go-version-file: go.mod
    51        - name: Cache Go Modules
    52          uses: actions/cache@v4
    53          with:
    54            path: |
    55              ~/.cache/go-build
    56              ~/go/pkg/mod
    57            key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
    58            restore-keys: |
    59              ${{ runner.os }}-go-
    60        - name: Get Commit Message
    61          id: commit
    62          run: |
    63            MSG=$(git log --format=%s -n 1 ${{github.event.after}})
    64            echo "msg=${MSG}" >> $GITHUB_OUTPUT
    65        - name: Build - 0
    66          run: |
    67            make binary
    68            mv dist/bee bee-0
    69        - name: Apply patches and build - 1
    70          run: |
    71            patch pkg/api/postage.go .github/patches/postage_api.patch
    72            patch pkg/retrieval/retrieval.go .github/patches/retrieval.patch
    73            make binary
    74            mv dist/bee bee-1
    75        - name: Install beekeeper
    76          run: |
    77            export PATH=$(pwd):$PATH
    78            timeout ${TIMEOUT} make beekeeper BEEKEEPER_INSTALL_DIR=$(pwd)
    79            beekeeper version --log-verbosity 0
    80            mv ~/.beekeeper.yaml .beekeeper.yaml
    81            mv ~/.beekeeper/local.yaml local.yaml
    82        - uses: actions/upload-artifact@v4
    83          with:
    84            name: temp-artifacts
    85            include-hidden-files: true
    86            path: |
    87              Dockerfile.goreleaser
    88              Makefile
    89              bee-0
    90              bee-1
    91              bee-2
    92              beekeeper
    93              local.yaml
    94              .beekeeper.yaml
    95              .github/bin/beekeeper_artifacts.sh
    96            retention-days: 5
    97    beekeeper:
    98      name: Integration tests
    99      runs-on: ubuntu-latest
   100      needs: [init]
   101      steps:
   102        - name: Cache
   103          uses: actions/cache@v4
   104          with:
   105            path: |
   106              /tmp/k3s-${{ env.K3S_VERSION }}
   107            key: k3s-${{ env.K3S_VERSION }}
   108        - name: "Download Artifact"
   109          uses: actions/download-artifact@v4
   110          with:
   111            name: temp-artifacts
   112        - name: Unpack artifacts
   113          run: |
   114            chmod +x bee-1 beekeeper .github/bin/beekeeper_artifacts.sh
   115            mv .beekeeper.yaml ~/.beekeeper.yaml
   116            mkdir ~/.beekeeper && mv local.yaml ~/.beekeeper/local.yaml
   117            mv bee-1 bee
   118            sudo mv beekeeper /usr/local/bin/beekeeper
   119        - name: Prepare local cluster
   120          run: |
   121            timeout ${TIMEOUT} make beelocal OPTS='ci skip-vet' ACTION=prepare
   122        - name: Set kube config
   123          run: |
   124            mkdir -p ~/.kube
   125            cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
   126        - name: Set local cluster
   127          run: |
   128            timeout ${TIMEOUT} make deploylocal BEEKEEPER_CLUSTER=local-dns
   129        - name: Test pingpong
   130          id: pingpong
   131          run: timeout ${TIMEOUT} bash -c 'until beekeeper check --cluster-name local-dns --checks ci-pingpong; do echo "waiting for pingpong..."; sleep .3; done'
   132        - name: Test fullconnectivity
   133          id: fullconnectivity
   134          run: timeout ${TIMEOUT} bash -c 'until beekeeper check --cluster-name local-dns --checks=ci-full-connectivity; do echo "waiting for full connectivity..."; sleep .3; done'
   135        - name: Test settlements
   136          id: settlements
   137          run: timeout ${TIMEOUT} beekeeper check --cluster-name local-dns --checks=ci-settlements
   138        - name: Sleep for time allowance to replenish
   139          run: sleep 2
   140        - name: Test pss
   141          id: pss
   142          run: timeout ${TIMEOUT} beekeeper check --cluster-name local-dns --checks=ci-pss
   143        - name: Test soc
   144          id: soc
   145          run: timeout ${TIMEOUT} beekeeper check --cluster-name local-dns --checks=ci-soc
   146        - name: Test pushsync (chunks)
   147          id: pushsync-chunks-1
   148          run: timeout ${TIMEOUT} beekeeper check --cluster-name local-dns --checks=ci-pushsync-chunks
   149        - name: Test pushsync (light mode chunks)
   150          id: pushsync-chunks-2
   151          run: timeout ${TIMEOUT} beekeeper check --cluster-name local-dns --checks=ci-pushsync-light-chunks
   152        - name: Test retrieval
   153          id: retrieval
   154          run: timeout ${TIMEOUT} beekeeper check --cluster-name local-dns --checks=ci-retrieval
   155        - name: Test manifest
   156          id: manifest
   157          run: timeout ${TIMEOUT} beekeeper check --cluster-name local-dns --checks=ci-manifest
   158        - name: Test postage stamps
   159          id: postage-stamps
   160          run: timeout ${TIMEOUT} beekeeper check --cluster-name local-dns --checks ci-postage
   161        - name: Test staking
   162          id: stake
   163          run: timeout ${TIMEOUT} beekeeper check --cluster-name local-dns --checks ci-stake
   164        - name: Test withdraw
   165          id: withdraw
   166          run: timeout ${TIMEOUT} bash -c 'until beekeeper check --cluster-name local-dns --checks ci-withdraw; do echo "waiting for withdraw..."; sleep .3; done'
   167        - name: Test redundancy
   168          id: redundancy
   169          run: timeout ${TIMEOUT} beekeeper check --cluster-name local-dns --checks ci-redundancy
   170        - name: Test act
   171          id: act
   172          run: timeout ${TIMEOUT} bash -c 'until beekeeper check --cluster-name local-dns --checks ci-act; do echo "waiting for act..."; sleep .3; done'
   173        - name: Collect debug artifacts
   174          if: failure()
   175          run: |
   176            bash .github/bin/beekeeper_artifacts.sh local-dns
   177            export FAILED='no-test'
   178            if ${{ steps.pingpong.outcome=='failure' }}; then FAILED=pingpong; fi
   179            if ${{ steps.fullconnectivity.outcome=='failure' }}; then FAILED=fullconnectivity; fi
   180            if ${{ steps.settlements.outcome=='failure' }}; then FAILED=settlements; fi
   181            if ${{ steps.pss.outcome=='failure' }}; then FAILED=pss; fi
   182            if ${{ steps.soc.outcome=='failure' }}; then FAILED=soc; fi
   183            if ${{ steps.pushsync-chunks-1.outcome=='failure' }}; then FAILED=pushsync-chunks-1; fi
   184            if ${{ steps.pushsync-chunks-2.outcome=='failure' }}; then FAILED=pushsync-chunks-2; fi
   185            if ${{ steps.retrieval.outcome=='failure' }}; then FAILED=retrieval; fi
   186            if ${{ steps.manifest.outcome=='failure' }}; then FAILED=manifest; fi
   187            if ${{ steps.content-availability.outcome=='failure' }}; then FAILED=content-availability; fi
   188            if ${{ steps.act.outcome=='failure' }}; then FAILED=act; fi
   189            curl -sSf -X POST -H "Content-Type: application/json" -d "{\"text\": \"**${RUN_TYPE}** Beekeeper Error\nBranch: \`${{ github.head_ref }}\`\nUser: @${{ github.event.pull_request.user.login }}\nDebugging artifacts: [click](https://$BUCKET_NAME.$AWS_ENDPOINT/artifacts_$VERTAG.tar.gz)\nStep failed: \`${FAILED}\`\"}" https://beehive.ethswarm.org/hooks/${{ secrets.TUNSHELL_KEY }}
   190            echo "Failed test: ${FAILED}"
   191        - name: Create tunshell session for debug
   192          if: failure() && contains(needs.init.outputs.msg, '[debug]')
   193          run: |
   194            KEYS=$(curl -sSf -X POST https://eu.relay.tunshell.com/api/sessions)
   195            curl -sSf -X POST -H "Content-Type: application/json" -d "{\"text\": \"**Integration tests** Beekeeper Debug\nBranch: \`${{ github.head_ref }}\`\nUser: @${{ github.event.pull_request.user.login }}\nDebug shell: \`sh <(curl -sSf https://lets.tunshell.com/init.sh) L $(echo $KEYS | jq -r .peer2_key) \${TUNSHELL_SECRET} eu.relay.tunshell.com\`\"}" https://beehive.ethswarm.org/hooks/${{ secrets.TUNSHELL_KEY }}
   196            echo "Connect to github actions node using"
   197            echo "sh <(curl -sSf https://lets.tunshell.com/init.sh) L $(echo $KEYS | jq -r .peer2_key) \${TUNSHELL_SECRET} eu.relay.tunshell.com"
   198            curl -sSf https://lets.tunshell.com/init.sh | sh /dev/stdin T $(echo $KEYS | jq -r .peer1_key) ${{ secrets.TUNSHELL_SECRET }} eu.relay.tunshell.com
   199        - uses: actions/upload-artifact@v4
   200          if: failure()
   201          with:
   202            name: debug-dump
   203            path: dump/
   204    retag:
   205      name: Retag and Trigger ArgoCD
   206      env:
   207        TIMEOUT: 10m
   208      needs: [beekeeper]
   209      runs-on: ubuntu-latest
   210      steps:
   211        - name: "Download Artifact"
   212          uses: actions/download-artifact@v4
   213          with:
   214            name: temp-artifacts
   215        - name: Unpack artifacts
   216          run: |
   217            chmod +x bee-0
   218            mv bee-0 bee
   219        - name: Build image
   220          run: |
   221            timeout ${TIMEOUT} make beelocal ACTION=build OPTS='ci skip-vet skip-push'
   222        - name: Retag Docker image and push
   223          if: github.ref == 'refs/heads/master' && github.event.action != 'beekeeper' && success()
   224          run: |
   225            docker tag k3d-registry.localhost:5000/ethersphere/bee:latest ethersphere/bee:latest
   226            docker tag k3d-registry.localhost:5000/ethersphere/bee:latest quay.io/ethersphere/bee:latest
   227            printf ${{ secrets.DOCKERHUB_PASSWORD }} | docker login --username ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
   228            printf ${{ secrets.QUAY_PASSWORD }} | docker login --username ${{ secrets.QUAY_USERNAME }} quay.io --password-stdin
   229            docker push ethersphere/bee:latest
   230            docker push quay.io/ethersphere/bee:latest
   231            echo RUN_TYPE="MERGE RUN" >> $GITHUB_ENV
   232        - name: Trigger Bee Factory latest build
   233          if: github.ref == 'refs/heads/master' && github.event.action != 'beekeeper' && success()
   234          uses: peter-evans/repository-dispatch@v2
   235          with:
   236            token: ${{ secrets.GHA_PAT_BASIC }}
   237            repository: ethersphere/bee-factory
   238            event-type: build-images
   239            client-payload: '{"tag": "latest"}'