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

feat: Lava Docker support #1458

Merged
merged 20 commits into from
Jun 2, 2024
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,9 @@ ecosystem/**/package-lock.json
.idea/
.vscode/
.storage/
.vscode/
go.work
go.work.sum
*.md

Dockerfile
104 changes: 64 additions & 40 deletions .github/workflows/lava.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ jobs:
with:
go-version-file: go.mod
cache-dependency-path: go.sum
# Setup Paths
- name: home
run: pwd && ls -l
- name: ls usr
run: ls -l /home/runner/work/lava/lava
- name: cp lava
run: cp -r ~/work/lava/lava ~/go/lava
- name: export PATH
Expand All @@ -34,14 +29,6 @@ jobs:
run: export GOPATH=$GOPATH:$(go env GOPATH):/go:/go/lava:/usr/local:`pwd`
- name: export LAVA
run: export LAVA=/home/runner/work/lava/lava
- name: go env
run: go env
- name: pwd
run: pwd
- name: tree
run: tree
- name: ls -l
run: ls -l

######################################################
### Run Consensus unitests
Expand All @@ -51,18 +38,7 @@ jobs:
go install github.com/jstemmer/go-junit-report/v2@latest
go test -v ./utils/... | go-junit-report -iocopy -set-exit-code -out utils-report.xml
go test -v ./common/... | go-junit-report -iocopy -set-exit-code -out common-report.xml
go test -v ./x/pairing/... | go-junit-report -iocopy -set-exit-code -out pairing-report.xml
go test -v ./x/epochstorage/... | go-junit-report -iocopy -set-exit-code -out epochstorage-report.xml
go test -v ./x/spec/... | go-junit-report -iocopy -set-exit-code -out spec-report.xml
go test -v ./x/conflict/... | go-junit-report -iocopy -set-exit-code -out conflict-report.xml
go test -v ./x/plans/... | go-junit-report -iocopy -set-exit-code -out plans-report.xml
go test -v ./x/projects/... | go-junit-report -iocopy -set-exit-code -out projects-report.xml
go test -v ./x/subscription/... | go-junit-report -iocopy -set-exit-code -out subscription-report.xml
go test -v ./x/dualstaking/... | go-junit-report -iocopy -set-exit-code -out dualstaking-report.xml
go test -v ./x/fixationstore/... | go-junit-report -iocopy -set-exit-code -out fixationstore-report.xml
go test -v ./x/timerstore/... | go-junit-report -iocopy -set-exit-code -out timerstore-report.xml
go test -v ./x/downtime/... | go-junit-report -iocopy -set-exit-code -out downtime-report.xml
go test -v ./x/rewards/... | go-junit-report -iocopy -set-exit-code -out rewards-report.xml
go test -v ./x/... | go-junit-report -iocopy -set-exit-code -out x-report.xml

- name: Upload Test Results
if: always()
Expand All @@ -79,12 +55,6 @@ jobs:
with:
go-version-file: go.mod
cache-dependency-path: go.sum

# Setup Paths
- name: home
run: pwd && ls -l
- name: ls usr
run: ls -l /home/runner/work/lava/lava
- name: cp lava
run: cp -r ~/work/lava/lava ~/go/lava
- name: export GOPATH
Expand All @@ -93,14 +63,6 @@ jobs:
run: export PATH=$PATH:/go:/go/bin:$(go env GOPATH)/bin:/usr/local:`pwd`:/home/runner/work/lava/lava/:$GOPATH/bin
- name: export LAVA
run: export LAVA=/home/runner/work/lava/lava
- name: go env
run: go env
- name: pwd
run: pwd
- name: tree
run: tree
- name: ls -l
run: ls -l

######################################################
### Run protocol unitests
Expand Down Expand Up @@ -217,6 +179,13 @@ jobs:
if: always()
continue-on-error: true
run: grep "" testutil/e2e/protocolLogs/06_RPCConsumer* --include="*errors*"

- name: Upload Protocol E2E Logs
if: always()
uses: actions/upload-artifact@v4
with:
name: Protocol E2E Logs
path: "testutil/e2e/protocolLogs/*"

test-sdk-e2e:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -327,6 +296,13 @@ jobs:
if: always()
continue-on-error: true
run: grep "" testutil/e2e/sdkLogs/01_sdkTest* --include="*errors*"

- name: Upload SDK E2E Logs
if: always()
uses: actions/upload-artifact@v4
with:
name: SDK E2E Logs
path: "testutil/e2e/sdkLogs/*"

test-payment-e2e:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -382,6 +358,13 @@ jobs:
if: always()
continue-on-error: true
run: grep "" testutil/e2e/protocolLogs/06_RPCConsumer* --include="*errors*"

- name: Upload Payment E2E Logs
if: always()
uses: actions/upload-artifact@v4
with:
name: Payment E2E Logs
path: "testutil/e2e/protocolLogs/*"

report-tests-results:
runs-on: ubuntu-latest
Expand All @@ -396,7 +379,48 @@ jobs:
uses: EnricoMi/publish-unit-test-result-action@v2
with:
files: "artifacts/**/*.xml"


