Skip to content

Commit 40fc8c5

Browse files
authored
Merge pull request #5167 from nulib/deploy/staging
Deploy v10.3.1 to production
2 parents 7a7a100 + 8d93c0f commit 40fc8c5

File tree

257 files changed

+18438
-17198
lines changed

Some content is hidden

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

257 files changed

+18438
-17198
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
!livebook/**/*
44
app/.dockerignore
55
app/.elixir_ls
6+
app/.expert
67
app/.git
8+
app/.lexical
79
app/_build
810
app/assets/coverage
911
app/**/node_modules

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Brief high level description of this feature or fix
44
# Specific Changes in this PR
55
- list changes
66
- list changes
7+
78
# Version bump required by the PR
89

910
See [Semantic Versioning 2.0.0](https://semver.org/) for help discerning which is required.
@@ -38,11 +39,10 @@ Also please let developers know if there are any special instructions to test th
3839
- [ ] Requires data migration
3940
- [ ] Requires database triggers disabled during deployment/migration
4041
- [ ] Requires reindex
41-
- [ ] Terraform changes
42-
- [ ] Adds/requires new or changed Terraform variables
43-
- [ ] Pipeline configuration changes (requires `mix meadow.pipeline.setup` run)
44-
- [ ] Requires new variable added to `miscellany`
45-
- [ ] Specific deployment synchronization instructions with other apps/API's
42+
- [ ] Requires `terraform apply`
43+
- [ ] Adds/requires new or changed `ENVIRONMENT.tfvars` variables
44+
- [ ] Requires `sam deploy`
45+
- [ ] Adds/requires new or changed `samconfig.yaml` variables
4646
- [ ] Other specific instructions/tasks
4747

4848

.github/scripts/upload_source_maps.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ docker pull $MEADOW_IMAGE
44
container_id=$(docker create ${MEADOW_IMAGE})
55
docker cp ${container_id}:/app/lib/meadow-${MEADOW_VERSION}/priv/static/js ${container_id}
66
cd $container_id
7-
for minified_file in app*.js app*.css; do
7+
for minified_file in app*.js; do
88
source_map=$(tail -1 $minified_file | sed -E 's/^.+sourceMappingURL=\W*(\S+).*$/\1/')
99
for ext in "" ".gz"; do
1010
curl https://api.honeybadger.io/v1/source_maps \

.github/workflows/deploy.yml

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-latest
1818
outputs:
1919
deploy_env: ${{ steps.set-deploy-env.outputs.result }}
20-
container_tag: ${{ steps.set-container-tag.outputs.result }}
20+
image_tag: ${{ steps.set-image-tag.outputs.result }}
2121
meadow_tenant: ${{ steps.set-meadow-prefix.outputs.result }}
2222
steps:
2323
- name: Set DEPLOY_ENV from Branch Name
@@ -30,8 +30,8 @@ jobs:
3030
fi
3131
env:
3232
BRANCH: ${{ github.ref }}
33-
- name: Set container tag from DEPLOY_ENV
34-
id: set-container-tag
33+
- name: Set image tag from DEPLOY_ENV
34+
id: set-image-tag
3535
run: |
3636
if [[ $DEPLOY_ENV == 'production' || $DEPLOY_ENV == 'staging' ]]; then
3737
echo "result=latest" >> $GITHUB_OUTPUT
@@ -53,15 +53,15 @@ jobs:
5353
- name: Output Environment Info
5454
run: |
5555
echo "Deploying to environment: ${{ steps.set-deploy-env.outputs.result }}"
56-
echo "Using container tag: ${{ steps.set-container-tag.outputs.result }}"
56+
echo "Using image tag: ${{ steps.set-image-tag.outputs.result }}"
5757
echo "Using meadow tenant prefix: ${{ steps.set-meadow-prefix.outputs.result }}"
5858
build:
5959
if: ${{ !github.event.pull_request && !contains(github.event.head_commit.message, '[no-deploy]') }}
6060
runs-on: ubuntu-latest
6161
needs: get-environment
6262
env:
6363
DEPLOY_ENV: ${{ needs.get-environment.outputs.deploy_env }}
64-
CONTAINER_TAG: ${{ needs.get-environment.outputs.container_tag }}
64+
IMAGE_TAG: ${{ needs.get-environment.outputs.image_tag }}
6565
MEADOW_TENANT: ${{ needs.get-environment.outputs.meadow_tenant }}
6666
steps:
6767
- uses: actions/checkout@v2
@@ -72,9 +72,8 @@ jobs:
7272
GITHUB_ENV: ${{ env.GITHUB_ENV }}
7373
SECRETS: ${{ toJSON(secrets) }}
7474
- name: Extract MEADOW_VERSION from mix.exs
75-
run: echo "MEADOW_VERSION=$(grep '@app_version "' mix.exs | sed -n 's/^.*"\(.*\)".*/\1/p')" >> $GITHUB_ENV
76-
working-directory: app
77-
- run: echo "Building Meadow v${MEADOW_VERSION} as nulib/meadow:${CONTAINER_TAG}"
75+
run: echo "MEADOW_VERSION=$(make app-version)" >> $GITHUB_ENV
76+
- run: echo "Building Meadow v${MEADOW_VERSION} as nulib/meadow:${IMAGE_TAG}"
7877
- name: Tag Meadow Release
7978
if: ${{ github.ref == 'refs/heads/main' }}
8079
run: |
@@ -86,42 +85,45 @@ jobs:
8685
- name: Login to Amazon ECR
8786
id: login-ecr
8887
uses: aws-actions/amazon-ecr-login@v1
89-
- name: Determine container tags
90-
id: determine-container-tags
88+
- name: Determine image tags
89+
id: determine-image-tags
9190
run: |
9291
{
9392
echo "tags<<EOF"
94-
echo "${REGISTRY_NAME}/meadow:${CONTAINER_TAG}"
95-
if [[ ${CONTAINER_TAG} == "latest" ]]; then
93+
echo "${REGISTRY_NAME}/meadow:${IMAGE_TAG}"
94+
if [[ ${IMAGE_TAG} == "latest" ]]; then
9695
echo "${REGISTRY_NAME}/meadow:${MEADOW_VERSION}"
9796
fi
9897
echo "EOF"
9998
} >> $GITHUB_OUTPUT
10099
env:
101100
REGISTRY_NAME: ${{ steps.login-ecr.outputs.registry }}
102-
- name: Set Meadow Release Name
103-
id: meadow-release
104-
run: echo "name=meadow-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
101+
- name: Set Build Options
102+
id: build-options
103+
run: |
104+
echo "release_name=meadow-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
105+
echo "build_image=$(make build-image)" >> $GITHUB_OUTPUT
106+
echo "runtime_image=$(make runtime-image)" >> $GITHUB_OUTPUT
105107
- uses: docker/build-push-action@v2
106108
with:
107109
context: ./app
108110
push: true
109-
tags: ${{ steps.determine-container-tags.outputs.tags }}
111+
tags: ${{ steps.determine-image-tags.outputs.tags }}
110112
build-args: |
111-
BUILD_IMAGE=hexpm/elixir:1.18.2-erlang-27.3-debian-bookworm-20250224
112-
RUNTIME_IMAGE=node:22-bookworm-slim
113+
BUILD_IMAGE=${{ steps.build-options.outputs.build_image }}
114+
RUNTIME_IMAGE=${{ steps.build-options.outputs.runtime_image }}
113115
HONEYBADGER_API_KEY=${{ secrets.HONEYBADGER_API_KEY }}
114116
HONEYBADGER_API_KEY_FRONTEND=${{ secrets.HONEYBADGER_API_KEY_FRONTEND }}
115117
HONEYBADGER_ENVIRONMENT=${{ env.DEPLOY_ENV }}
116118
HONEYBADGER_REVISION=${{ github.sha }}
117-
RELEASE_NAME=${{ steps.meadow-release.outputs.name }}
119+
RELEASE_NAME=${{ steps.build-options.outputs.release_name }}
118120
MEADOW_TENANT=${{ env.MEADOW_TENANT }}
119121
MEADOW_VERSION=${{ env.MEADOW_VERSION }}
120122
- name: Upload Source Maps to Honeybadger
121123
run: .github/scripts/upload_source_maps.sh
122124
env:
123125
DEPLOY_ENV: ${{ env.DEPLOY_ENV }}
124-
MEADOW_IMAGE: ${{ steps.login-ecr.outputs.registry }}/meadow:${{ env.CONTAINER_TAG }}
126+
MEADOW_IMAGE: ${{ steps.login-ecr.outputs.registry }}/meadow:${{ env.IMAGE_TAG }}
125127
MEADOW_VERSION: ${{ env.MEADOW_VERSION }}
126128
HONEYBADGER_API_KEY_FRONTEND: ${{ secrets.HONEYBADGER_API_KEY_FRONTEND }}
127129
HONEYBADGER_REVISION: ${{ github.sha }}
@@ -150,13 +152,12 @@ jobs:
150152
needs: get-environment
151153
env:
152154
DEPLOY_ENV: ${{ needs.get-environment.outputs.deploy_env }}
153-
CONTAINER_TAG: ${{ needs.get-environment.outputs.container_tag }}
155+
IMAGE_TAG: ${{ needs.get-environment.outputs.image_tag }}
154156
MEADOW_TENANT: ${{ needs.get-environment.outputs.meadow_tenant }}
155157
steps:
156158
- uses: actions/checkout@v2
157159
- name: Extract MEADOW_VERSION from mix.exs
158-
run: echo "MEADOW_VERSION=$(grep '@app_version "' mix.exs | sed -n 's/^.*"\(.*\)".*/\1/p')" >> $GITHUB_ENV
159-
working-directory: app
160+
run: echo "MEADOW_VERSION=$(make app-version)" >> $GITHUB_ENV
160161
- name: Configure AWS
161162
run: .github/scripts/configure_aws.sh
162163
env:
@@ -168,13 +169,13 @@ jobs:
168169
- name: Login to Amazon ECR
169170
id: login-ecr
170171
uses: aws-actions/amazon-ecr-login@v1
171-
- name: Determine container tags
172-
id: determine-container-tags
172+
- name: Determine image tags
173+
id: determine-image-tags
173174
run: |
174175
{
175176
echo "tags<<EOF"
176-
echo "${REGISTRY_NAME}/meadow:livebook-${CONTAINER_TAG}"
177-
if [[ ${CONTAINER_TAG} == "latest" ]]; then
177+
echo "${REGISTRY_NAME}/meadow:livebook-${IMAGE_TAG}"
178+
if [[ ${IMAGE_TAG} == "latest" ]]; then
178179
echo "${REGISTRY_NAME}/meadow:livebook-${MEADOW_VERSION}"
179180
fi
180181
echo "EOF"
@@ -186,7 +187,7 @@ jobs:
186187
context: .
187188
file: ./Dockerfile.livebook
188189
push: true
189-
tags: ${{ steps.determine-container-tags.outputs.tags }}
190+
tags: ${{ steps.determine-image-tags.outputs.tags }}
190191
deploy:
191192
needs:
192193
- get-environment
@@ -196,7 +197,7 @@ jobs:
196197
runs-on: ubuntu-latest
197198
env:
198199
DEPLOY_ENV: ${{ needs.get-environment.outputs.deploy_env }}
199-
CONTAINER_TAG: ${{ needs.get-environment.outputs.container_tag }}
200+
IMAGE_TAG: ${{ needs.get-environment.outputs.image_tag }}
200201
MEADOW_TENANT: ${{ needs.get-environment.outputs.meadow_tenant }}
201202
steps:
202203
- uses: actions/checkout@v2

.github/workflows/test.yml

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,8 @@ jobs:
2323
run: npm install -g npm@${{ env.NPM_VERSION }}
2424
env:
2525
NPM_VERSION: 11.6.0
26-
- name: Install JS dependencies
27-
run: |
28-
npm ci --force --no-fund
29-
npm list
30-
working-directory: app/assets
31-
- name: JS Static Analysis
32-
run: npm run-script prettier
33-
working-directory: app/assets
34-
- name: JS Tests
35-
run: npm run-script ci:silent -- -w 1
36-
working-directory: app/assets
37-
- name: Test ESBuild
38-
run: npm run-script deploy
39-
working-directory: app/assets
26+
- name: Frontend CI
27+
run: make app-frontend-ci
4028
elixir-test:
4129
runs-on: ubuntu-latest
4230
env:
@@ -69,15 +57,11 @@ jobs:
6957
${{ runner.os }}-hex-v6-${{ hashFiles('app/mix.lock') }}
7058
${{ runner.os }}-hex-v6-
7159
- name: Install Elixir dependencies
72-
run: mix do deps.get, compile
73-
working-directory: app
60+
run: make app-compile
7461
env:
7562
MIX_ENV: test
76-
- name: Install Claude Code
77-
run: npm install -g @anthropic-ai/claude-code
7863
- name: Elixir Static Analysis
79-
run: mix credo
80-
working-directory: app
64+
run: make app-lint
8165
- name: Wait for services to be ready
8266
run: timeout 120 bash -c 'while ! ./all-healthy.sh; do sleep 2; done'
8367
working-directory: ./infrastructure/localstack
@@ -86,13 +70,12 @@ jobs:
8670
- name: Provision Localstack using Terraform
8771
run: make localstack-provision
8872
- name: Elixir Tests
89-
run: mix test || mix test --seed $(cat ${MEADOW_TEST_SAVE_SEED}) --failed
73+
run: make app-test
9074
env:
9175
AWS_LOCALSTACK: true
9276
USE_SAM_LAMBDAS: true
9377
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9478
MEADOW_TEST_SAVE_SEED: ${{ runner.temp }}/MEADOW_TEST_SEED
95-
working-directory: app
9679
# - name: Test DB Rollback
9780
# run: mix ecto.rollback --all
9881
# working-directory: app

.gitignore

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ npm-debug.log
5151
*.tfvars
5252

5353
/infrastructure/**/.aws-sam
54+
/infrastructure/**/.localstack/
5455
/infrastructure/**/.terraform/
5556
/infrastructure/**/*.tfstate*
5657
/infrastructure/**/_build/
@@ -78,18 +79,18 @@ yarn.lock
7879

7980
**/*.pid
8081

81-
lambdas/stream-authorizer/config
8282
.env
8383
AGENT.md
8484

8585
# Python build artifacts
86-
/app/priv/python/agent/build/
87-
/app/priv/python/agent/dist/
88-
/app/priv/python/agent/src/*.egg-info/
89-
/app/priv/python/agent/**/__pycache__/
90-
/app/priv/python/agent/**/*.pyc
91-
/app/priv/python/agent/**/*.pyo
92-
/app/priv/python/agent/**/*.pyd
86+
/lambdas/metadata-agent/requirements.txt
87+
/lambdas/metadata-agent/.venv/
88+
/lambdas/metadata-agent/**/*.egg-info/
89+
/lambdas/metadata-agent/**/__pycache__/
90+
/lambdas/metadata-agent/**/*.pyc
91+
/lambdas/metadata-agent/**/*.pyo
92+
/lambdas/metadata-agent/**/*.pyd
9393

9494
.aws-sam/
9595
samconfig.*
96+
livebook/versions

.tool-versions

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
nodejs 22.14.0
2-
erlang 27.3
3-
elixir 1.18.2-otp-27
2+
erlang 28.1.1
3+
elixir 1.19.3-otp-28
44
terraform 1.7.4
55
aws-sam-cli 1.152.0
66
#npm 11.6.0

Makefile

Lines changed: 70 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,85 @@ endif
44

55
MAKEFLAGS += --no-print-directory
66
SHELL := /bin/bash
7+
8+
APP_DIR ?= ./app
79
LOCALSTACK_DIR ?= ./infrastructure/localstack
810
PIPELINE_DIR ?= ./infrastructure/pipeline
9-
TERRAFORM_DIR ?= ./infrastructure/deploy
10-
11-
.PHONY: help
11+
MEADOW_VERSION ?= $(shell $(MAKE) --no-print-directory app-version)
12+
IMAGE_TAG ?= latest
13+
VERSIONS_FILE ?= livebook/versions
14+
ELIXIR_VERSION ?= $(shell . $(VERSIONS_FILE) && echo $${elixir})
15+
OTP_VERSION ?= $(shell . $(VERSIONS_FILE) && echo $${otp})
16+
UBUNTU_VERSION ?= $(shell . $(VERSIONS_FILE) && echo $${ubuntu})
17+
BUILD_IMAGE ?= hexpm/elixir:$(ELIXIR_VERSION)-erlang-$(OTP_VERSION)-ubuntu-$(UBUNTU_VERSION)
18+
RUNTIME_IMAGE ?= ubuntu:$(UBUNTU_VERSION)
1219

1320
help:
21+
@make app-help | sed 's/^make /make app-/'
22+
@echo "make ci | install all dependencies, start test environment, and run all tests"
1423
@make localstack-help | sed 's/^make /make localstack-/'
1524
@make pipeline-help | sed 's/^make /make pipeline-/'
1625

17-
localstack-%:
26+
$(VERSIONS_FILE):
27+
livebook_version=$$(curl -s https://api.github.com/repos/livebook-dev/livebook/releases | jq -r '[.[] | select(.tag_name != "nightly")][0].tag_name') && \
28+
curl -sL -o $@ "https://raw.githubusercontent.com/livebook-dev/livebook/refs/tags/$${livebook_version}/versions"
29+
30+
.tool-versions: $(VERSIONS_FILE)
31+
. $(VERSIONS_FILE) && \
32+
otp_major="$${otp%%.*}" && \
33+
sed -i "s/^erlang .*/erlang $${otp}/" .tool-versions && \
34+
sed -i "s/^elixir .*/elixir $${elixir}-otp-$${otp_major}/" .tool-versions
35+
36+
build-image: $(VERSIONS_FILE)
37+
@echo $(BUILD_IMAGE)
38+
39+
runtime-image: $(VERSIONS_FILE)
40+
@echo $(RUNTIME_IMAGE)
41+
42+
app-image: $(VERSIONS_FILE)
43+
app-image: AWS_ACCOUNT_ID ?= $(shell aws sts get-caller-identity --query Account --output text)
44+
app-image: AWS_REGION ?= us-east-1
45+
app-image: ECR_REPO ?= $(AWS_ACCOUNT_ID).dkr.ecr.$(AWS_REGION).amazonaws.com
46+
app-image: RELEASE_NAME ?= meadow-$(shell git rev-parse --short HEAD)
47+
app-image: NODE_VERSION ?= 22
48+
app-image: MEADOW_TENANT ?= meadow
49+
app-image:
50+
cd app && \
51+
docker build \
52+
--build-arg HONEYBADGER_API_KEY=$(HONEYBADGER_API_KEY) \
53+
--build-arg HONEYBADGER_API_KEY_FRONTEND=$(HONEYBADGER_API_KEY_FRONTEND) \
54+
--build-arg HONEYBADGER_ENVIRONMENT=$(HONEYBADGER_ENVIRONMENT) \
55+
--build-arg HONEYBADGER_REVISION=$(HONEYBADGER_REVISION) \
56+
--build-arg BUILD_IMAGE=$(BUILD_IMAGE) \
57+
--build-arg RUNTIME_IMAGE=$(RUNTIME_IMAGE) \
58+
--build-arg NODE_VERSION=$(NODE_VERSION) \
59+
--build-arg MEADOW_TENANT=$(MEADOW_TENANT) \
60+
--build-arg MEADOW_VERSION=$(MEADOW_VERSION) \
61+
--tag $(ECR_REPO)/meadow:$(IMAGE_TAG) \
62+
--tag $(ECR_REPO)/meadow:$(MEADOW_VERSION) \
63+
.
64+
65+
livebook-image:
66+
docker build \
67+
--tag nulib/meadow:livebook-$(MEADOW_VERSION) \
68+
--tag nulib/meadow:livebook-$(IMAGE_TAG) \
69+
-f Dockerfile.livebook \
70+
.
71+
72+
localstack-%:
1873
cd $(LOCALSTACK_DIR) && make $*
1974

2075
pipeline-%:
2176
cd $(PIPELINE_DIR) && make $*
2277

23-
api-%:
24-
cd ../dc-api-v2 && make $*
78+
app-test: localstack-provision
79+
app-all-test: localstack-provision
80+
81+
app-%:
82+
cd $(APP_DIR) && make $*
83+
84+
ci: localstack-provision app-all-deps app-all-test localstack-stop
85+
86+
clean: localstack-clean pipeline-clean
87+
88+
distclean: clean app-distclean

0 commit comments

Comments
 (0)