Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c6179d1
bumpver
Oct 27, 2019
ea065e6
Update README.md
gabeduke Oct 27, 2019
f86accf
tests working
gabeduke Jan 24, 2020
785aecf
structured interface
gabeduke Jan 24, 2020
92bd1e5
add tests
gabeduke Jan 25, 2020
8cf32ad
Merge pull request #39 from gabeduke/refactor-parser
gabeduke Jan 25, 2020
726ca62
add slack handler
gabeduke Jan 27, 2020
b6a3539
add docs
gabeduke Jan 27, 2020
240d0e5
Merge pull request #40 from gabeduke/add-slack
gabeduke Jan 27, 2020
01cb15e
to lower
gabeduke Jan 27, 2020
b112ee6
Merge pull request #41 from gabeduke/add-slack
gabeduke Jan 27, 2020
3d0049b
add cloudbuild
gabeduke Jan 27, 2020
a8fd774
Merge pull request #42 from gabeduke/add-slack
gabeduke Jan 27, 2020
e1ff4c7
add bootstrap
gabeduke Mar 9, 2020
fedb85f
Bump github.com/gin-gonic/gin from 1.4.0 to 1.7.0
dependabot[bot] Aug 12, 2021
834fbfb
Merge pull request #43 from gabeduke/dependabot/go_modules/github.com…
gabeduke Feb 7, 2022
1b19c33
fix configs
gabeduke Feb 7, 2022
7f34dfa
curl head
gabeduke Feb 7, 2022
bd5bec3
use gp fn
gabeduke Feb 7, 2022
4ef2e5c
curl silent
gabeduke Feb 7, 2022
64de1a8
curl fix
gabeduke Feb 7, 2022
3174bba
Add support for querying multiple water level APIs
gabeduke Feb 16, 2025
00d866d
Add WaterLevelAPI interface and implementations for NWS, USGS, and EC…
gabeduke Feb 16, 2025
ad248f0
gabeduke Feb 16, 2025
a082ad2
gabeduke Feb 16, 2025
4022e97
gabeduke Feb 16, 2025
2cbc9ee
gabeduke Feb 16, 2025
461254e
api updates and fix tests
gabeduke Feb 16, 2025
fe06dde
bumpver go in dockerfile
gabeduke Feb 16, 2025
0444e74
bumpver go in dockerfile
gabeduke Feb 16, 2025
a9a87c4
golang-ci lint path
gabeduke Feb 16, 2025
9ab7b5e
fix lint
gabeduke Feb 16, 2025
6cdc055
tune versions for lint
gabeduke Feb 16, 2025
51cf54a
Merge pull request #44 from gabeduke/add-multiple-api-support
gabeduke Jul 6, 2025
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
4 changes: 1 addition & 3 deletions .github/actions/golang/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
FROM golang:1.12

RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.17.1
FROM golang:1.24

RUN apt-get update && \
apt-get install -y jq
Expand Down
23 changes: 15 additions & 8 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,21 @@ on:
- develop

name: Lint
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read

jobs:
lint:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: lint
uses: ./.github/actions/golang
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: lint
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.24
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.64.5
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
CHANGELOG.md
dist
test-results.txt
coverage.txt
coverage.txt

.terraform/
level.tfstate
level.tfstate.backup
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "bootstrap"]
path = bootstrap
url = git@github.com:gabeduke/cloudrun-bootstrap.git
14 changes: 9 additions & 5 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ ports:

# List the start up tasks. You can start them in parallel in multiple terminals. See https://www.gitpod.io/docs/44_config_start_tasks/
tasks:
- init: echo 'init' # runs during prebuild
- name: Init
init: echo 'init' # runs during prebuild
command: go mod download
- command: go run main.go
name: Serve
- openMode: split-bottom
command: until curl -w '\n' --connect-timeout 5 --max-time 10 --retry 5 --retry-delay 0 --retry-connrefused --retry-max-time 40 localhost:8080/api/v1/level ; do echo "retrying.." && sleep 5 ; done
- name: Serve
command: go run main.go
- openMode: tab-after
name: e2e
command: |
gp await-port 8080
curl -w '\n' localhost:8080/api/v1/level
2 changes: 1 addition & 1 deletion .release
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.24
1.0.25
67 changes: 49 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,50 +1,81 @@
include $(CURDIR)/bootstrap/Makefile
SERVICE_NAME := level
VAR_FILE := $(CURDIR)/level.tfvars

# Docker config
TAG ?= latest
IMG ?= level
REGISTRY ?= dukeman
DOCKER_IMG = $(REGISTRY)/$(IMG):$(TAG)
PORT = 8080
MODULE = github.com/gabeduke/level

.DEFAULT_GOAL = help

.PHONY: help fmt test lint docker-build
##########################################################
##@ APP
##########################################################
.PHONY: build dev run

build: swagger ## build container
DOCKER_BUILDKIT=1 docker build -t $(DOCKER_IMG) .

dev: swagger ## run program in dev mode
$(info INFO serving API in 'dev' mode)
LOG_LEVEL=debug go run main.go

run: docker ## run project in container
docker run -p $(PORT):8080 -it $(DOCKER_IMG)

##########################################################
##@ TEST
##########################################################
.PHONY: fmt test lint

fmt: ## fmt project
fmt: ## fmt project
go fmt ./...

test: ## test project
test: ## test project
go test ./... -race -coverprofile=coverage.txt -covermode=atomic

lint: ## lint project
lint: ## lint project
golangci-lint run

swagger: swagger-init swagger-static swagger-readme ## rebuild swagger docs
##########################################################
##@ DOCS
##########################################################
.PHONY: docs swagger swagger-init swagger-static swagger-readme

docs: ## Serve package godocs
$(info http://localhost:6060/pkg/$(MODULE))
godoc -http=localhost:6060

swagger: swagger-init swagger-static swagger-readme ## rebuild swagger docs

swagger-init:
swag init
$(info INFO init swagger)
@swag init

swagger-static:
docker run --rm -v ${PWD}:/local --user $(shell id -u):$(shell id -u) \
$(info INFO generating swagger static files)
@docker run --rm -v ${PWD}:/local --user $(shell id -u):$(shell id -u) \
swaggerapi/swagger-codegen-cli generate \
-i /local/docs/swagger.yaml \
-l html2 \
-o /local/docs

swagger-readme:
docker run --rm \
$(info INFO generating swagger readme)
@docker run --rm \
--user $(shell id -u):$(shell id -u) \
--volume $(shell pwd):/app \
--workdir /app \
node npx markdown-swagger /app/docs/swagger.yaml /app/README.md

build: swagger ## build container
DOCKER_BUILDKIT=1 docker build -t $(DOCKER_IMG) .

dev: swagger ## run program in dev mode
go run main.go

run: docker ## run project in container
docker run -p $(PORT):8080 -it $(DOCKER_IMG)
##########################################################
##@ UTIL
##########################################################
.PHONY: help

help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
help: ## show help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
![](https://github.com/gabeduke/level/workflows/Test/badge.svg)
![](https://github.com/gabeduke/level/workflows/Lint/badge.svg)
![](https://github.com/gabeduke/level/workflows/Fmt/badge.svg)
![](https://github.com/gabeduke/level/workflows/Tag/badge.svg)
![](https://github.com/gabeduke/level/workflows/Release/badge.svg)
[![codecov](https://codecov.io/gh/gabeduke/level/branch/master/graph/badge.svg)](https://codecov.io/gh/gabeduke/level)

# Level
Expand All @@ -16,11 +14,12 @@ Level is an API to query readings from the National Water Service. Readings can
More detailed docs can be found [HERE](https://gabeduke.github.io/level/)

<!-- markdown-swagger -->
Endpoint | Method | Auth? | Description
----------- | ------ | ----- | --------------------
`/healthz` | GET | No | get health
`/level` | GET | No | get level by station
`/stations` | GET | No | get stations
Endpoint | Method | Auth? | Description
----------- | ------ | ----- | -----------------------
`/healthz` | GET | No | get health
`/level` | GET | No | get level by station
`/slack` | POST | No | return a slack response
`/stations` | GET | No | get stations
<!-- /markdown-swagger -->

## Run
Expand All @@ -37,4 +36,11 @@ Try out the API for free on Google Cloud Run:

`make dev` will run the project in Go dev mode

### Bootstrap (terraform)

```bash
git submodule update
make init
make import
make apply
```
1 change: 1 addition & 0 deletions bootstrap
Submodule bootstrap added at 62d384
21 changes: 21 additions & 0 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
steps:
# Build the container image
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', 'gcr.io/leetcloud-173303/github.com/gabeduke/level:snapshot-$BRANCH_NAME', '.']
# Push the image to Container Registry
- name: 'gcr.io/cloud-builders/docker'
args: ['push', 'gcr.io/leetcloud-173303/github.com/gabeduke/level:snapshot-$BRANCH_NAME']
# Deploy image to Cloud Run
- name: 'gcr.io/cloud-builders/gcloud'
args:
- 'run'
- 'deploy'
- 'level'
- '--image'
- 'gcr.io/leetcloud-173303/github.com/gabeduke/level:snapshot-$BRANCH_NAME'
- '--region'
- 'us-east1'
- '--platform'
- 'managed'
images:
- gcr.io/leetcloud-173303/github.com/gabeduke/level
2 changes: 1 addition & 1 deletion docs/.swagger-codegen/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.0-SNAPSHOT
2.4.12
32 changes: 27 additions & 5 deletions docs/docs.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// This file was generated by swaggo/swag at
// 2019-10-22 23:31:48.136136717 -0400 EDT m=+0.234164654
// 2020-01-26 21:20:29.289308664 -0500 EST m=+0.083412855

package docs

Expand Down Expand Up @@ -71,8 +71,30 @@ var doc = `{
],
"responses": {
"200": {},
"417": {
"description": "Expectation Failed",
"424": {
"description": "Failed Dependency",
"schema": {
"$ref": "#/definitions/httputil.HTTPError"
}
}
}
}
},
"/slack": {
"post": {
"description": "return a slack response",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"summary": "return a slack response",
"operationId": "slack",
"responses": {
"200": {},
"424": {
"description": "Failed Dependency",
"schema": {
"$ref": "#/definitions/httputil.HTTPError"
}
Expand All @@ -93,8 +115,8 @@ var doc = `{
"operationId": "stations",
"responses": {
"200": {},
"417": {
"description": "Expectation Failed",
"424": {
"description": "Failed Dependency",
"schema": {
"$ref": "#/definitions/httputil.HTTPError"
}
Expand Down
Loading