Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Initial setup for integration tests #80

Merged
merged 19 commits into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adds github fmt, lint, test ci
  • Loading branch information
cmoog committed Jul 28, 2020
commit f11304ba32c6d27f9d0caf875e48163890440a92
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v1
- name: Build
run: ./ci/build.sh
run: ./ci/steps/build.sh
- name: Upload
uses: actions/upload-artifact@v2
with:
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: ci
on: [push, pull_request]

jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: fmt
uses: ./ci/image
with:
args: ./ci/steps/fmt.sh
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: lint
uses: ./ci/image
with:
args: ./ci/steps/lint.sh
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: test
uses: ./ci/image
with:
args: go test ./...
8 changes: 8 additions & 0 deletions ci/image/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM golang:1

ENV GOFLAGS="-mod=readonly"
ENV CI=true

RUN go get golang.org/x/tools/cmd/goimports
RUN go get golang.org/x/lint/golint
RUN go get github.com/mattn/goveralls
4 changes: 2 additions & 2 deletions ci/build.sh → ci/steps/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ mkdir -p bin

build(){
tmpdir=$(mktemp -d)
go build -ldflags "-s -w -X main.version=${tag}" -o "$tmpdir/coder" ../cmd/coder
go build -ldflags "-s -w -X main.version=${tag}" -o "$tmpdir/coder" ../../cmd/coder

pushd "$tmpdir"
tarname="coder-cli-$GOOS-$GOARCH.tar.gz"
tar -czf "$tarname" coder
popd

cp "$tmpdir/$tarname" bin
cp "$tmpdir/$tarname" ../bin
rm -rf "$tmpdir"
}

Expand Down
16 changes: 16 additions & 0 deletions ci/steps/fmt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
echo "Formatting..."

go mod tidy
gofmt -w -s .
goimports -w "-local=$$(go list -m)" .

if [ "$CI" != "" ]; then
if [[ $(git ls-files --other --modified --exclude-standard) != "" ]]; then
echo "Files need generation or are formatted incorrectly:"
git -c color.ui=always status | grep --color=no '\e\[31m'
echo "Please run the following locally:"
echo " ./ci/fmt.sh"
exit 1
fi
fi
6 changes: 6 additions & 0 deletions ci/steps/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

echo "Linting..."

go vet ./...
golint -set_exit_status ./...