Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move docker build to separate ci #1128

Merged
merged 4 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions .github/workflows/auto-generated-code-checker.yml

This file was deleted.

20 changes: 20 additions & 0 deletions .github/workflows/publish_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Publish Docker Image

on:
workflow_dispatch:
push:
tags:
- "*"
branches:
- master

jobs:
publish_docker_image:
name: Publish Docker Image
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- run: echo ${{ secrets.docker_pass }} | docker login --username ${{ secrets.docker_username }} --password-stdin
shell: bash
- run: CURRENT_BRANCH=${{ github.head_ref || github.ref_name }} PUSH_DOCKER_IMAGE=true ./scripts/build_image.sh
shell: bash
34 changes: 19 additions & 15 deletions .github/workflows/ci.yml → .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
name: Build + Test + Lint
name: Tests

on:
push:
branches:
- master
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- '*'
pull_request:

env:
tmpnet_data_path: ~/.tmpnet/networks/1000
min_go_version: '~1.21.7'

jobs:
lint_test:
Expand All @@ -21,7 +22,7 @@ jobs:
shell: bash
- uses: actions/setup-go@v5
with:
go-version: '~1.21.7'
go-version: ${{ env.min_go_version }}
check-latest: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
Expand All @@ -40,7 +41,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '~1.21.7'
go-version: ${{ env.min_go_version }}
check-latest: true
- run: go mod download
shell: bash
Expand All @@ -62,7 +63,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '~1.21.7'
go-version: ${{ env.min_go_version }}
check-latest: true
- name: Use Node.js
uses: actions/setup-node@v4
Expand Down Expand Up @@ -104,7 +105,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '~1.21.7'
go-version: ${{ env.min_go_version }}
check-latest: true
- name: Use Node.js
uses: actions/setup-node@v4
Expand Down Expand Up @@ -146,7 +147,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '~1.21.7'
go-version: ${{ env.min_go_version }}
check-latest: true
- name: Install AvalancheGo Release
shell: bash
Expand All @@ -164,13 +165,16 @@ jobs:
name: load-tmpnet-data
path: ${{ env.tmpnet_data_path }}
if-no-files-found: error

build_image:
name: Build Docker Image
runs-on: ubuntu-20.04
mock_gen:
name: MockGen Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: echo ${{ secrets.docker_pass }} | docker login --username ${{ secrets.docker_username }} --password-stdin
shell: bash
- run: CURRENT_BRANCH=${{ github.head_ref || github.ref_name }} PUSH_DOCKER_IMAGE=true ./scripts/build_image.sh
shell: bash
- uses: actions/setup-go@v4
with:
go-version: ${{ env.min_go_version }}
check-latest: true
- shell: bash
run: scripts/mock.gen.sh
- shell: bash
run: .github/workflows/check-clean-branch.sh
6 changes: 5 additions & 1 deletion scripts/build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ source "$SUBNET_EVM_PATH"/scripts/versions.sh
# Load the constants
source "$SUBNET_EVM_PATH"/scripts/constants.sh

BUILD_IMAGE_ID=${BUILD_IMAGE_ID:-"${AVALANCHE_VERSION}-Subnet-EVM-${CURRENT_BRANCH}"}
BUILD_IMAGE_ID=${BUILD_IMAGE_ID:-"avalanchego-${AVALANCHE_VERSION}-subnet-evm-${CURRENT_BRANCH}"}

echo "Building Docker Image: $DOCKERHUB_REPO:$BUILD_IMAGE_ID based of $AVALANCHE_VERSION"
docker build -t "$DOCKERHUB_REPO:$BUILD_IMAGE_ID" "$SUBNET_EVM_PATH" -f "$SUBNET_EVM_PATH/Dockerfile" \
Expand All @@ -25,5 +25,9 @@ docker build -t "$DOCKERHUB_REPO:$BUILD_IMAGE_ID" "$SUBNET_EVM_PATH" -f "$SUBNET
--build-arg CURRENT_BRANCH="$CURRENT_BRANCH"

if [[ ${PUSH_DOCKER_IMAGE:-""} == "true" ]]; then
if [[ $CURRENT_BRANCH == "master" ]]; then
echo "Tagging current image as $DOCKERHUB_REPO:latest"
docker tag "$DOCKERHUB_REPO:$BUILD_IMAGE_ID" "$DOCKERHUB_REPO:latest"
fi
docker push "$DOCKERHUB_REPO:$BUILD_IMAGE_ID"
fi
2 changes: 1 addition & 1 deletion scripts/constants.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set -euo pipefail
GOPATH="$(go env GOPATH)"

# Avalabs docker hub
DOCKERHUB_REPO="avaplatform/avalanchego"
DOCKERHUB_REPO="avaplatform/subnet-evm"

# if this isn't a git repository (say building from a release), don't set our git constants.
if [ ! -d .git ]; then
Expand Down
Loading