diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..77252a5c --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,25 @@ +name: Lint +on: + push: + branches: + - main + pull_request: +permissions: + contents: read +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: shellcheck + run: | + sudo apt-get -y install tree + dev/lint-shellcheck + - uses: actions/setup-go@v3 + with: + go-version-file: go.mod + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + args: --timeout=5m --config dev/.golangci.yaml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..acbcebcd --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,33 @@ +name: Test +on: + push: + branches: + - main + pull_request: +jobs: + test: + name: Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version-file: go.mod + - run: dev/docker/up + - name: Run Tests + run: | + export GOPATH="${HOME}/go/" + export PATH="${PATH}:${GOPATH}/bin" + go install github.com/jstemmer/go-junit-report/v2@latest + go test -v ./... | go-junit-report -set-exit-code -iocopy -out report.xml + - name: Run Race Tests + run: | + export GOPATH="${HOME}/go/" + export PATH="${PATH}:${GOPATH}/bin" + go test -v ./... -race + - uses: datadog/junit-upload-github-action@v1 + with: + api-key: ${{ secrets.DD_API_KEY }} + service: xmtp-node-go + files: report.xml + env: ci diff --git a/.vscode/settings.json b/.vscode/settings.json index f11a28f2..12fb01d4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,6 @@ { + "go.lintTool": "golangci-lint", + "go.lintFlags": ["--fast"], "pgFormatter.typeCase": "uppercase", "pgFormatter.tabs": true, "[sql]": { diff --git a/dev/lint-shellcheck b/dev/lint-shellcheck new file mode 100755 index 00000000..117f034b --- /dev/null +++ b/dev/lint-shellcheck @@ -0,0 +1,5 @@ +#!/bin/bash +set -e + +read -ra shellcheck_paths <<< "$(grep -rIzl '^#!' dev)" +shellcheck -x "${shellcheck_paths[@]}"