build_docker:
permissions:
contents: read
packages: write
needs: [test-consensus, test-protocol]
runs-on: ubuntu-latest
strategy:
matrix:
binary: [lavap, lavad]
env:
REGISTRY: ghcr.io
IMAGE_NAME: "lavanet/lava/${{ matrix.binary }}"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push
uses: docker/build-push-action@v5
with:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: cmd/${{ matrix.binary }}/Dockerfile
build-args: |
GIT_VERSION="${{ steps.meta.outputs.version }}"
GIT_COMMIT="${{ github.sha }}"
push: true

build_and_package:
name: ${{ matrix.binary }}-${{ matrix.targetos }}-${{ matrix.arch }}
needs: [test-consensus, test-protocol]
Expand Down
137 changes: 42 additions & 95 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.release_tag != '' && github.event.inputs.release_tag || github.ref_name }}

ref: ${{ github.event.inputs.release_tag != '' && github.event.inputs.release_tag || github.ref_name }}
- name: Fetch all tags
run: |
git fetch --force --tags
Expand All @@ -38,6 +38,7 @@ jobs:
go-version-file: go.mod
cache-dependency-path: go.sum


- name: Run GoReleaser
id: releaser
uses: goreleaser/goreleaser-action@v5
Expand All @@ -46,96 +47,42 @@ jobs:
args: release --clean --timeout 90m
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# - name: Check for existing assests
# id: existing_asset
# run: |
# if [ "${{ github.event.release.assets[0].name }}" = "lavad" ]; then
# echo "URL=${{ github.event.release.assets[0].id }}" >> $GITHUB_OUTPUT
# echo "URL=${{ github.event.release.assets[0].url }}" >> $GITHUB_OUTPUT
# echo "CHECK=true" >> $GITHUB_OUTPUT
# else
# echo "CHECK=false" >> $GITHUB_OUTPUT
# fi

# - name: Upload build to release
# run: |
# upload_binary () {
# echo "Uploading binary to: $(echo '${{ github.event.release.upload_url }}' | sed 's/{?name,label}/?name=lavad/g')"
# curl \
# -X POST \
# -H "Accept: application/vnd.github+json" \
# -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
# -H "Content-Type: $(file -b --mime-type build/lavad)" \
# --data-binary @build/lavad \
# $(echo '${{ github.event.release.upload_url }}' | sed 's/{?name,label}/?name=lavad-${{ github.event.release.tag_name }}-linux-amd64/g')

# curl \
# -X POST \
# -H "Accept: application/vnd.github+json" \
# -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
# -H "Content-Type: $(file -b --mime-type build/lavap)" \
# --data-binary @build/lavap \
# $(echo '${{ github.event.release.upload_url }}' | sed 's/{?name,label}/?name=lavap-${{ github.event.release.tag_name }}-linux-amd64/g')

# curl \
# -X POST \
# -H "Accept: application/vnd.github+json" \
# -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
# -H "Content-Type: $(file -b --mime-type build/lavavisor)" \
# --data-binary @build/lavavisor \
# $(echo '${{ github.event.release.upload_url }}' | sed 's/{?name,label}/?name=lavavisor-${{ github.event.release.tag_name }}-linux-amd64/g')
# }

# delete_binary(){
# echo "Deleting existing binary"
# curl \
# -X DELETE \
# -H "Accept: application/vnd.github+json" \
# -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
# ${{ steps.existing_asset.outputs.URL }}
# }

# if ${{ steps.existing_asset.outputs.CHECK }}; then
# delete_binary
# upload_binary
# else
# upload_binary
# fi

# - name: Check for existing Checksum
# id: existing_checksum
# run: |
# #Get Checksum of new build
# export CHECKSUM=$(sha256sum build/lavad | cut -d " " -f1)

# #Get the existing body
# existing_body=$(curl \
# -H "Accept: application/vnd.github+json" \
# -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
# -H "Content-Type: $(file -b --mime-type build/lavad)" \
# ${{ github.event.release.url }} | jq '.body')

# if [[ $existing_body == *"$CHECKSUM"* ]]; then
# echo "CHECK=true" >> $GITHUB_OUTPUT
# echo "Checksum hasn't changed."
# else
# echo "CHECK=false" >> $GITHUB_OUTPUT
# cat <<EOF >> /tmp/body
# $(echo $existing_body | sed '$s/.$//')\r\nChecksum $CHECKSUM"
# EOF
# echo -E "NEW_BODY=$(cat /tmp/body)" >> $GITHUB_OUTPUT
# fi

# - name: Append Binary Checksum
# uses: actions/github-script@v6
# if: ${{ steps.existing_checksum.outputs.CHECK }} == 'false'
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# script: |
# const { data } = await github.rest.repos.updateRelease({
# owner: context.repo.owner,
# repo: context.repo.repo,
# release_id: context.payload.release.id,
# body: ${{ steps.existing_checksum.outputs.NEW_BODY }}
# });

release_docker:
permissions:
packages: write
runs-on: ubuntu-latest
strategy:
matrix:
binary: [lavap, lavad]
env:
REGISTRY: ghcr.io
IMAGE_NAME: "lavanet/lava/${{ matrix.binary }}"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push
uses: docker/build-push-action@v5
with:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: cmd/${{ matrix.binary }}/Dockerfile
build-args: |
GIT_VERSION="${{ steps.meta.outputs.version }}"
GIT_COMMIT="${{ github.sha }}"
push: true
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,4 @@ EXPOSE 26656
# tendermint rpc
EXPOSE 26657

ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT ["/entrypoint.sh"]
Loading
Loading