Skip to content

Commit

Permalink
ci: run code verification steps in pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
kylehoehns committed Nov 22, 2023
1 parent 7e61daf commit abd6cd1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ jobs:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: 1.21
run: go mod tidy

- name: Verify
run: scripts/verify .

- name: Build
run: go build -v ./...
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ go run puzzles/day00/main.go
To create a template of files needed for a new day's puzzle, run the following command.

```shell
./scripts/create-day.sh 01
./scripts/create-day 01
```

This will create a new folder named `day01` pre-created with files for the main code, test code, and input files.
File renamed without changes.
19 changes: 19 additions & 0 deletions scripts/verify
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#! /bin/bash
set -e

echo "Verifying formatting..."

FILES=$(find $1 -name '*.go')
GOFMT_RESULT=$(gofmt -d -s $FILES 2>&1)

if [[ ${#GOFMT_RESULT} != 0 ]]; then
echo "Files are not formatted correctly:"
echo "$GOFMT_RESULT"
exit 1
else
echo "All files are formatted correctly."
fi

echo "Vetting source files..."
go vet ./...
echo "Source files vetted."
1 change: 1 addition & 0 deletions template/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ func main() {
}

func part1(name string) int {
fmt.Printf("Part 1: %s%s\n", name)
return 0
}

Expand Down

0 comments on commit abd6cd1

Please sign in to comment.