diff options
| author | Martin Atkins <mart@degeneration.co.uk> | 2022-02-14 15:54:20 -0800 |
|---|---|---|
| committer | Martin Atkins <mart@degeneration.co.uk> | 2022-02-15 10:26:38 -0800 |
| commit | 4f56414b15e95cf505ae31bfecba9a538cc78c31 (patch) | |
| tree | 7ea34f7d181b05994eba56f0fe58b0c9c58140ff /.github | |
| parent | a9ff6f1153153b9fdc8818e62edd02d1c8e9bac4 (diff) | |
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.
Diffstat (limited to '.github')
| -rw-r--r-- | .github/workflows/push.yml | 53 |
1 files changed, 53 insertions, 0 deletions
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 |
