From 4f56414b15e95cf505ae31bfecba9a538cc78c31 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Mon, 14 Feb 2022 15:54:20 -0800 Subject: build: Per-commit checks with GitHub Actions We previously used CircleCI for this but we no longer have CircleCI enabled for this repository and so we've been left with no automatic checks. This is an alternative check workflow implemented with GitHub Actions. This isn't as complex/comprehensive as the CircleCI workflow that came before it, but my initial goal here is only to have some basic automatic feedback on new PRs as a starting point; we can expand this later if we want to reintroduce other features such as code coverage reports. --- .github/workflows/push.yml | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/push.yml (limited to '.github') diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 0000000..a28f8f8 --- /dev/null +++ b/.github/workflows/push.yml @@ -0,0 +1,53 @@ +name: Per-commit Checks + +on: + push: + +jobs: + unit_tests: + strategy: + matrix: + include: + - runs-on: ubuntu-latest + target: linux_amd64 + - runs-on: windows-latest + target: windows_amd64 + fail-fast: false + + name: "Unit Tests on ${{ matrix.target }}" + runs-on: "${{ matrix.runs-on }}" + steps: + - name: "Disable git crlf conversions" + if: ${{ runner.os == 'Windows' }} + # HCL preserves the input line endings when processing a heredoc, + # and our tests for heredocs are written to expect the result for + # the source code as checked in to the repository, so git's normal + # tampering with the line endings would invalidate those tests. + run: | + git config --global core.autocrlf false + - name: "Fetch source code" + uses: actions/checkout@v2 + - name: Go test + run: | + go test ./... + + fmt_and_vet: + name: "fmt and lint" + runs-on: ubuntu-latest + + steps: + - name: "Fetch source code" + uses: actions/checkout@v2 + - name: "Check vet" + run: | + go vet ./... + - name: "Check fmt" + run: | + go fmt ./... + if [[ -z "$(git status --porcelain)" ]]; then + echo "Formatting is consistent with 'go fmt'." + else + echo "Run 'go fmt ./...' to automatically apply standard Go style to all packages." + git status --porcelain + exit 1 + fi -- cgit v1.2.3