diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 4561e859..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: Build - -on: - push: - branches: [main] - pull_request: - branches: [main] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1.17 - - - name: Set up Node.js - uses: actions/setup-node@v2 - with: - node-version: "16" - - - name: Generate - run: go generate -x - - - name: Build - run: go build -v - - - name: Test - run: go test -v ./... - - golangci: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v2 - with: - go-version: 1.17 - - - name: golangci-lint - uses: golangci/golangci-lint-action@v3 - with: - version: latest - - prettier: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: "16" - - - run: yarn install - working-directory: web - - - run: yarn prettier --check 'src/**/*.{css,html,js,svelte}' - working-directory: web diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index f590e1fa..00000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Docker - -on: - push: - branches: [main] - tags: [v*] - pull_request: - branches: [main] - -jobs: - docker: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v3 - with: - images: ${{ secrets.DOCKERHUB_USERNAME }}/eth-faucet - tags: | - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v2 - with: - context: . - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml new file mode 100644 index 00000000..2ab51c55 --- /dev/null +++ b/.github/workflows/pr.yaml @@ -0,0 +1,32 @@ +# This workflow will build a golang project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go + +name: 'PR CI' + +on: + pull_request: + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: setup-go + uses: actions/setup-go@v4 + with: + go-version: '1.22' + - name: build + run: make build + - name: golangci-lint + run: make lint + - name: format + run: | + make format + if [ -z "$(git status --untracked-files=no --porcelain)" ]; then + echo "All files formatted" + else + echo "Running format is required" + exit 1 + fi + - name: test + run: make test \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 20cf673b..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: goreleaser - -on: - push: - tags: [v*] - -jobs: - goreleaser: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1.17 - - - name: Set up Node.js - uses: actions/setup-node@v2 - with: - node-version: "16" - - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v2 - with: - distribution: goreleaser - version: latest - args: release --rm-dist - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Makefile b/Makefile index 890d623d..31c3e789 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ BLUE = \033[1;34m GREEN = \033[1;32m COLOR_END = \033[0;39m -build: build-backend build-frontend +build: build-frontend build-backend build-backend: # Builds the application and create a binary at ./bin/ @echo "$(BLUE)ยป Building $(APP_NAME) application binary... $(COLOR_END)" @@ -20,7 +20,6 @@ build-frontend: # Builds the frontned application run: # Runs the application, use `make run FLAGS="--help"` @./bin/${APP_NAME} ${FLAGS} -.PHONY: test test: # Runs tests @echo "Test packages" @go test -race -shuffle=on -coverprofile=coverage.out -cover $(PKGS) @@ -32,14 +31,12 @@ lint: # Runs golangci-lint on the repo format: # Runs gofmt on the repo gofmt -s -w . -.PHONY: docker-build build-image: # Builds docker image - @echo "$(BLUE) Building docker image...$(COLOR_END)" + @echo "$(BLUE)Building docker image...$(COLOR_END)" @docker build -t $(APP_NAME) . -.PHONY: docker-run docker-start: # Runs docker image - @echo "$(BLUE) Starting docker container $(APP_NAME)...$(COLOR_END)" + @echo "$(BLUE)Starting docker container $(APP_NAME)...$(COLOR_END)" ifdef PRIVATE_KEY @docker run --name $(APP_NAME) -p 8080:8080 -d -e WEB3_PROVIDER=$(WEB3_PROVIDER) -e PRIVATE_KEY=$(PRIVATE_KEY) $(APP_NAME) else ifdef KEYSTORE @@ -47,7 +44,7 @@ else ifdef KEYSTORE endif docker-stop: - @echo "$(BLUE) Stopping and removing docker container $(APP_NAME)...$(COLOR_END)" + @echo "$(BLUE)Stopping and removing docker container $(APP_NAME)...$(COLOR_END)" @docker rm -f $(APP_NAME) .PHONY: help diff --git a/internal/chain/transaction.go b/internal/chain/transaction.go index 684e0498..c8aa04fb 100644 --- a/internal/chain/transaction.go +++ b/internal/chain/transaction.go @@ -149,7 +149,7 @@ func (b *TxBuild) TransferERC20(ctx context.Context, to string, value *big.Int) if err = b.client.SendTransaction(ctx, signedTx); err != nil { log.Error("failed to send tx", "tx hash", signedTx.Hash().String(), "err", err) if strings.Contains(err.Error(), "nonce") { - b.refreshNonce(context.Background()) + b.refreshNonce(ctx) } return emptyHash, err } diff --git a/internal/chain/transaction_test.go b/internal/chain/transaction_test.go index 4a931048..68d871f9 100644 --- a/internal/chain/transaction_test.go +++ b/internal/chain/transaction_test.go @@ -14,7 +14,7 @@ import ( "github.com/ethereum/go-ethereum/ethclient/simulated" ) -func TestTxBuilder(t *testing.T) { +func TestTxBuilder_TransferETH(t *testing.T) { privateKey, _ := crypto.HexToECDSA("976f9f7772781ff6d1c93941129d417c49a209c674056a3cf5e27e225ee55fa8") fromAddress := crypto.PubkeyToAddress(privateKey.PublicKey) simBackend := simulated.NewBackend(