From b53a9069308615a1ab66bbd9a920b53c3799e75e Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Sat, 27 Jul 2024 21:06:26 -0700 Subject: [PATCH] add github actions --- .github/workflows/lint.yml | 25 +++++++++++++++++++++++++ .github/workflows/test.yml | 33 +++++++++++++++++++++++++++++++++ .vscode/settings.json | 2 ++ dev/lint-shellcheck | 5 +++++ 4 files changed, 65 insertions(+) create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/test.yml create mode 100755 dev/lint-shellcheck 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[@]}"