-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
271 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
name: Beekeeper | ||
|
||
on: | ||
repository_dispatch: | ||
types: [trigger-beekeeper, beekeeper] | ||
pull_request: | ||
branches: | ||
- '**' | ||
|
||
jobs: | ||
beekeeper: | ||
name: Infra tests | ||
env: | ||
REPLICA: 3 | ||
RUN_TYPE: "PR RUN" | ||
SETUP_CONTRACT_IMAGE_TAG: "0.2.0" | ||
BEEKEEPER_BRANCH: "master" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: '1.17' | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
if: github.event.action != 'beekeeper' | ||
with: | ||
fetch-depth: 1 | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
if: github.event.action == 'beekeeper' | ||
with: | ||
ref: ${{ github.event.client_payload.ref }} | ||
fetch-depth: 1 | ||
- name: Cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
/tmp/k3s-v1.19.5+k3s2 | ||
key: k3s-v1.19.5+k3s2 | ||
- name: Cache Go modules | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-build-${{ hashFiles('**/go.sum') }} | ||
- name: Apply patches | ||
run: | | ||
patch pkg/postage/batchstore/reserve.go .github/patches/postagereserve.patch | ||
patch pkg/postage/postagecontract/contract.go .github/patches/postagecontract.patch | ||
patch pkg/postage/listener/listener.go .github/patches/listener.patch | ||
patch pkg/postage/service.go .github/patches/postageservice.patch | ||
- name: Prepare testing cluster (Node connection and clef enabled) | ||
run: | | ||
printf ${{ secrets.CR_PAT }} | docker login ghcr.io -u bee-worker --password-stdin | ||
make beekeeper BEEKEEPER_INSTALL_DIR=/usr/local/bin BEEKEEPER_USE_SUDO=true | ||
timeout 10m make beelocal OPTS='ci skip-vet' | ||
- name: Set kube config | ||
run: | | ||
mkdir -p ~/.kube | ||
cp /etc/rancher/k3s/k3s.yaml ~/.kube/config | ||
- name: Set local cluster | ||
run: | | ||
make beelocal ACTION=add-hosts | ||
timeout 10m make deploylocal BEEKEEPER_CLUSTER=local-clef | ||
run: | | ||
timeout 10m make beelocal OPTS='ci skip-vet' | ||
- name: Test pingpong | ||
id: pingpong-2 | ||
run: until beekeeper check --cluster-name local-clef --checks ci-pingpong; do echo "waiting for pingpong..."; sleep .3; done | ||
- name: Test fullconnectivity | ||
id: fullconnectivity-2 | ||
run: beekeeper check --cluster-name local-clef --checks=ci-full-connectivity | ||
- name: Test settlements | ||
id: settlements-2 | ||
run: beekeeper check --cluster-name local-clef --checks=ci-settlements-clef | ||
- name: Destroy the cluster | ||
run: | | ||
beekeeper delete bee-cluster --cluster-name local-clef | ||
make beelocal ACTION=uninstall | ||
- name: Retag Docker image and push for cache | ||
if: success() | ||
run: | | ||
docker tag k3d-registry.localhost:5000/ethersphere/bee:latest ghcr.io/ethersphere/bee | ||
docker push ghcr.io/ethersphere/bee | ||
- name: Retag Docker image and push | ||
if: github.ref == 'refs/heads/master' && github.event.action != 'beekeeper' && success() | ||
run: | | ||
docker tag k3d-registry.localhost:5000/ethersphere/bee:latest ethersphere/bee:latest | ||
docker tag k3d-registry.localhost:5000/ethersphere/bee:latest quay.io/ethersphere/bee:latest | ||
printf ${{ secrets.DOCKERHUB_PASSWORD }} | docker login --username ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin | ||
printf ${{ secrets.QUAY_PASSWORD }} | docker login --username ${{ secrets.QUAY_USERNAME }} quay.io --password-stdin | ||
docker push ethersphere/bee:latest | ||
docker push quay.io/ethersphere/bee:latest | ||
echo RUN_TYPE="MERGE RUN" >> $GITHUB_ENV | ||
- name: Set IMAGE_DIGEST variable | ||
if: github.ref == 'refs/heads/master' && github.event.action != 'beekeeper' && success() | ||
run: echo "IMAGE_DIGEST=$(docker inspect --format='{{index .RepoDigests 0}}' ethersphere/bee:latest | cut -d'@' -f 2 | tr -d '\n')" >> $GITHUB_ENV | ||
- name: Trigger ArgoCD | ||
if: github.ref == 'refs/heads/master' && github.event.action != 'beekeeper' && success() | ||
uses: peter-evans/repository-dispatch@v1 | ||
with: | ||
token: ${{ secrets.REPO_GHA_PAT }} | ||
repository: ethersphere/bee-argo | ||
event-type: trigger-argo | ||
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}", "digest": "${{ env.IMAGE_DIGEST }}"}' | ||
- name: Debug workflow if failed | ||
if: failure() | ||
run: | | ||
export BUCKET_NAME=beekeeper-artifacts | ||
export AWS_ACCESS_KEY_ID=${{ secrets.DO_AWS_ACCESS_KEY_ID }} | ||
export AWS_SECRET_ACCESS_KEY=${{ secrets.DO_AWS_SECRET_ACCESS_KEY }} | ||
export AWS_EC2_METADATA_DISABLED=true | ||
export AWS_ENDPOINT=fra1.digitaloceanspaces.com | ||
export VERTAG=$(< /dev/urandom tr -dc A-Z-a-z-0-9 2> /dev/null | head -c15) | ||
bash .github/bin/beekeeper_artifacts.sh | ||
export FAILED='no-test' | ||
if ${{ steps.pingpong-1.outcome=='failure' }}; then FAILED=pingpong-1; fi | ||
if ${{ steps.fullconnectivity-1.outcome=='failure' }}; then FAILED=fullconnectivity-1; fi | ||
if ${{ steps.settlements-1.outcome=='failure' }}; then FAILED=settlements-1; fi | ||
if ${{ steps.pushsync-chunks-1.outcome=='failure' }}; then FAILED=pushsync-chunks-1; fi | ||
if ${{ steps.retrieval-1.outcome=='failure' }}; then FAILED=retrieval-1; fi | ||
if ${{ steps.manifest-1.outcome=='failure' }}; then FAILED=manifest-1; fi | ||
if ${{ steps.content-availability.outcome=='failure' }}; then FAILED=content-availability; fi | ||
if ${{ steps.pingpong-2.outcome=='failure' }}; then FAILED=pingpong-2; fi | ||
if ${{ steps.fullconnectivity-2.outcome=='failure' }}; then FAILED=fullconnectivity-2; fi | ||
if ${{ steps.settlements-2.outcome=='failure' }}; then FAILED=settlements-2; fi | ||
if ${{ steps.pss.outcome=='failure' }}; then FAILED=pss; fi | ||
if ${{ steps.soc.outcome=='failure' }}; then FAILED=soc; fi | ||
if ${{ steps.pingpong-3.outcome=='failure' }}; then FAILED=pingpong-3; fi | ||
if ${{ steps.gc-chunk-1.outcome=='failure' }}; then FAILED=gc-chunk-1; fi | ||
KEYS=$(curl -sSf -X POST https://eu.relay.tunshell.com/api/sessions) | ||
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}\`\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.WEBHOOK_KEY }} | ||
echo "run the debug shell and run the following to get debugging artifacts:" | ||
echo "curl -s -o debug.sh https://gist.githubusercontent.com/acud/2c219531e832aafbab51feffe5b5e91f/raw/304880f1f8cc819e577d1dd3f1f45df8709c543d/beekeeper_artifacts.sh | bash" | ||
echo "Failed test: ${FAILED}" | ||
echo "Connect to github actions node using" | ||
echo "sh <(curl -sSf https://lets.tunshell.com/init.sh) L $(echo $KEYS | jq -r .peer2_key) \${TUNSHELL_SECRET} eu.relay.tunshell.com" | ||
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 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
name: Beekeeper | ||
|
||
on: | ||
repository_dispatch: | ||
types: [trigger-beekeeper, beekeeper] | ||
pull_request: | ||
branches: | ||
- '**' | ||
|
||
jobs: | ||
beekeeper: | ||
name: Infra tests | ||
env: | ||
REPLICA: 3 | ||
RUN_TYPE: "PR RUN" | ||
SETUP_CONTRACT_IMAGE_TAG: "0.2.0" | ||
BEEKEEPER_BRANCH: "master" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: '1.17' | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
if: github.event.action != 'beekeeper' | ||
with: | ||
fetch-depth: 1 | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
if: github.event.action == 'beekeeper' | ||
with: | ||
ref: ${{ github.event.client_payload.ref }} | ||
fetch-depth: 1 | ||
- name: Cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
/tmp/k3s-v1.19.5+k3s2 | ||
key: k3s-v1.19.5+k3s2 | ||
- name: Cache Go modules | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-build-${{ hashFiles('**/go.sum') }} | ||
- name: Apply patches | ||
run: | | ||
patch pkg/postage/batchstore/reserve.go .github/patches/postagereserve.patch | ||
patch pkg/postage/postagecontract/contract.go .github/patches/postagecontract.patch | ||
patch pkg/postage/listener/listener.go .github/patches/listener.patch | ||
patch pkg/postage/service.go .github/patches/postageservice.patch | ||
patch pkg/postage/batchstore/reserve.go .github/patches/postagereserve_gc.patch | ||
- name: Prepare testing cluster (storage incentives setup) | ||
run: | | ||
printf ${{ secrets.CR_PAT }} | docker login ghcr.io -u bee-worker --password-stdin | ||
make beekeeper BEEKEEPER_INSTALL_DIR=/usr/local/bin BEEKEEPER_USE_SUDO=true | ||
timeout 10m make beelocal OPTS='ci skip-vet' | ||
- name: Set kube config | ||
run: | | ||
mkdir -p ~/.kube | ||
cp /etc/rancher/k3s/k3s.yaml ~/.kube/config | ||
- name: Set testing cluster (storage incentives setup) | ||
run: | | ||
timeout 10m make deploylocal BEEKEEPER_CLUSTER=local-gc | ||
- name: Test pingpong | ||
id: pingpong-3 | ||
run: until beekeeper check --cluster-name local-gc --checks ci-pingpong; do echo "waiting for pingpong..."; sleep .3; done | ||
- name: Test gc | ||
id: gc-chunk-1 | ||
run: beekeeper check --cluster-name local-gc --checks=ci-gc | ||
- name: Destroy the cluster | ||
run: | | ||
beekeeper delete bee-cluster --cluster-name local-gc | ||
make beelocal ACTION=uninstall | ||
- name: Retag Docker image and push for cache | ||
if: success() | ||
run: | | ||
docker tag k3d-registry.localhost:5000/ethersphere/bee:latest ghcr.io/ethersphere/bee | ||
docker push ghcr.io/ethersphere/bee | ||
- name: Retag Docker image and push | ||
if: github.ref == 'refs/heads/master' && github.event.action != 'beekeeper' && success() | ||
run: | | ||
docker tag k3d-registry.localhost:5000/ethersphere/bee:latest ethersphere/bee:latest | ||
docker tag k3d-registry.localhost:5000/ethersphere/bee:latest quay.io/ethersphere/bee:latest | ||
printf ${{ secrets.DOCKERHUB_PASSWORD }} | docker login --username ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin | ||
printf ${{ secrets.QUAY_PASSWORD }} | docker login --username ${{ secrets.QUAY_USERNAME }} quay.io --password-stdin | ||
docker push ethersphere/bee:latest | ||
docker push quay.io/ethersphere/bee:latest | ||
echo RUN_TYPE="MERGE RUN" >> $GITHUB_ENV | ||
- name: Set IMAGE_DIGEST variable | ||
if: github.ref == 'refs/heads/master' && github.event.action != 'beekeeper' && success() | ||
run: echo "IMAGE_DIGEST=$(docker inspect --format='{{index .RepoDigests 0}}' ethersphere/bee:latest | cut -d'@' -f 2 | tr -d '\n')" >> $GITHUB_ENV | ||
- name: Trigger ArgoCD | ||
if: github.ref == 'refs/heads/master' && github.event.action != 'beekeeper' && success() | ||
uses: peter-evans/repository-dispatch@v1 | ||
with: | ||
token: ${{ secrets.REPO_GHA_PAT }} | ||
repository: ethersphere/bee-argo | ||
event-type: trigger-argo | ||
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}", "digest": "${{ env.IMAGE_DIGEST }}"}' | ||
- name: Debug workflow if failed | ||
if: failure() | ||
run: | | ||
export BUCKET_NAME=beekeeper-artifacts | ||
export AWS_ACCESS_KEY_ID=${{ secrets.DO_AWS_ACCESS_KEY_ID }} | ||
export AWS_SECRET_ACCESS_KEY=${{ secrets.DO_AWS_SECRET_ACCESS_KEY }} | ||
export AWS_EC2_METADATA_DISABLED=true | ||
export AWS_ENDPOINT=fra1.digitaloceanspaces.com | ||
export VERTAG=$(< /dev/urandom tr -dc A-Z-a-z-0-9 2> /dev/null | head -c15) | ||
bash .github/bin/beekeeper_artifacts.sh | ||
export FAILED='no-test' | ||
if ${{ steps.pingpong-1.outcome=='failure' }}; then FAILED=pingpong-1; fi | ||
if ${{ steps.fullconnectivity-1.outcome=='failure' }}; then FAILED=fullconnectivity-1; fi | ||
if ${{ steps.settlements-1.outcome=='failure' }}; then FAILED=settlements-1; fi | ||
if ${{ steps.pushsync-chunks-1.outcome=='failure' }}; then FAILED=pushsync-chunks-1; fi | ||
if ${{ steps.retrieval-1.outcome=='failure' }}; then FAILED=retrieval-1; fi | ||
if ${{ steps.manifest-1.outcome=='failure' }}; then FAILED=manifest-1; fi | ||
if ${{ steps.content-availability.outcome=='failure' }}; then FAILED=content-availability; fi | ||
if ${{ steps.pingpong-2.outcome=='failure' }}; then FAILED=pingpong-2; fi | ||
if ${{ steps.fullconnectivity-2.outcome=='failure' }}; then FAILED=fullconnectivity-2; fi | ||
if ${{ steps.settlements-2.outcome=='failure' }}; then FAILED=settlements-2; fi | ||
if ${{ steps.pss.outcome=='failure' }}; then FAILED=pss; fi | ||
if ${{ steps.soc.outcome=='failure' }}; then FAILED=soc; fi | ||
if ${{ steps.pingpong-3.outcome=='failure' }}; then FAILED=pingpong-3; fi | ||
if ${{ steps.gc-chunk-1.outcome=='failure' }}; then FAILED=gc-chunk-1; fi | ||
KEYS=$(curl -sSf -X POST https://eu.relay.tunshell.com/api/sessions) | ||
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}\`\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.WEBHOOK_KEY }} | ||
echo "run the debug shell and run the following to get debugging artifacts:" | ||
echo "curl -s -o debug.sh https://gist.githubusercontent.com/acud/2c219531e832aafbab51feffe5b5e91f/raw/304880f1f8cc819e577d1dd3f1f45df8709c543d/beekeeper_artifacts.sh | bash" | ||
echo "Failed test: ${FAILED}" | ||
echo "Connect to github actions node using" | ||
echo "sh <(curl -sSf https://lets.tunshell.com/init.sh) L $(echo $KEYS | jq -r .peer2_key) \${TUNSHELL_SECRET} eu.relay.tunshell.com" | ||
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 |