Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
28 changes: 28 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable

- name: Install dependencies
run: go get .

- name: Formatting
run: if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then gofmt -s -l .; exit 1; fi

- name: Run tests
run: make test
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
BIN_DIR=bin
DIST_DIR=dist
CMD_DIR=cmd
CSV_DIR=csv
EXECUTABLE=gocsv

.DEFAULT_GOAL := bin
Expand All @@ -11,8 +9,7 @@ dist:
bash scripts/build-dist.sh

test:
cd $(CMD_DIR) && go test -cover
cd $(CSV_DIR) && go test -cover
go test -cover ./...

bin:
bash scripts/build-bin.sh
Expand Down
6 changes: 6 additions & 0 deletions cmd/split_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ func TestSplit(t *testing.T) {
if input.Name != "input.csv" {
t.Fatalf("got first file %s; want input.csv", input.Name)
}
currentDir, err := os.Getwd()
if err != nil {
t.Fatal(err)
}
defer os.Chdir(currentDir)
defer os.RemoveAll(tempdir)
// need to change dir to test that calling split without
// a basename works
os.Chdir(tempdir)
Expand Down