From 52f70d95eb70ac4e95715d6b75fec1a98f3f35fa Mon Sep 17 00:00:00 2001 From: diamondburned Date: Tue, 31 Jan 2023 00:31:46 -0800 Subject: [PATCH] *: Add GitHub Actions (#371) *: Add shell.nix for development *: Add test workflow --- .github/workflows/test.yml | 40 ++++++++++++++++++++++++++++++++++++++ shell.nix | 11 +++++++++++ 2 files changed, 51 insertions(+) create mode 100644 .github/workflows/test.yml create mode 100644 shell.nix diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..3001e18 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,40 @@ +name: Test + +on: + push: + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Install Nix packages + uses: diamondburned/cache-install@0746911c01dc84bba95d35be82db09435537d8ca + + - name: Generate + run: | + go generate ./... + + if ! git diff --exit-code; then + echo '::error::Repository differ after `go generate`.' + exit 1 + fi + + - name: Build + run: | + go build ./... + + - name: Test + run: | + go test -coverprofile /tmp/coverage.out -race ./... + go tool cover -func /tmp/coverage.out + env: + BOT_TOKEN: ${{ secrets.BOT_TOKEN }} + + - name: Upload coverage profile + uses: actions/upload-artifact@v3 + with: + name: coverage + path: /tmp/coverage.out diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..ac43e15 --- /dev/null +++ b/shell.nix @@ -0,0 +1,11 @@ +{ pkgs ? import {} }: + +pkgs.mkShell { + buildInputs = with pkgs; [ + go + gopls + go-tools + ]; + + CGO_ENABLED = "1"; +}