Skip to content

Commit

Permalink
update docker (#683)
Browse files Browse the repository at this point in the history
* update docker

* commment out contract test

* update check

* update workflow
  • Loading branch information
Liuhaai authored Oct 9, 2024
1 parent f1c3cbd commit 014deda
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 335 deletions.
33 changes: 0 additions & 33 deletions .github/workflows/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

23 changes: 0 additions & 23 deletions .github/workflows/ISSUE_TEMPLATE/feature_request.md

This file was deleted.

33 changes: 0 additions & 33 deletions .github/workflows/ISSUE_TEMPLATE/general_question.md

This file was deleted.

14 changes: 7 additions & 7 deletions .github/workflows/check.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: pr_check
name: run tests

on:
push:
branches: [ "develop", "pull-request" ]
branches: [ "develop"]
pull_request:
branches: [ "develop", "pull-request" ]
branches: [ "develop"]

jobs:
build:
Expand All @@ -28,16 +28,16 @@ jobs:
with:
node-version: '21.x'

- name: Run Unit tests for smart-contract
run: make contract_test
- name: Run tests for smart-contract
run: make contract-test

- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.22

- name: Run Unit tests.
run: make unit_test
- name: Run unit tests.
run: make test

- name: Upload Coverage report to CodeCov
uses: codecov/[email protected]
Expand Down
102 changes: 42 additions & 60 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,65 +1,47 @@

DOCKER_COMPOSE_TEST_FILE=./docker-compose-test.yaml

e2e_test_depends_stop:
@docker compose -f ${DOCKER_COMPOSE_TEST_FILE} down

e2e_test_depends_start:
@docker compose -p w3bstream-sprout -f ${DOCKER_COMPOSE_TEST_FILE} up -d

.PHONY: e2e_test_depends
e2e_test_depends: e2e_test_depends_stop e2e_test_depends_start

e2e_test: e2e_test_depends
@cd cmd/e2etest/ && CGO_LDFLAGS='-L../sequencer/lib/linux-x86_64 -lioConnectCore' go test ./... -v

unit_test:
GOARCH=amd64 go test -gcflags="all=-N -l" ./... -covermode=atomic -coverprofile cover.out

.PHONY: contract_test_depends
contract_test_depends:
@cd smartcontracts && npm install --save-dev hardhat

contract_test: contract_test_depends
@cd smartcontracts && npx hardhat test

# Variables
BUILD_DIR=build
DOCKER_APINODE_TARGET=ghcr.io/iotexproject/w3bstream-apinode:latest
DOCKER_PROVER_TARGET=ghcr.io/iotexproject/w3bstream-prover:latest
DOCKER_BOOTNODE_TARGET=ghcr.io/iotexproject/w3bstream-bootnode:latest
DOCKER_SEQUENCER_TARGET=ghcr.io/iotexproject/w3bstream-sequencer:latest

# Build targets
.PHONY: build
build: build-apinode build-prover build-bootnode build-sequencer

.PHONY: build-apinode
build-apinode:
go build -o $(BUILD_DIR)/apinode cmd/apinode/main.go

.PHONY: build-prover
build-prover:
go build -o $(BUILD_DIR)/prover cmd/prover/main.go

.PHONY: build-bootnode
build-bootnode:
go build -o $(BUILD_DIR)/bootnode cmd/bootnode/main.go

.PHONY: build-sequencer
build-sequencer:
go build -o $(BUILD_DIR)/sequencer cmd/sequencer/main.go

# Docker targets
.PHONY: images
images:
@for target in 'sequencer' 'prover' 'coordinator' ; \
do \
echo build $$target image; \
if [ -e $$target.Dockerfile ]; then \
echo $$target.Dockerfile; \
docker build -f $$target.Dockerfile . -t $$target; \
else \
echo "no entry"; \
fi; \
echo "done!"; \
done

.PHONY: prover_image
prover_image:
@docker build -f prover.Dockerfile . -t prover
docker build -f apinode.Dockerfile -t $(DOCKER_APINODE_TARGET) .
docker build -f prover.Dockerfile -t $(DOCKER_PROVER_TARGET) .
docker build -f bootnode.Dockerfile -t $(DOCKER_BOOTNODE_TARGET) .
docker build -f sequencer.Dockerfile -t $(DOCKER_SEQUENCER_TARGET) .

.PHONY: sequencer_image
sequencer_image:
@docker build -f sequencer.Dockerfile . -t sequencer
.PHONY: test
test:
go test -gcflags="all=-N -l" ./...

.PHONY: coordinator_image
coordinator_image:
@docker build -f coordinator.Dockerfile . -t coordinator

MOD=$(shell cat go.mod | grep ^module -m 1 | awk '{ print $$2; }' || '')

.PHONY: fmt
fmt:
@echo ${MOD}
@for item in `find . -type f -name '*.go' -not -path '*.pb.go'` ; \
do \
if [ -z ${MOD} ]; then \
goimports -w $$item ; \
else \
goimports -w -local "${MOD}" $$item ; \
fi \
done
# Clean targets
.PHONY: clean
clean:
@rm -rf $(BUILD_DIR)

contract-test:
@cd smartcontracts && npm install --save-dev hardhat
@cd smartcontracts && npx hardhat test
4 changes: 2 additions & 2 deletions apinode.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ghcr.io/machinefi/apinode:latest
FROM --platform=linux/amd64 golang:1.22-alpine AS builder
FROM golang:1.22-alpine AS builder

ENV GO111MODULE=on

Expand All @@ -8,7 +8,7 @@ COPY ./ ./

RUN cd ./cmd/apinode && go build -o apinode

FROM --platform=linux/amd64 alpine:3.20 AS runtime
FROM alpine:3.20 AS runtime

ENV LANG en_US.UTF-8

Expand Down
13 changes: 1 addition & 12 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,8 @@ ignore:
- vm/proto
# generated contracts
- smartcontracts
# test utils
- test
- testutil
# e2e test
- cmd/e2etest
- cmd/stresstest
# metrics
- metrics
# main
- cmd/coordinator/main.go
- cmd/prover/main.go
- cmd/sequencer/main.go
- cmd/*
- project/project_easyjson.go
- persistence/contract/contract_easyjson.go
- persistence/contract/project_easyjson.go
- persistence/contract/prover_easyjson.go
66 changes: 0 additions & 66 deletions docker-compose-dev.yaml

This file was deleted.

Loading

0 comments on commit 014deda

Please sign in to comment.