diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..2051b91 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,32 @@ +name: Test/Fmt + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test_and_format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Setup Go + uses: actions/setup-go@v2 + with: + go-version: 1.19 + + - name: Setup Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + + - name: build + run: make build + + - name: test + run: make test + + - name: format + run: make check_fmt diff --git a/Makefile b/Makefile index 1626820..4ba2f51 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: run +.PHONY: run fmt check_fmt run: @go run cmd/cli/main.go @@ -10,3 +10,9 @@ build: @cd pkg/lambdaworks/lib/lambdaworks && cargo build --release @cp pkg/lambdaworks/lib/lambdaworks/target/release/liblambdaworks.a pkg/lambdaworks/lib @go build ./... + +fmt: + gofmt -w pkg + +check_fmt: + ./check_fmt.sh diff --git a/check_fmt.sh b/check_fmt.sh new file mode 100755 index 0000000..d572ec2 --- /dev/null +++ b/check_fmt.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +files=$(gofmt -l pkg) +if [[ $files ]]; then + echo -e "Some files are not correctly formatted:\n${files}" + exit 1 +else + exit 0 +fi