buidling blobber image without buildx #4758
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
name: "Build & Publish Docker Image" | |
concurrency: | |
group: "publish-${{ github.ref }}" | |
cancel-in-progress: true | |
on: | |
push: | |
branches: [ master,staging, sprint* ] | |
tags: | |
- '*' | |
pull_request: | |
workflow_dispatch: | |
inputs: | |
latest_tag: | |
description: 'type yes for building latest / staging tag' | |
default: 'no' | |
required: true | |
env: | |
BLOBBER_REGISTRY: ${{ secrets.BLOBBER_REGISTRY }} | |
VALIDATOR_REGISTRY: ${{ secrets.VALIDATOR_REGISTRY }} | |
BLOBBER_BUILDBASE: blobber_base | |
BLOBBER_BUILD_BASE_REGISTRY: ${{ secrets.BLOBBER_BUILD_BASE_REGISTRY }} | |
jobs: | |
blobber: | |
timeout-minutes: 30 | |
runs-on: [arc-runner] | |
steps: | |
- name: Set docker image tag | |
run: | | |
if [[ "${{github.ref}}" == refs/pull/* ]]; then | |
tag=${GITHUB_REF/\/merge/} | |
echo "TAG=$(echo pr-${tag:10})" >> $GITHUB_ENV | |
else | |
echo "TAG=$(echo ${GITHUB_REF#refs/*/} | sed 's/\//-/g')" >> $GITHUB_ENV | |
fi | |
echo "BRANCH=$([ -z '${{ github.event.pull_request.head.sha }}' ] && echo ${GITHUB_REF#refs/*/} || echo $GITHUB_HEAD_REF)" >> $GITHUB_ENV | |
echo "SHA=$([ -z '${{ github.event.pull_request.head.sha }}' ] && echo $GITHUB_SHA || echo '${{ github.event.pull_request.head.sha }}')" >> $GITHUB_ENV | |
- name: Clone blobber | |
uses: actions/checkout@v4 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Get changed files using defaults | |
id: changed-files | |
uses: tj-actions/[email protected] | |
- name: Pull Build Base | |
run: | | |
docker pull $BLOBBER_BUILD_BASE_REGISTRY:staging | |
docker tag $BLOBBER_BUILD_BASE_REGISTRY:staging $BLOBBER_BUILDBASE | |
- name: Build Base image | |
if: contains(steps.changed-files.outputs.modified_files, 'docker.local/base.Dockerfile') | |
run: | | |
SHORT_SHA=$(echo ${{ env.SHA }} | head -c 8) | |
docker build -f docker.local/base.Dockerfile . -t $BLOBBER_BUILDBASE | |
docker tag $BLOBBER_BUILDBASE $BLOBBER_BUILD_BASE_REGISTRY:staging | |
docker tag $BLOBBER_BUILDBASE $BLOBBER_BUILD_BASE_REGISTRY:$TAG-$SHORT_SHA | |
docker push $BLOBBER_BUILD_BASE_REGISTRY:staging | |
docker push $BLOBBER_BUILD_BASE_REGISTRY:$TAG-$SHORT_SHA | |
- name: Build blobber | |
run: | | |
export DOCKER_IMAGE_BASE="$BLOBBER_BUILD_BASE_REGISTRY:staging" | |
echo "building swagger file" | |
docker build --build-arg DOCKER_IMAGE_BASE=$DOCKER_IMAGE_BASE -f docker.local/Dockerfile.swagger . -t swagger | |
docker run -v $(pwd):/codecov swagger bash -c "cd /codecov/code/go/0chain.net/; swagger generate spec -w . -m -o swagger.yaml; swagger generate markdown -f swagger.yaml --output=swagger.md" | |
docker build --build-arg GIT_COMMIT=$GITHUB_SHA --build-arg DOCKER_IMAGE_BASE=$DOCKER_IMAGE_BASE -t ${BLOBBER_REGISTRY}:latest -f docker.local/blobber.Dockerfile . | |
docker tag ${BLOBBER_REGISTRY}:latest ${BLOBBER_REGISTRY}:${TAG} | |
docker push ${BLOBBER_REGISTRY}:${TAG} | |
SHORT_SHA=$(echo ${{ env.SHA }} | head -c 8) | |
docker tag ${BLOBBER_REGISTRY}:latest ${BLOBBER_REGISTRY}:${TAG}-${SHORT_SHA} | |
docker push ${BLOBBER_REGISTRY}:${TAG}-${SHORT_SHA} | |
- name: Push latest | |
if: ${{ github.event.inputs.latest_tag == 'yes' || github.ref == 'refs/heads/master' }} | |
run: | | |
docker push ${BLOBBER_REGISTRY}:latest | |
validator: | |
timeout-minutes: 30 | |
runs-on: [arc-runner] | |
steps: | |
- name: Set docker image tag | |
run: | | |
if [[ "${{github.ref}}" == refs/pull/* ]]; then | |
tag=${GITHUB_REF/\/merge/} | |
echo "TAG=$(echo pr-${tag:10})" >> $GITHUB_ENV | |
else | |
echo "TAG=$(echo ${GITHUB_REF#refs/*/} | sed 's/\//-/g')" >> $GITHUB_ENV | |
fi | |
echo "BRANCH=$([ -z '${{ github.event.pull_request.head.sha }}' ] && echo ${GITHUB_REF#refs/*/} || echo $GITHUB_HEAD_REF)" >> $GITHUB_ENV | |
echo "SHA=$([ -z '${{ github.event.pull_request.head.sha }}' ] && echo $GITHUB_SHA || echo '${{ github.event.pull_request.head.sha }}')" >> $GITHUB_ENV | |
- name: Clone blobber | |
uses: actions/checkout@v4 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Get changed files using defaults | |
id: changed-files | |
uses: tj-actions/[email protected] | |
- name: Pull Build Base | |
run: | | |
docker pull $BLOBBER_BUILD_BASE_REGISTRY:staging | |
docker tag $BLOBBER_BUILD_BASE_REGISTRY:staging $BLOBBER_BUILDBASE | |
- name: Build Base image | |
if: contains(steps.changed-files.outputs.modified_files, 'docker.local/base.Dockerfile') | |
run: | | |
SHORT_SHA=$(echo ${{ env.SHA }} | head -c 8) | |
docker build -f docker.local/base.Dockerfile . -t $BLOBBER_BUILDBASE | |
docker tag $BLOBBER_BUILDBASE $BLOBBER_BUILD_BASE_REGISTRY:staging | |
docker tag $BLOBBER_BUILDBASE $BLOBBER_BUILD_BASE_REGISTRY:$TAG-$SHORT_SHA | |
docker push $BLOBBER_BUILD_BASE_REGISTRY:staging | |
docker push $BLOBBER_BUILD_BASE_REGISTRY:$TAG-$SHORT_SHA | |
- name: Build validator | |
run: | | |
export DOCKER_IMAGE_BASE="$BLOBBER_BUILD_BASE_REGISTRY:staging" | |
docker build --build-arg GIT_COMMIT=$GITHUB_SHA --build-arg DOCKER_IMAGE_BASE=$DOCKER_IMAGE_BASE -t ${VALIDATOR_REGISTRY}:latest -f docker.local/validator.Dockerfile . | |
docker tag ${VALIDATOR_REGISTRY}:latest ${VALIDATOR_REGISTRY}:${TAG} | |
docker push ${VALIDATOR_REGISTRY}:${TAG} | |
SHORT_SHA=$(echo ${{ env.SHA }} | head -c 8) | |
docker tag ${VALIDATOR_REGISTRY}:latest ${VALIDATOR_REGISTRY}:${TAG}-${SHORT_SHA} | |
docker push ${VALIDATOR_REGISTRY}:${TAG}-${SHORT_SHA} | |
- name: Push latest | |
if: ${{ github.event.inputs.latest_tag == 'yes' || github.ref == 'refs/heads/master' }} | |
run: | | |
docker push ${VALIDATOR_REGISTRY}:latest | |
system-tests: | |
if: github.event_name != 'workflow_dispatch' | |
needs: [blobber, validator] | |
runs-on: [ tests-suite ] | |
steps: | |
- name: "Get current PR" | |
uses: jwalton/gh-find-current-pr@v1 | |
id: findPr | |
with: | |
github-token: ${{ github.token }} | |
- name: "Set PR status as pending" | |
uses: 0chain/actions/set-pr-status@master | |
if: steps.findPr.outputs.number | |
with: | |
pr_number: ${{ steps.findPr.outputs.pr }} | |
description: "System tests running with default config..." | |
state: "pending" | |
repository: ${{ github.repository }} | |
status_name: "0Chain System Tests" | |
target_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
github_token: ${{ github.token }} | |
- name: "Setup" | |
run: | | |
if [[ "${{github.ref}}" == refs/pull/* ]]; then | |
tag=${GITHUB_REF/\/merge/} | |
echo "TAG=$(echo pr-${tag:10})" >> $GITHUB_ENV | |
else | |
echo "TAG=$(echo ${GITHUB_REF#refs/*/} | sed 's/\//-/g')" >> $GITHUB_ENV | |
fi | |
echo "BRANCH=$([ -z '${{ github.event.pull_request.head.sha }}' ] && echo ${GITHUB_REF#refs/*/} || echo $GITHUB_HEAD_REF)" >> $GITHUB_ENV | |
echo "SHORT_SHA=$(([ -z '${{ github.event.pull_request.head.sha }}' ] && echo $GITHUB_SHA || echo '${{ github.event.pull_request.head.sha }}') | head -c 8)" >> $GITHUB_ENV | |
echo "NETWORK_URL=$(echo dev-${RUNNER_NAME:(-1)}.devnet-0chain.net)" >> $GITHUB_ENV | |
echo "RUNNER_NUMBER=${RUNNER_NAME:(-1)}" >> $GITHUB_ENV | |
- name: 'Setup jq' | |
uses: dcarbone/[email protected] | |
with: | |
version: '1.7' | |
force: 'false' | |
- name: "Create Tenderly fork" | |
run: | | |
echo "TENDERLY_CREATION_INFO=$(curl -X POST \ | |
-H "x-access-key: ${{ secrets.TENDERLY_SECRET }}" \ | |
-H "Content-Type: application/json" \ | |
-d '{"alias":"mainnet-dev-${{ env.RUNNER_NUMBER }}-${{ github.run_id }}${{ github.run_attempt }}", "description":"", "block_number": 18539779, "network_id":"1"}' \ | |
https://api.tenderly.co/api/v1/account/zus_network/project/project/fork)" >> $GITHUB_ENV | |
- name: "Parse Tenderly fork creation transaction result" | |
run: | | |
echo "TENDERLY_FORK_ID=$(echo '${{ env.TENDERLY_CREATION_INFO }}' | jq -r '.simulation_fork.id')" >> $GITHUB_ENV | |
echo "TENDERLY_ROOT_TRANSACTION_ID=$(echo '${{ env.TENDERLY_CREATION_INFO }}' | jq -r '.root_transaction.id')" >> $GITHUB_ENV | |
- name: "Retrieve Tenderly fork block number" | |
run: | | |
echo "TENDERLY_FORK_BLOCK_NUMBER=$(curl -X GET \ | |
-H "x-access-key: ${{ secrets.TENDERLY_SECRET }}" \ | |
-H "Content-Type: application/json" \ | |
https://api.tenderly.co/api/v1/network/1/block-number | jq -r '.block_number')" >> $GITHUB_ENV | |
echo "TENDERLY_FORK_BLOCK_NUMBER=$((${{ env.TENDERLY_FORK_BLOCK_NUMBER }} + 1))" >> GITHUB_ENV | |
- name: "Transfer Bridge ownership in Tenderly fork" | |
run: | | |
echo "TENDERLY_ROOT_TRANSACTION_ID=$(curl -X POST \ | |
-H "x-access-key: ${{ secrets.TENDERLY_SECRET }}" \ | |
-H "Content-Type: application/json" \ | |
-d '{ | |
"network_id": "1", | |
"block_number": ${{ env.TENDERLY_FORK_BLOCK_NUMBER }}, | |
"transaction_index": null, | |
"from": "0xed8f3170db6d1a71c8fa6d8d73cc2c51db95d5a4", | |
"input": "0xf2fde38b0000000000000000000000008e25cfd9bd6c0ca67a5522cd920b3c66d39d6e97", | |
"to": "0x7700d773022b19622095118fadf46f7b9448be9b", | |
"gas": 8000000, | |
"gas_price": "0", | |
"value": "0", | |
"access_list": [], | |
"generate_access_list": true, | |
"save": true, | |
"source": "dashboard", | |
"block_header": null, | |
"root": "${{ env.TENDERLY_ROOT_TRANSACTION_ID }}", | |
"skip_fork_head_update": false, | |
"alias": "", | |
"description": "Transfer ownership to 0x8E25cfd9bd6c0ca67a5522cd920b3c66D39d6E97" | |
}' \ | |
https://api.tenderly.co/api/v1/account/zus_network/project/project/fork/${{ env.TENDERLY_FORK_ID }}/simulate | jq -r '.simulation.id')" >> $GITHUB_ENV | |
echo "TENDERLY_FORK_BLOCK_NUMBER=$((${{ env.TENDERLY_FORK_BLOCK_NUMBER }} + 1))" >> GITHUB_ENV | |
- name: "Transfer Authorizers ownership in Tenderly fork" | |
run: | | |
curl -X POST \ | |
-H "x-access-key: ${{ secrets.TENDERLY_SECRET }}" \ | |
-H "Content-Type: application/json" \ | |
-d '{ | |
"network_id": "1", | |
"block_number": ${{ env.TENDERLY_FORK_BLOCK_NUMBER }}, | |
"transaction_index": null, | |
"from": "0xed8f3170db6d1a71c8fa6d8d73cc2c51db95d5a4", | |
"input": "0xf2fde38b0000000000000000000000008e25cfd9bd6c0ca67a5522cd920b3c66d39d6e97", | |
"to": "0x481dab4407b9880de0a68dc62e6af611c4949e42", | |
"gas": 8000000, | |
"gas_price": "0", | |
"value": "0", | |
"access_list": [], | |
"generate_access_list": true, | |
"save": true, | |
"source": "dashboard", | |
"block_header": null, | |
"root": "${{ env.TENDERLY_ROOT_TRANSACTION_ID }}", | |
"skip_fork_head_update": false, | |
"alias": "", | |
"description": "Transfer ownership to 0x8E25cfd9bd6c0ca67a5522cd920b3c66D39d6E97" | |
}' \ | |
https://api.tenderly.co/api/v1/account/zus_network/project/project/fork/${{ env.TENDERLY_FORK_ID }}/simulate | |
- name: "Deploy 0Chain" | |
uses: 0chain/actions/deploy-0chain@master | |
with: | |
repo_snapshots_branch: "<CURRENT BRANCH WITH FALLBACK TO CURRENT_SPRINT>" | |
kube_config: ${{ secrets[format('DEV{0}KC', env.RUNNER_NUMBER)] }} | |
teardown_condition: "TESTS_PASSED" | |
blobber_image: ${{ env.TAG }}-${{ env.SHORT_SHA }} | |
validator_image: ${{ env.TAG }}-${{ env.SHORT_SHA }} | |
SUBGRAPH_API_URL: ${{ secrets.SUBGRAPH_API_URL }} | |
TENDERLY_FORK_ID: ${{ env.TENDERLY_FORK_ID }} | |
graphnode_sc: ${{ secrets.GRAPHNODE_SC }} | |
graphnode_network: ${{ secrets.GRAPHNODE_NETWORK }} | |
graphnode_ethereum_node_url: https://rpc.tenderly.co/fork/${{ env.TENDERLY_FORK_ID }} | |
svc_account_secret: ${{ secrets.SVC_ACCOUNT_SECRET }} | |
- name: "Run System tests" | |
uses: 0chain/actions/run-system-tests@master | |
with: | |
repo_snapshots_branch: "<CURRENT BRANCH WITH FALLBACK TO CURRENT_SPRINT>" | |
network: ${{ env.NETWORK_URL }} | |
svc_account_secret: ${{ secrets.SVC_ACCOUNT_SECRET }} | |
deploy_report_page: false | |
archive_results: true | |
run_flaky_tests: false | |
retry_failures: true | |
run_smoke_tests: ${{ github.ref != 'refs/heads/staging' && github.base_ref != 'staging' && github.ref != 'refs/heads/master' && github.base_ref != 'master' }} | |
TENDERLY_FORK_ID: ${{ env.TENDERLY_FORK_ID }} | |
DEVOPS_CHANNEL_WEBHOOK_URL: ${{ secrets.DEVOPS_CHANNEL_WEBHOOK_URL }} | |
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }} | |
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }} | |
- name: "Remove Tenderly fork" | |
if: always() | |
run: | | |
curl -X DELETE \ | |
-H "x-access-key: ${{ secrets.TENDERLY_SECRET }}" \ | |
-H "Content-Type: application/json" \ | |
https://api.tenderly.co/api/v1/account/zus_network/project/project/fork/${{ env.TENDERLY_FORK_ID }} | |
- name: "Set PR status as ${{ job.status }}" | |
if: ${{ (success() || failure()) && steps.findPr.outputs.number }} | |
uses: 0chain/actions/set-pr-status@master | |
with: | |
pr_number: ${{ steps.findPr.outputs.pr }} | |
description: "System tests with default config ${{ job.status }}" | |
state: ${{ job.status }} | |
repository: ${{ github.repository }} | |
status_name: "0Chain System Tests" | |
target_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
github_token: ${{ github.token }} |