diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..b2d2a90 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,47 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Install Task + uses: arduino/setup-task@v1 + + - name: Check go fmt + run: | + task check-format + + - name: Check linting + run: | + task lint + + build: + needs: [lint] + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Install Task + uses: arduino/setup-task@v1 + + - name: Build Binary + run: | + task build + + - uses: stefanzweifel/git-auto-commit-action@v5 + if: github.event_name == 'pull_request' + with: + commit_message: Update compiled binaries + file_pattern: "bin/*" diff --git a/.golangci.yml b/.golangci.yml index 11c6035..98e3cbe 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,3 +1,2 @@ linters: - enable-all: true fast: false diff --git a/Taskfile.yaml b/Taskfile.yaml index 88179e2..43e474e 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -30,9 +30,9 @@ tasks: golang:{{ .GO_VERSION }} \ {{ .COMMAND }} - compile: + build: <<: *go-docker - desc: Compile the application + desc: Build the application vars: COMMAND: go build -o bin/{{ .GIT_REPO_NAME }} *.go @@ -48,6 +48,12 @@ tasks: vars: COMMAND: go fmt ./... + check-format: + <<: *go-docker + desc: Format the application + vars: + COMMAND: bash -c 'if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then exit 1; fi' + lint: desc: Lint the application deps: