Skip to content

Commit 46ccdec

Browse files
authored
Drop platform-specific deployment code and configuration (#79)
1 parent a05101c commit 46ccdec

File tree

11 files changed

+217
-422
lines changed

11 files changed

+217
-422
lines changed

.github/workflows/continuous_delivery.yaml

Lines changed: 0 additions & 105 deletions
This file was deleted.

.github/workflows/lint.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ jobs:
1515
- uses: actions/setup-go@v2
1616
with:
1717
go-version: '1.18'
18-
- name: golangci-lint
19-
uses: golangci/[email protected]
18+
- uses: golangci/[email protected]
2019
with:
2120
version: v1.45.2

.github/workflows/test.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Test
2+
3+
# Translated: "Execute this workflow on pushes to main OR on pull requests
4+
# opened against main"
5+
#
6+
# See this question and answer for what we're solving here:
7+
# https://github.community/t5/GitHub-Actions/How-to-trigger-an-action-on-push-or-pull-request-but-not-both/m-p/36155#M2460
8+
on:
9+
push:
10+
branches: [main]
11+
pull_request:
12+
branches: [main]
13+
14+
jobs:
15+
test:
16+
name: Test
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/setup-go@v2
21+
with:
22+
go-version: '1.18'
23+
24+
- uses: actions/checkout@v2
25+
26+
- run: make testci
27+
28+
- uses: codecov/codecov-action@v1
29+
with:
30+
file: ./coverage.txt
31+
32+
- run: make image
33+
34+
regression_tests:
35+
name: Regression Tests
36+
runs-on: ubuntu-latest
37+
38+
strategy:
39+
matrix:
40+
go_version:
41+
- '1.17'
42+
- '1.16'
43+
44+
steps:
45+
- uses: actions/setup-go@v2
46+
with:
47+
go-version: ${{matrix.go_version}}
48+
49+
- uses: actions/checkout@v2
50+
51+
- run: make test

Makefile

Lines changed: 16 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,7 @@
1-
.PHONY: clean deploy deps gcloud-auth image imagepush lint run stagedeploy test testci testcover
2-
31
# The version that will be used in docker tags (e.g. to push a
42
# go-httpbin:latest image use `make imagepush VERSION=latest)`
5-
VERSION ?= $(shell git rev-parse --short HEAD)
6-
7-
# Override these values to deploy to a different Cloud Run project
8-
GCLOUD_PROJECT ?= httpbingo
9-
GCLOUD_ACCOUNT ?= [email protected]
10-
GCLOUD_REGION ?= us-central1
11-
12-
# The version tag for the Cloud Run deployment (override this to adjust
13-
# pre-production URLs)
14-
GCLOUD_TAG ?= "v-$(VERSION)"
15-
16-
# Run gcloud in a container to avoid needing to install the SDK locally
17-
GCLOUD_COMMAND ?= ./bin/gcloud
18-
19-
# We push docker images to both docker hub and gcr.io
20-
DOCKER_TAG_DOCKERHUB ?= mccutchen/go-httpbin:$(VERSION)
21-
DOCKER_TAG_GCLOUD ?= gcr.io/$(GCLOUD_PROJECT)/go-httpbin:$(VERSION)
3+
VERSION ?= $(shell git rev-parse --short HEAD)
4+
DOCKER_TAG ?= mccutchen/go-httpbin:$(VERSION)
225

236
# Built binaries will be placed here
247
DIST_PATH ?= dist
@@ -41,22 +24,26 @@ GO_SOURCES = $(wildcard **/*.go)
4124
# =============================================================================
4225
build: $(DIST_PATH)/go-httpbin
4326

27+
buildtests: $(DIST_PATH)/go-httpbin.test
28+
4429
$(DIST_PATH)/go-httpbin: $(GO_SOURCES)
4530
mkdir -p $(DIST_PATH)
4631
CGO_ENABLED=0 go build -ldflags="-s -w" -o $(DIST_PATH)/go-httpbin ./cmd/go-httpbin
4732

48-
buildtests:
33+
$(DIST_PATH)/go-httpbin.test: $(GO_SOURCES)
4934
CGO_ENABLED=0 go test -ldflags="-s -w" -v -c -o $(DIST_PATH)/go-httpbin.test ./httpbin
5035

5136
clean:
5237
rm -rf $(DIST_PATH) $(COVERAGE_PATH)
38+
.PHONY: clean
5339

5440

5541
# =============================================================================
5642
# test & lint
5743
# =============================================================================
5844
test:
5945
go test $(TEST_ARGS) ./...
46+
.PHONY: test
6047

6148

6249
# Test command to run for continuous integration, which includes code coverage
@@ -65,77 +52,45 @@ test:
6552
testci: build
6653
go test $(TEST_ARGS) $(COVERAGE_ARGS) ./...
6754
git diff --exit-code
55+
.PHONY: testci
6856

6957
testcover: testci
7058
go tool cover -html=$(COVERAGE_PATH)
59+
.PHONY: testcover
7160

7261
lint: $(TOOL_GOLINT) $(TOOL_STATICCHECK)
7362
test -z "$$(gofmt -d -s -e .)" || (echo "Error: gofmt failed"; gofmt -d -s -e . ; exit 1)
7463
go vet ./...
7564
$(TOOL_GOLINT) -set_exit_status ./...
7665
$(TOOL_STATICCHECK) ./...
66+
.PHONY: lint
7767

7868

7969
# =============================================================================
8070
# run locally
8171
# =============================================================================
8272
run: build
8373
$(DIST_PATH)/go-httpbin
74+
.PHONY: run
8475

8576
watch: $(TOOL_REFLEX)
8677
reflex -s -r '\.(go|html)$$' make run
87-
88-
89-
# =============================================================================
90-
# deploy to fly.io
91-
# =============================================================================
92-
deploy:
93-
flyctl deploy --strategy=rolling
94-
95-
96-
# =============================================================================
97-
# deploy to google cloud run
98-
# =============================================================================
99-
deploy-cloud-run: gcloud-auth imagepush
100-
$(GCLOUD_COMMAND) beta run deploy \
101-
$(GCLOUD_PROJECT) \
102-
--image=$(DOCKER_TAG_GCLOUD) \
103-
--revision-suffix=$(VERSION) \
104-
--tag=$(GCLOUD_TAG) \
105-
--project=$(GCLOUD_PROJECT) \
106-
--region=$(GCLOUD_REGION) \
107-
--allow-unauthenticated \
108-
--platform=managed
109-
$(GCLOUD_COMMAND) run services update-traffic --to-latest
110-
111-
stagedeploy-cloud-run: gcloud-auth imagepush
112-
$(GCLOUD_COMMAND) beta run deploy \
113-
$(GCLOUD_PROJECT) \
114-
--image=$(DOCKER_TAG_GCLOUD) \
115-
--revision-suffix=$(VERSION) \
116-
--tag=$(GCLOUD_TAG) \
117-
--project=$(GCLOUD_PROJECT) \
118-
--region=$(GCLOUD_REGION) \
119-
--allow-unauthenticated \
120-
--platform=managed \
121-
--no-traffic
122-
123-
gcloud-auth:
124-
@$(GCLOUD_COMMAND) auth list | grep '^\*' | grep -q $(GCLOUD_ACCOUNT) || $(GCLOUD_COMMAND) auth login $(GCLOUD_ACCOUNT)
125-
@$(GCLOUD_COMMAND) auth print-access-token | docker login -u oauth2accesstoken --password-stdin https://gcr.io
78+
.PHONY: watch
12679

12780

12881
# =============================================================================
12982
# docker images
13083
# =============================================================================
13184
image:
132-
DOCKER_BUILDKIT=1 docker build -t $(DOCKER_TAG_DOCKERHUB) .
85+
DOCKER_BUILDKIT=1 docker build -t $(DOCKER_TAG) .
86+
.PHONY: image
13387

13488
imagepush:
13589
docker buildx create --name httpbin
13690
docker buildx use httpbin
137-
docker buildx build --push --platform linux/amd64,linux/arm64 -t $(DOCKER_TAG_DOCKERHUB) .
91+
docker buildx build --push --platform linux/amd64,linux/arm64 -t $(DOCKER_TAG) .
13892
docker buildx rm httpbin
93+
.PHONY: imagepush
13994

14095

14196
# =============================================================================

app.yaml

Lines changed: 0 additions & 16 deletions
This file was deleted.

bin/gcloud

Lines changed: 0 additions & 17 deletions
This file was deleted.

cmd/README.md

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)