Skip to content

Commit bdd7afd

Browse files
Merge branch 'main' into fix-buf-version
2 parents e887305 + ed019e1 commit bdd7afd

File tree

12 files changed

+104
-25
lines changed

12 files changed

+104
-25
lines changed

.mise/tasks/docker/build

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
#MISE description="Builds a Docker image for the current application in the dev environment."
3+
4+
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
5+
SHELL_DIR="$DIR/../../../shell"
6+
LIB_DIR="$SHELL_DIR/lib"
7+
8+
# shellcheck source=../../../shell/lib/bootstrap.sh
9+
source "$LIB_DIR"/bootstrap.sh
10+
11+
APP_VERSION="$(get_app_version)" "$SHELL_DIR"/docker-build.sh

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,15 @@ modules:
3333
...
3434
```
3535

36-
CI will now use that branch, to use it locally re-run any `make` command. **Note**: This will not automatically update locally when the remote branch is changed, in order to do that you will need to `rm -rf .bootstrap` and re-run a `make` command. If you are testing changes to `make e2e`, you must also run
36+
CI will now use that branch, to use it locally re-run any `make` command.
37+
38+
> [!NOTE]
39+
> This will not automatically update locally when the remote branch is changed, in order to do that you will need to `rm -rf .bootstrap` and re-run a `make` command. If you are testing changes to `make e2e`, you must also run
3740
`rm -rf ~/.outreach/.cache/gobin/binaries/$(go version | awk '{ print $3 }' | tr -d 'go')/github.com/getoutreach/devbase` before re-running a make command, in addition to `rm -rf .bootstrap`.
3841

42+
> [!WARNING]
43+
> If you run `stencil` while using the custom build, your manual changes to `stencil.lock` will be erased and replaced with the `devbase` version specified by `service.yaml`. You will need to restore the branch name manually after `stencil` completes.
44+
3945
## Building Docker Images
4046

4147
Docker images can be built by creating a `docker.yaml` file in the `deployments/` directory of a repository. The format of this file is as follows:

root/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,10 @@ debug:: pre-debug
212212
@if [[ -n $$DLV_PORT ]]; then DEVBOX_LOGFMT="$(LOGFMT)" ./scripts/shell-wrapper.sh debug.sh; fi
213213
@if [[ -z $$DLV_PORT ]]; then OUTREACH_ACCOUNTS_BASE_URL=$(ACCOUNTS_URL) MY_NAMESPACE=$(E2E_NAMESPACE) OUTREACH_DOMAIN=$(OUTREACH_DOMAIN) ./scripts/shell-wrapper.sh debug.sh; fi
214214

215-
## docker-build: build docker image for dev environment
215+
## docker-build: [DEPRECATED] build docker image for dev environment
216216
.PHONY: docker-build
217217
docker-build:: pre-docker-build
218-
@./scripts/shell-wrapper.sh docker-build.sh
218+
@./scripts/shell-wrapper.sh deprecated-task.sh docker-build docker:build
219219

220220
## fmt: run source code formatters
221221
.PHONY: fmt

shell/ci/release/dryrun.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,13 @@ if ! git diff --quiet "$OLD_CIRCLE_BRANCH"; then
5858
git merge --squash "$OLD_CIRCLE_BRANCH"
5959
git commit -m "$COMMIT_MESSAGE"
6060

61-
GH_TOKEN="$(github_token)"
62-
if [[ -z $GH_TOKEN ]]; then
61+
GITHUB_TOKEN="$(github_token)"
62+
if [[ -z $GITHUB_TOKEN ]]; then
6363
warn "Failed to read Github personal access token" >&2
6464
fi
6565

66-
GH_TOKEN="$GH_TOKEN" yarn --frozen-lockfile semantic-release --dry-run
66+
MISE_GITHUB_TOKEN="$GITHUB_TOKEN" GH_TOKEN="$GITHUB_TOKEN" \
67+
yarn --frozen-lockfile semantic-release --dry-run
6768

6869
# Handle prereleases for CLIs, pre-conditions for this exist
6970
# in the script.

shell/ci/release/release.sh

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@ LIB_DIR="${DIR}/../../lib"
88
# shellcheck source=../../lib/github.sh
99
source "${LIB_DIR}/github.sh"
1010

11+
# shellcheck source=../../lib/logging.sh
12+
source "${LIB_DIR}/logging.sh"
13+
1114
# Retrieve the GH_TOKEN
12-
GH_TOKEN="$(github_token)"
13-
if [[ -z $GH_TOKEN ]]; then
14-
echo "Failed to read GitHub personal access token" >&2
15+
GITHUB_TOKEN="$(github_token)"
16+
if [[ -z $GITHUB_TOKEN ]]; then
17+
error "Failed to read GitHub personal access token"
1518
fi
1619

1720
send_failure_notification() {
1821
if [[ -z $RELEASE_FAILURE_SLACK_CHANNEL ]]; then
19-
echo "Failed to release"
20-
exit 1
22+
fatal "Failed to release"
2123
fi
2224

2325
curl -X POST "$RELEASE_FAILURE_WEBHOOK" \
@@ -26,9 +28,6 @@ send_failure_notification() {
2628
exit 1
2729
}
2830

29-
# shellcheck source=../../lib/logging.sh
30-
source "${LIB_DIR}/logging.sh"
31-
3231
# shellcheck source=../../lib/bootstrap.sh
3332
source "${LIB_DIR}/bootstrap.sh"
3433

@@ -44,5 +43,5 @@ unset CI_PULL_REQUEST
4443
unset CI_PULL_REQUESTS
4544

4645
# Unset NPM_TOKEN to force it to use the configured ~/.npmrc
47-
NPM_TOKEN='' GH_TOKEN=$GH_TOKEN \
46+
NPM_TOKEN='' MISE_GITHUB_TOKEN="$GITHUB_TOKEN" GH_TOKEN="$GITHUB_TOKEN" \
4847
yarn --frozen-lockfile semantic-release || send_failure_notification

shell/circleci/machine.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,6 @@ fi
4949
if ! command -v aws >/dev/null; then
5050
install_tool_with_mise aws-cli
5151
fi
52+
53+
# Tiny app to work around GitHub token rate limits
54+
install_tool_with_mise wait-for-gh-rate-limit

shell/circleci/setup.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
66
CI_DIR="$DIR/../ci"
77
LIB_DIR="$DIR/../lib"
88

9+
# shellcheck source=../lib/bootstrap.sh
10+
source "${LIB_DIR}/bootstrap.sh"
11+
912
# shellcheck source=../lib/circleci.sh
1013
source "${LIB_DIR}/circleci.sh"
1114

15+
# shellcheck source=../lib/github.sh
16+
source "${LIB_DIR}/github.sh"
17+
1218
# shellcheck source=../lib/logging.sh
1319
source "${LIB_DIR}/logging.sh"
1420

@@ -18,6 +24,12 @@ source "${LIB_DIR}/mise.sh"
1824
# shellcheck source=../lib/shell.sh
1925
source "${LIB_DIR}/shell.sh"
2026

27+
if gh_installed; then
28+
# shellcheck disable=SC2119
29+
# Why: no extra args needed to pass to ghaccesstoken in this case.
30+
bootstrap_github_token
31+
fi
32+
2133
if [[ -z $ALLOW_MISE_TO_MANAGE_TOOL_VERSIONS ]]; then
2234
# Ensure that asdf is ready to be used
2335
info "🔨 Setting up asdf"

shell/devspace_start.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
66
# shellcheck source=./lib/box.sh
77
source "$DIR/lib/box.sh"
88

9+
# Trust mise config in app
10+
mise trust --cd /home/dev/app
11+
912
GH_NO_UPDATE_NOTIFIER=true gh auth setup-git
1013

1114
# SSH -> HTTPS, since we're not using SSH keys

shell/docker-build.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
#!/usr/bin/env bash
22
# Builds a Docker image for the current application in the dev environment.
3+
#
4+
# External environment variables accepted:
5+
#
6+
# * `APP_VERSION` (REQUIRED)
7+
# * `DOCKERFILE` (defaults to `deployments/$app/Dockerfile`)
8+
# * `DOCKER_BUILD_EXTRA_ARGS` (extra arguments to `docker build`,
9+
# defaults to empty string)
310

411
set -eo pipefail
512

@@ -17,9 +24,13 @@ source "${LIB_DIR}/logging.sh"
1724
# shellcheck source=./lib/docker.sh
1825
source "${LIB_DIR}/docker.sh"
1926

27+
if [[ -z ${APP_VERSION:-} ]]; then
28+
fatal "Please specify APP_VERSION"
29+
fi
30+
2031
appName="$(get_app_name)"
2132

22-
if [[ -z $DOCKERFILE ]]; then
33+
if [[ -z ${DOCKERFILE:-} ]]; then
2334
DOCKERFILE="deployments/$appName/Dockerfile"
2435
fi
2536

@@ -41,5 +52,5 @@ DOCKER_BUILDKIT=1 docker build \
4152
--ssh default "${tags[@]}" \
4253
-f "$DOCKERFILE" \
4354
. \
44-
--build-arg VERSION="$APP_VERSION" \
45-
$DOCKER_BUILD_EXTRA_ARGS
55+
--build-arg VERSION="${APP_VERSION:-}" \
56+
${DOCKER_BUILD_EXTRA_ARGS:-}

shell/lib/github.sh

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
#!/usr/bin/env bash
22
# Contains various helper functions for interacting with Github.
3+
#
4+
# Requires the following libraries:
5+
# * logging.sh (required by mise.sh)
6+
# * mise.sh
7+
# * shell.sh (required by mise.sh)
8+
#
9+
# Setting the GitHub token requires bootstrap.sh.
310

411
# LIB_DIR is the directory that shell script libraries live in.
512
LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
@@ -14,14 +21,21 @@ source "$LIB_DIR/shell.sh"
1421
ghCmd=""
1522

1623
# Looks for gh in the PATH or in the mise environment.
17-
run_gh() {
24+
gh_installed() {
1825
if [[ -z $ghCmd ]]; then
1926
ghCmd="$(find_tool gh)"
2027
if [[ -z $ghCmd ]]; then
21-
error "gh not found in mise environment (run_gh)"
28+
error "gh not found in mise environment (gh_installed)"
2229
return 1
2330
fi
2431
fi
32+
}
33+
34+
# Runs gh if found, otherwise fails.
35+
run_gh() {
36+
if ! gh_installed; then
37+
return 1
38+
fi
2539

2640
"$ghCmd" "$@"
2741
}
@@ -98,6 +112,7 @@ bootstrap_github_token() {
98112

99113
# Print the GitHub token from getoutreach/ci:ghaccesstoken. Any
100114
# arguments are passed to `ghaccesstoken token`.
115+
# Requires lib/bootstrap.sh for `get_tool_version`.
101116
fetch_github_token_from_ci() {
102117
(
103118
local version
@@ -115,7 +130,7 @@ fetch_github_token_from_ci() {
115130
ghaccesstoken_exists() {
116131
local version="$1"
117132
local ghaccesstoken_path
118-
ghaccesstoken_path="$(mise which ghaccesstoken 2>/dev/null)"
133+
ghaccesstoken_path="$(find_tool ghaccesstoken 2>/dev/null)"
119134
if [[ -z $ghaccesstoken_path ]]; then
120135
return 1
121136
fi

0 commit comments

Comments
 (0)