Skip to content

Commit 1d3d975

Browse files
authored
feat: run bootstrap (#86)
1 parent d4c0271 commit 1d3d975

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+5068
-751
lines changed

.circleci/config.yml

Lines changed: 307 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,307 @@
1+
version: 2.1
2+
3+
commands:
4+
with_job_span:
5+
parameters:
6+
steps:
7+
type: steps
8+
steps:
9+
- run:
10+
name: Creating span for job
11+
command: |-
12+
echo "STEP_START=$(date +%s)" >> $BASH_ENV
13+
echo "STEP_SPAN_ID=$(echo $CIRCLE_JOB | sum | cut -f 1 -d \ )" >> $BASH_ENV
14+
- steps: << parameters.steps >>
15+
- run:
16+
name: Finishing span for job
17+
command: buildevents step "$CIRCLE_WORKFLOW_ID" "$STEP_SPAN_ID" "$STEP_START" "$CIRCLE_JOB"
18+
when: always
19+
20+
jobs:
21+
###Block(circleJobs)
22+
###EndBlock(circleJobs)
23+
send_traces:
24+
docker:
25+
- image: gcr.io/outreach-docker/buildevents:latest
26+
auth:
27+
username: _json_key
28+
password: $GCLOUD_SERVICE_ACCOUNT
29+
steps:
30+
- run:
31+
name: Watch for workflow to finish
32+
command: /tmp/buildevents watch $CIRCLE_WORKFLOW_ID
33+
34+
test: # runs not using Workflows must have a build job as entry point
35+
docker: # run the steps with Docker
36+
# CircleCI Go images available at: https://hub.docker.com/r/cimg/go
37+
- image: gcr.io/outreach-docker/bootstrap/testbed:1.16.2
38+
auth:
39+
username: _json_key
40+
password: $GCLOUD_SERVICE_ACCOUNT
41+
# directory where steps are run.
42+
working_directory: ~/localizer
43+
44+
environment: # environment variables for the build itself
45+
TEST_RESULTS: /tmp/test-results # path to where test results will be saved
46+
GOPRIVATE: github.com/getoutreach/*
47+
GOPROXY: https://proxy.golang.org
48+
###Block(testEnvVars)
49+
###EndBlock(testEnvVars)
50+
51+
steps: # steps that comprise the build job
52+
- with_job_span:
53+
steps:
54+
# adds the ssh key that Wheatley put here for us. Ask Wheatley on slack to "setup circle for <project_name>"
55+
# see https://outreach-io.atlassian.net/wiki/spaces/EN/pages/701596137/Services+Checklist for the setup process
56+
- add_ssh_keys
57+
- checkout
58+
- run: mkdir -p $TEST_RESULTS # create the test results directory
59+
60+
- restore_cache: # restores saved cache if no changes are detected since last run
61+
# Read about caching dependencies: https://circleci.com/docs/2.0/caching/
62+
keys:
63+
# looks for the cache for this go.sum
64+
- v2-pkg-cache-{{ checksum "go.sum" }}
65+
# fallback to the latest cached versions
66+
- v2-pkg-cache-
67+
68+
# we make this a seperate step to prevent obscure SSH error messages
69+
- run:
70+
name: Install Dependencies
71+
command: buildevents cmd $CIRCLE_WORKFLOW_ID $STEP_SPAN_ID install-go-dependencies -- make dep
72+
73+
- run:
74+
name: Run unit tests
75+
# Store the results of our tests in the $TEST_RESULTS directory
76+
command:
77+
buildevents cmd $CIRCLE_WORKFLOW_ID $STEP_SPAN_ID unit-tests --
78+
make test | tee ${TEST_RESULTS}/go-test.out
79+
80+
- run:
81+
name: Upload Code Coverage
82+
command: |
83+
if [[ -n "$COVERALLS_TOKEN" ]]; then
84+
buildevents cmd $CIRCLE_WORKFLOW_ID $STEP_SPAN_ID upload-code-coverage -- \
85+
goveralls -coverprofile=/tmp/coverage.out -service=circle-ci -repotoken=$COVERALLS_TOKEN;
86+
fi
87+
88+
- save_cache:
89+
key: v2-pkg-cache-{{ checksum "go.sum" }}
90+
paths:
91+
- "~/go/pkg"
92+
93+
- store_artifacts: # Upload test coverage for display in Artifacts: https://circleci.com/docs/2.0/artifacts/
94+
path: /tmp/coverage.out
95+
destination: raw-coverage-profile
96+
97+
- store_artifacts: # Upload test summary for display in Artifacts: https://circleci.com/docs/2.0/artifacts/
98+
path: /tmp/test-results
99+
destination: raw-test-output
100+
101+
- store_test_results: # Upload test results for display in Test Summary: https://circleci.com/docs/2.0/collect-test-data/
102+
path: /tmp/test-results
103+
104+
release-dryrun:
105+
docker:
106+
- image: gcr.io/outreach-docker/bootstrap/testbed:1.16.2
107+
auth:
108+
username: _json_key
109+
password: $GCLOUD_SERVICE_ACCOUNT
110+
environment:
111+
GOPRIVATE: github.com/getoutreach/*
112+
GOPROXY: https://proxy.golang.org
113+
steps:
114+
- with_job_span:
115+
steps:
116+
- setup_remote_docker:
117+
docker_layer_caching: true
118+
version: 19.03.13
119+
- checkout
120+
- add_ssh_keys
121+
- run:
122+
name: Setup npm Authentication
123+
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
124+
- run:
125+
name: Configuring Golang SSH
126+
command: |-
127+
git config --global url."git@github.com:".insteadOf "https://github.com/"
128+
- restore_cache:
129+
keys:
130+
- v1-release-node-cache-{{ checksum "package.json" }}
131+
- v1-release-node-cache-
132+
- run:
133+
name: Install semantic-release Dependencies
134+
command: buildevents cmd $CIRCLE_WORKFLOW_ID $STEP_SPAN_ID install-sem-release-dependencies -- yarn --frozen-lockfile
135+
- save_cache:
136+
key: v1-release-node-cache-{{ checksum "package.json" }}
137+
paths:
138+
- node_modules
139+
- run:
140+
name: Release (Dry-run)
141+
command: |-
142+
# Make https://github.com/pvdlg/env-ci/blob/master/services/circleci.js
143+
# think we're not on a PR.
144+
145+
# Store these and set them after
146+
OLD_CIRCLE_PR_NUMBER=$CIRCLE_PR_NUMBER
147+
OLD_CIRCLE_PULL_REQUEST=$CIRCLE_PULL_REQUEST
148+
OLD_CI_PULL_REQUEST=$CI_PULL_REQUEST
149+
OLD_CIRCLE_BRANCH=$CIRCLE_BRANCH
150+
151+
# Fetch the API URL for usage later.
152+
# 19 comes from the length of https://github.com/
153+
export CIRCLE_PR_API_URL=$(echo "https://api.github.com/repos/${CIRCLE_PULL_REQUEST:19}" | sed "s/\/pull\//\/pulls\//")
154+
155+
# Remove evidence of us being on a PR.
156+
unset CIRCLE_PR_NUMBER
157+
unset CIRCLE_PULL_REQUEST
158+
unset CI_PULL_REQUEST
159+
160+
# Fetch the base branch from the API, since CircleCI doesn't expose it.
161+
export CIRCLE_BRANCH=$(curl -s -H "Authorization: token ${OUTREACH_GITHUB_TOKEN}" "$CIRCLE_PR_API_URL" | jq -r '.base.ref')
162+
163+
# Act like we're on the base branch.
164+
git branch -D "$CIRCLE_BRANCH" || true
165+
git checkout -b "$CIRCLE_BRANCH" || true
166+
167+
# Run the releaser now.
168+
GH_TOKEN=$OUTREACH_GITHUB_TOKEN yarn --frozen-lockfile semantic-release --dry-run
169+
170+
export CIRCLE_PR_NUMBER=$OLD_CIRCLE_PR_NUMBER
171+
export CIRCLE_PULL_REQUEST=$OLD_CIRCLE_PULL_REQUEST
172+
export CI_PULL_REQUEST=$OLD_CI_PULL_REQUEST
173+
export CIRCLE_BRANCH=$OLD_CIRCLE_BRANCH
174+
release:
175+
docker:
176+
- image: gcr.io/outreach-docker/bootstrap/testbed:1.16.2
177+
auth:
178+
username: _json_key
179+
password: $GCLOUD_SERVICE_ACCOUNT
180+
environment:
181+
GOPRIVATE: github.com/getoutreach/*
182+
GOPROXY: https://proxy.golang.org
183+
steps:
184+
- with_job_span:
185+
steps:
186+
- setup_remote_docker:
187+
docker_layer_caching: true
188+
version: 19.03.13
189+
- checkout
190+
- add_ssh_keys
191+
- run:
192+
name: Setup npm Authentication
193+
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
194+
- run:
195+
name: Configuring Golang SSH
196+
command: |-
197+
git config --global url."git@github.com:".insteadOf "https://github.com/"
198+
- restore_cache:
199+
keys:
200+
- v1-release-node-cache-{{ checksum "package.json" }}
201+
- v1-release-node-cache-
202+
- run:
203+
name: Install semantic-release Dependencies
204+
command: buildevents cmd $CIRCLE_WORKFLOW_ID $STEP_SPAN_ID install-sem-release-dependencies -- yarn --frozen-lockfile
205+
- save_cache:
206+
key: v1-release-node-cache-{{ checksum "package.json" }}
207+
paths:
208+
- node_modules
209+
- run:
210+
name: Release
211+
command: |
212+
export GH_TOKEN=$OUTREACH_GITHUB_TOKEN
213+
buildevents cmd $CIRCLE_WORKFLOW_ID $STEP_SPAN_ID semantic-release -- yarn --frozen-lockfile semantic-release
214+
215+
trigger_documentation:
216+
docker:
217+
- image: gcr.io/outreach-docker/bootstrap/testbed:1.16.2
218+
auth:
219+
username: _json_key
220+
password: $GCLOUD_SERVICE_ACCOUNT
221+
steps:
222+
- with_job_span:
223+
steps:
224+
- add_ssh_keys
225+
- checkout
226+
227+
# This is needed to download dependencies, which go list needs for some reason.
228+
- restore_cache:
229+
keys:
230+
- v2-pkg-cache-{{ checksum "go.sum" }}
231+
- v2-pkg-cache-
232+
- run:
233+
name: Install Dependencies
234+
command: buildevents cmd $CIRCLE_WORKFLOW_ID $STEP_SPAN_ID install-go-dependencies -- make dep
235+
- save_cache:
236+
key: v2-pkg-cache-{{ checksum "go.sum" }}
237+
paths:
238+
- "~/go/pkg"
239+
240+
- run:
241+
name: Trigger Documentation Update
242+
command: |-
243+
TAG="$CIRCLE_TAG"
244+
if [[ -z "$TAG" ]]; then
245+
# Calculate the psuedo-semver tag, this is used for non-v2 services
246+
# (things without semantic-release, generally)
247+
TAG="v0.0.0-$(TZ=UTC git --no-pager show --quiet --abbrev=12 --date='format-local:%Y%m%d%H%M%S' --format='%cd-%h')"
248+
fi
249+
250+
# We need to use the module path to support major versions properly
251+
MODULE_PATH="$(go list -f '{{ .Path }}' -m)"
252+
URL="https://engdocs.outreach.cloud/fetch/$MODULE_PATH@$TAG"
253+
254+
buildevents cmd $CIRCLE_WORKFLOW_ID $STEP_SPAN_ID deploy-docs -- curl -X POST "$URL"
255+
256+
workflows:
257+
version: 2
258+
###Block(circleWorkflows)
259+
###EndBlock(circleWorkflows)
260+
build_and_test:
261+
jobs:
262+
- send_traces:
263+
context:
264+
- docker-registry
265+
- buildevents
266+
###Block(circleWorkflowJobs)
267+
###EndBlock(circleWorkflowJobs)
268+
- release:
269+
context:
270+
- docker-registry
271+
- buildevents
272+
- npm-credentials
273+
requires:
274+
- test
275+
filters:
276+
branches:
277+
only:
278+
- master
279+
- main
280+
- release-dryrun:
281+
context:
282+
- docker-registry
283+
- buildevents
284+
- npm-credentials
285+
filters:
286+
branches:
287+
ignore:
288+
- master
289+
- main
290+
- test:
291+
context:
292+
- docker-registry
293+
- buildevents
294+
filters:
295+
# This enables running test when a tag is created.
296+
# This still runs on each branch.
297+
tags:
298+
only: /v\d+(\.\d+)*(-.*)*/
299+
- trigger_documentation:
300+
context:
301+
- docker-registry
302+
- buildevents
303+
filters:
304+
branches:
305+
ignore: /.*/
306+
tags:
307+
only: /v[0-9]+(\.[0-9]+)*(-.*)*/

.clang-format

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
Language: Proto
3+
BasedOnStyle: google
4+
PenaltyBreakAssignment: 10000
5+
PenaltyBreakComment: 0
6+
ColumnLimit: 140
7+
AlignConsecutiveAssignments: true
8+
ReflowComments: true
9+
BreakBeforeBinaryOperators: None
10+
---
11+

.editorconfig

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ insert_final_newline = true
88
[Makefile]
99
indent_style = tab
1010

11-
[*.{yml,yaml}]
12-
indent_style = space
11+
[*.go]
12+
indent_style = tab
1313
indent_size = 2
1414

15-
[*.{sh,bash}]
15+
[*.{bash,rb,sh,slim,yml,yaml}]
1616
indent_style = space
1717
indent_size = 2
18-
Terms
18+
19+
###Block(editorconfig)
20+
###EndBlock(editorconfig)

.gitattributes

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
go.sum linguist-generated
2+
*_pb.d.ts linguist-generated
3+
*.pb.go linguist-generated
4+
*_pb.js linguist-generated
5+
*_pb.rb linguist-generated
6+
internal/ent linguist-generated
7+
internal/ent/schema/*.go -text diff=golang
8+
bootstrap.lock linguist-generated

.github/FUNDING.yml

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

.github/pull_request_template.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!-- !!!! README !!!! Please fill this out. -->
2+
3+
4+
<!-- A short description of what your PR does and what it solves. -->
5+
**What this PR does / why we need it**:
6+
7+
**JIRA ID**: XX-XX
8+
9+
<!-- Notes that may be helpful for anyone reviewing this PR -->
10+
**Notes for your reviewer**:

.github/workflows/build.yaml

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

0 commit comments

Comments
 (0)