Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

Seanaye/ci/lambdas build (#3162)

Sean Aye04af555c041c
diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml
index a8c628b578..31af77e9de 100644
--- a/.github/actionlint.yaml
+++ b/.github/actionlint.yaml
@@ -1,3 +1,4 @@
self-hosted-runner:
labels:
- linux-extra-beefy
+ - linux-latest-middy
diff --git a/.github/actions/deploy-cloud-storage-pulumi/action.yml b/.github/actions/deploy-cloud-storage-pulumi/action.yml
index 7b4d72ca2c..e544bda818 100644
--- a/.github/actions/deploy-cloud-storage-pulumi/action.yml
+++ b/.github/actions/deploy-cloud-storage-pulumi/action.yml
@@ -44,6 +44,18 @@ inputs:
description: 'Optional GitHub artifact containing prebuilt service binaries to copy into Docker images'
required: false
default: ''
+ lambda-artifacts:
+ description: 'Optional GitHub artifact containing built Lambda bootstrap.zip files under target/lambda'
+ required: false
+ default: ''
+ cloud-storage-service-name:
+ description: 'Optional service key from .github/services-config.json; builds Lambda artifacts inline when lambda-artifacts is not provided'
+ required: false
+ default: ''
+ cachix-auth-token:
+ description: 'Cachix auth token used for inline Lambda artifact builds'
+ required: false
+ default: ''
runs:
using: composite
@@ -68,6 +80,43 @@ runs:
mkdir -p rust/cloud-storage/prebuilt
tar -xzf rust/cloud-storage/prebuilt-artifact/prebuilt-binaries.tar.gz -C rust/cloud-storage/prebuilt
+ - name: Download Lambda artifacts
+ if: ${{ inputs.lambda-artifacts != '' }}
+ uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
+ with:
+ name: ${{ inputs.lambda-artifacts }}
+ path: rust/cloud-storage/lambda-artifact
+
+ - name: Extract Lambda artifacts
+ if: ${{ inputs.lambda-artifacts != '' }}
+ shell: bash
+ run: |
+ set -euo pipefail
+ tar -xzf rust/cloud-storage/lambda-artifact/lambda-artifacts.tar.gz -C rust/cloud-storage
+
+ - name: Check Lambda config for inline build
+ if: ${{ inputs.lambda-artifacts == '' && inputs.cloud-storage-service-name != '' }}
+ id: check-lambdas
+ shell: bash
+ env:
+ SERVICE: ${{ inputs.cloud-storage-service-name }}
+ run: |
+ has_lambdas=$(jq -r --arg service "$SERVICE" '((.services[$service].deploy_lambdas // []) | length) > 0' .github/services-config.json)
+ echo "has_lambdas=$has_lambdas" >> "$GITHUB_OUTPUT"
+
+ - name: Configure Cachix
+ if: ${{ inputs.lambda-artifacts == '' && inputs.cloud-storage-service-name != '' && steps.check-lambdas.outputs.has_lambdas == 'true' }}
+ uses: ./.github/actions/setup-cachix
+ with:
+ cachix-auth-token: ${{ inputs.cachix-auth-token }}
+
+ - name: Build Lambda artifacts inline
+ if: ${{ inputs.lambda-artifacts == '' && inputs.cloud-storage-service-name != '' && steps.check-lambdas.outputs.has_lambdas == 'true' }}
+ shell: bash
+ env:
+ SERVICE: ${{ inputs.cloud-storage-service-name }}
+ run: .github/scripts/build-cloud-storage-lambdas.sh
+
# setup docker
- uses: docker/setup-buildx-action@v3
if: ${{ inputs.use-docker == 'true' }}
diff --git a/.github/actions/preview-cloud-storage-pulumi/action.yml b/.github/actions/preview-cloud-storage-pulumi/action.yml
index c8b5e097f8..0f1ec426ea 100644
--- a/.github/actions/preview-cloud-storage-pulumi/action.yml
+++ b/.github/actions/preview-cloud-storage-pulumi/action.yml
@@ -44,6 +44,14 @@ inputs:
description: 'GitHub token for PR comments'
required: false
default: ''
+ cloud-storage-service-name:
+ description: 'Optional service key from .github/services-config.json; used to build Lambda artifacts before preview'
+ required: false
+ default: ''
+ cachix-auth-token:
+ description: 'Cachix auth token used when building Lambda artifacts'
+ required: false
+ default: ''
runs:
using: composite
@@ -53,6 +61,29 @@ runs:
with:
lfs: ${{ inputs.use-lfs }}
+ - name: Configure Cachix
+ if: ${{ inputs.cloud-storage-service-name != '' }}
+ uses: ./.github/actions/setup-cachix
+ with:
+ cachix-auth-token: ${{ inputs.cachix-auth-token }}
+
+ - name: Check Lambda config
+ if: ${{ inputs.cloud-storage-service-name != '' }}
+ id: check-lambdas
+ shell: bash
+ env:
+ SERVICE: ${{ inputs.cloud-storage-service-name }}
+ run: |
+ has_lambdas=$(jq -r --arg service "$SERVICE" '((.services[$service].deploy_lambdas // []) | length) > 0' .github/services-config.json)
+ echo "has_lambdas=$has_lambdas" >> "$GITHUB_OUTPUT"
+
+ - name: Build Lambda artifacts for preview
+ if: ${{ inputs.cloud-storage-service-name != '' && steps.check-lambdas.outputs.has_lambdas == 'true' }}
+ shell: bash
+ env:
+ SERVICE: ${{ inputs.cloud-storage-service-name }}
+ run: .github/scripts/build-cloud-storage-lambdas.sh
+
# setup docker
- uses: docker/setup-buildx-action@v3
if: ${{ inputs.use-docker == 'true' }}
diff --git a/.github/actions/setup-cachix/action.yml b/.github/actions/setup-cachix/action.yml
index cfc26203d2..9d010b59b1 100644
--- a/.github/actions/setup-cachix/action.yml
+++ b/.github/actions/setup-cachix/action.yml
@@ -10,6 +10,10 @@ inputs:
description: Cachix cache name.
required: false
default: macro-inc
+ dev-shell:
+ description: Enter the repository Nix dev shell after configuring Cachix.
+ required: false
+ default: 'false'
runs:
using: composite
@@ -36,3 +40,13 @@ runs:
cachix authtoken "$CACHIX_AUTH_TOKEN"
fi
cachix use "$CACHIX_CACHE_NAME"
+
+ - name: Enter Nix dev shell
+ if: ${{ inputs.dev-shell == 'true' }}
+ shell: bash
+ run: |
+ set -euo pipefail
+ nix print-dev-env --accept-flake-config > /tmp/dev-env
+ echo "BASH_ENV=/tmp/dev-env" >> "$GITHUB_ENV"
+ source /tmp/dev-env
+ printf '%s\n' "$PATH" | tr ':' '\n' >> "$GITHUB_PATH"
diff --git a/.github/actions/setup-nix-dev-shell/action.yml b/.github/actions/setup-nix-dev-shell/action.yml
deleted file mode 100644
index 33f43a95d2..0000000000
--- a/.github/actions/setup-nix-dev-shell/action.yml
+++ /dev/null
@@ -1,38 +0,0 @@
-name: Setup Nix Dev Shell
-description: Configure Cachix and enter the repository Nix dev shell.
-
-inputs:
- cachix-auth-token:
- description: Cachix auth token used to configure authenticated pulls and pushes.
- required: false
- default: ''
- cache-name:
- description: Cachix cache name.
- required: false
- default: macro-inc
-
-runs:
- using: composite
- steps:
- - name: Configure Cachix
- uses: ./.github/actions/setup-cachix
- with:
- cachix-auth-token: ${{ inputs.cachix-auth-token }}
- cache-name: ${{ inputs.cache-name }}
-
- - name: Enter Nix dev shell
- shell: bash
- env:
- CACHIX_AUTH_TOKEN: ${{ inputs.cachix-auth-token }}
- CACHIX_CACHE_NAME: ${{ inputs.cache-name }}
- run: |
- set -euo pipefail
- if [ -n "$CACHIX_AUTH_TOKEN" ]; then
- cachix watch-store "$CACHIX_CACHE_NAME" &
- cachix_pid=$!
- trap 'kill "$cachix_pid" || true' EXIT
- fi
- nix print-dev-env --accept-flake-config > /tmp/dev-env
- echo "BASH_ENV=/tmp/dev-env" >> "$GITHUB_ENV"
- source /tmp/dev-env
- printf '%s\n' "$PATH" | tr ':' '\n' >> "$GITHUB_PATH"
diff --git a/.github/actions/setup-reqs-web/action.yml b/.github/actions/setup-reqs-web/action.yml
index 4679501ecb..213614eb75 100644
--- a/.github/actions/setup-reqs-web/action.yml
+++ b/.github/actions/setup-reqs-web/action.yml
@@ -14,9 +14,10 @@ runs:
using: composite
steps:
- name: Setup Nix dev shell
- uses: ./.github/actions/setup-nix-dev-shell
+ uses: ./.github/actions/setup-cachix
with:
cachix-auth-token: ${{ inputs.cachix-auth-token }}
+ dev-shell: 'true'
- name: Setup bunfig.toml
working-directory: js
diff --git a/.github/scripts/build-cloud-storage-lambdas.sh b/.github/scripts/build-cloud-storage-lambdas.sh
new file mode 100755
index 0000000000..2c893c4aa0
--- /dev/null
+++ b/.github/scripts/build-cloud-storage-lambdas.sh
@@ -0,0 +1,41 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+SERVICE="${SERVICE:?SERVICE is required}"
+OUTPUT_DIR="${OUTPUT_DIR:-lambda-artifacts}"
+CONFIG_PATH="${CONFIG_PATH:-.github/services-config.json}"
+
+if ! jq -e --arg service "$SERVICE" '.services | has($service)' "$CONFIG_PATH" >/dev/null; then
+ echo "Service '$SERVICE' not found in $CONFIG_PATH" >&2
+ exit 1
+fi
+
+mapfile -t LAMBDAS < <(jq -r --arg service "$SERVICE" '.services[$service].deploy_lambdas[]? // empty' "$CONFIG_PATH")
+
+if [[ ${#LAMBDAS[@]} -eq 0 ]]; then
+ echo "No deploy_lambdas configured for $SERVICE"
+ exit 0
+fi
+
+echo "Building Lambda artifacts for $SERVICE: ${LAMBDAS[*]}"
+
+LAMBDAS_ENV="${LAMBDAS[*]}" nix develop .# -c bash -lc '
+ set -euo pipefail
+ cd rust/cloud-storage
+ for lambda in $LAMBDAS_ENV; do
+ echo "::group::Build $lambda"
+ ulimit -n 10240
+ just "$lambda/build"
+ test -f "target/lambda/$lambda/bootstrap.zip"
+ echo "::endgroup::"
+ done
+'
+
+rm -rf "$OUTPUT_DIR"
+mkdir -p "$OUTPUT_DIR/target/lambda"
+for lambda in "${LAMBDAS[@]}"; do
+ mkdir -p "$OUTPUT_DIR/target/lambda/$lambda"
+ cp "rust/cloud-storage/target/lambda/$lambda/bootstrap.zip" "$OUTPUT_DIR/target/lambda/$lambda/bootstrap.zip"
+done
+
+tar -C "$OUTPUT_DIR" -czf lambda-artifacts.tar.gz target
diff --git a/.github/scripts/detect-affected-services.sh b/.github/scripts/detect-affected-services.sh
index c315cfd516..ef8e39de1d 100755
--- a/.github/scripts/detect-affected-services.sh
+++ b/.github/scripts/detect-affected-services.sh
@@ -5,7 +5,7 @@ set -e
# It uses cargo metadata to build a proper dependency graph
# Get changed files from git
-CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD | grep "^rust/cloud-storage/" || true)
+CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD | grep -E "^(rust/cloud-storage/|infra/|\.github/services-config\.json|\.github/scripts/build-cloud-storage-lambdas\.sh)" || true)
if [ -z "$CHANGED_FILES" ]; then
echo "No cloud-storage files changed"
diff --git a/.github/services-config.json b/.github/services-config.json
index e69a173f77..2677053b77 100644
--- a/.github/services-config.json
+++ b/.github/services-config.json
@@ -13,11 +13,15 @@
"source_paths": [
"rust/cloud-storage/authentication_service/**",
"rust/cloud-storage/referral/**",
- "rust/cloud-storage/teams/**"
+ "rust/cloud-storage/teams/**",
+ "rust/cloud-storage/user_link_cleanup_handler/**"
],
"stack_path": "infra/stacks/authentication-service/**",
"deploy_binaries": [
"authentication_service"
+ ],
+ "deploy_lambdas": [
+ "user_link_cleanup_handler"
]
},
"bulk-upload": {
@@ -25,7 +29,11 @@
"rust/cloud-storage/upload_extractor_lambda_handler/**",
"rust/cloud-storage/upload_extractor_lambda_trigger/**"
],
- "stack_path": "infra/stacks/bulk-upload/**"
+ "stack_path": "infra/stacks/bulk-upload/**",
+ "deploy_lambdas": [
+ "upload_extractor_lambda_handler",
+ "upload_extractor_lambda_trigger"
+ ]
},
"connection-gateway": {
"source_paths": [
@@ -58,7 +66,10 @@
"source_paths": [
"rust/cloud-storage/deleted_item_poller/**"
],
- "stack_path": "infra/stacks/deleted-item-poller/**"
+ "stack_path": "infra/stacks/deleted-item-poller/**",
+ "deploy_lambdas": [
+ "deleted_item_poller"
+ ]
},
"document-cognition-service": {
"source_paths": [
@@ -72,11 +83,17 @@
"document-storage-service": {
"source_paths": [
"rust/cloud-storage/document_storage_service/**",
- "rust/cloud-storage/github/**"
+ "rust/cloud-storage/github/**",
+ "rust/cloud-storage/delete_chat_handler/**",
+ "rust/cloud-storage/docx_unzip_handler/**"
],
"stack_path": "infra/stacks/cloud-storage-service/**",
"deploy_binaries": [
"document_storage_service"
+ ],
+ "deploy_lambdas": [
+ "delete_chat_handler",
+ "docx_unzip_handler"
]
},
"document-storage": {
@@ -89,16 +106,25 @@
"source_paths": [
"rust/cloud-storage/document_text_extractor/**"
],
- "stack_path": "infra/stacks/document-text-extractor/**"
+ "stack_path": "infra/stacks/document-text-extractor/**",
+ "deploy_lambdas": [
+ "document_text_extractor"
+ ]
},
"email-service": {
"source_paths": [
- "rust/cloud-storage/email_service/**"
+ "rust/cloud-storage/email_service/**",
+ "rust/cloud-storage/email_refresh_handler/**",
+ "rust/cloud-storage/email_scheduled_handler/**"
],
"stack_path": "infra/stacks/email-service/**",
"deploy_binaries": [
"email_service",
"pubsub_workers"
+ ],
+ "deploy_lambdas": [
+ "email_refresh_handler",
+ "email_scheduled_handler"
]
},
"notification-service": {
@@ -112,9 +138,15 @@
},
"organization-retention": {
"source_paths": [
- "rust/cloud-storage/organization_retention/**"
+ "rust/cloud-storage/organization_retention/**",
+ "rust/cloud-storage/organization_retention_handler/**",
+ "rust/cloud-storage/organization_retention_trigger/**"
],
- "stack_path": "infra/stacks/organization-retention/**"
+ "stack_path": "infra/stacks/organization-retention/**",
+ "deploy_lambdas": [
+ "organization_retention_handler",
+ "organization_retention_trigger"
+ ]
},
"search-processing-service": {
"source_paths": [
@@ -127,23 +159,33 @@
},
"search-upload": {
"source_paths": [
- "rust/cloud-storage/search_upload/**"
+ "rust/cloud-storage/search_upload_handler/**"
],
- "stack_path": "infra/stacks/search-upload/**"
+ "stack_path": "infra/stacks/search-upload/**",
+ "deploy_lambdas": [
+ "search_upload_handler"
+ ]
},
"email-sfs-delete-handler": {
"source_paths": [
"rust/cloud-storage/email_sfs_delete_handler/**"
],
- "stack_path": "infra/stacks/email-sfs-delete-handler/**"
+ "stack_path": "infra/stacks/email-sfs-delete-handler/**",
+ "deploy_lambdas": [
+ "email_sfs_delete_handler"
+ ]
},
"static-file-service": {
"source_paths": [
- "rust/cloud-storage/static_file_service/**"
+ "rust/cloud-storage/static_file_service/**",
+ "rust/cloud-storage/image_optimizer/**"
],
"stack_path": "infra/stacks/static-file-service/**",
"deploy_binaries": [
"static_file_service"
+ ],
+ "deploy_lambdas": [
+ "image_optimizer"
]
},
"unfurl-service": {
@@ -172,15 +214,21 @@
},
"email-suppression": {
"source_paths": [
- "rust/cloud-storage/email_suppression/**"
+ "rust/cloud-storage/email_suppression_handler/**"
],
- "stack_path": "infra/stacks/email-suppression/**"
+ "stack_path": "infra/stacks/email-suppression/**",
+ "deploy_lambdas": [
+ "email_suppression_handler"
+ ]
},
"dlp-handler": {
"source_paths": [
- "rust/cloud-storage/dlp_handler/**"
+ "rust/cloud-storage/dataloss_prevention_handler/**"
],
- "stack_path": "infra/stacks/dlp-handler/**"
+ "stack_path": "infra/stacks/dlp-handler/**",
+ "deploy_lambdas": [
+ "dataloss_prevention_handler"
+ ]
},
"image-proxy-service": {
"source_paths": [
diff --git a/.github/workflows/code-check-cloud-storage.yml b/.github/workflows/code-check-cloud-storage.yml
index f1d489f70c..48701dc98f 100644
--- a/.github/workflows/code-check-cloud-storage.yml
+++ b/.github/workflows/code-check-cloud-storage.yml
@@ -23,7 +23,7 @@ jobs:
should_run: ${{ steps.filter.outputs.should_run }}
nextest_filter: ${{ steps.package-filter.outputs.nextest_filter }}
steps:
- - uses: actions/checkout@v6
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
clean: false
fetch-depth: 0
@@ -37,8 +37,9 @@ jobs:
- 'flake.nix'
- 'flake.lock'
- '.github/actions/setup-cachix/**'
- - '.github/actions/setup-nix-dev-shell/**'
- '.github/actions/setup-sccache/**'
+ - '.github/services-config.json'
+ - '.github/scripts/build-cloud-storage-lambdas.sh'
- .github/workflows/code-check-cloud-storage.yml
- name: compute nextest package filter
id: package-filter
@@ -62,7 +63,7 @@ jobs:
printf '%s\n' "$changed_files" > /tmp/changed-files
# Root cargo/toolchain/CI changes can affect the whole workspace, so run all tests.
- if printf '%s\n' "$changed_files" | grep -qE '^(rust/rust-toolchain\.toml|flake\.nix|flake\.lock|rust/cloud-storage/Cargo\.(toml|lock)|rust/cloud-storage/\.cargo/.*|\.github/actions/(setup-rust|setup-cachix|setup-nix-dev-shell|setup-sccache)/.*|\.github/workflows/code-check-cloud-storage\.yml)$'; then
+ if printf '%s\n' "$changed_files" | grep -qE '^(rust/rust-toolchain\.toml|flake\.nix|flake\.lock|rust/cloud-storage/Cargo\.(toml|lock)|rust/cloud-storage/\.cargo/.*|\.github/actions/(setup-rust|setup-cachix|setup-sccache)/.*|\.github/workflows/code-check-cloud-storage\.yml)$'; then
echo "Workspace-level change detected; running all tests"
echo "nextest_filter=" >> "$GITHUB_OUTPUT"
exit 0
@@ -168,13 +169,14 @@ jobs:
RUSTFLAGS: "-Dwarnings -C link-arg=-fuse-ld=mold"
RUSTDOCFLAGS: "-Dwarnings"
steps:
- - uses: actions/checkout@v6
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
clean: false
- name: Setup Nix dev shell
- uses: ./.github/actions/setup-nix-dev-shell
+ uses: ./.github/actions/setup-cachix
with:
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
+ dev-shell: 'true'
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
with:
workspaces: rust/cloud-storage
@@ -242,13 +244,14 @@ jobs:
- 6379:6379
options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- - uses: actions/checkout@v6
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
clean: false
- name: Setup Nix dev shell
- uses: ./.github/actions/setup-nix-dev-shell
+ uses: ./.github/actions/setup-cachix
with:
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
+ dev-shell: 'true'
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
with:
workspaces: rust/cloud-storage
@@ -315,114 +318,12 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: sccache --show-stats || true
- diff-check:
- needs: path-check
- if: needs.path-check.outputs.should_run == 'true' && github.event.pull_request.draft == false
- runs-on: ubuntu-latest
- outputs:
- docx-unzip-handler: ${{ steps.changes.outputs.docx-unzip-handler }}
- worker-trigger: ${{ steps.changes.outputs.worker-trigger }}
- document-text-extractor: ${{ steps.changes.outputs.document-text-extractor }}
- organization_retention_trigger: ${{ steps.changes.outputs.organization_retention_trigger }}
- organization_retention_handler: ${{ steps.changes.outputs.organization_retention_handler }}
- delete_chat_handler: ${{ steps.changes.outputs.delete_chat_handler }}
- search_upload_handler: ${{ steps.changes.outputs.search_upload_handler }}
- upload_extractor_lambda_trigger: ${{ steps.changes.outputs.upload_extractor_lambda_trigger }}
- upload_extractor_lambda_handler: ${{ steps.changes.outputs.upload_extractor_lambda_handler }}
- email_suppression_handler: ${{ steps.changes.outputs.email_suppression_handler }}
- deleted_item_poller: ${{ steps.changes.outputs.deleted_item_poller }}
- email_refresh_handler: ${{ steps.changes.outputs.email_refresh_handler }}
- email_scheduled_handler: ${{ steps.changes.outputs.email_scheduled_handler }}
- email_sfs_delete_handler: ${{ steps.changes.outputs.email_sfs_delete_handler }}
- user_link_cleanup_handler: ${{ steps.changes.outputs.user_link_cleanup_handler }}
- steps:
- - uses: actions/checkout@v6
- - uses: whutchinson98/[email protected]
- id: changes
- with:
- token: ${{ GITHUB.TOKEN }}
- diff: |
- docx-unzip-handler: ./rust/cloud-storage/docx-unzip-handler/*
- worker-trigger: ./rust/cloud-storage/worker-trigger/*
- document-text-extractor: ./rust/cloud-storage/document-text-extractor/*
- organization_retention_trigger: ./rust/cloud-storage/organization_retention_trigger/*
- organization_retention_handler: ./rust/cloud-storage/organization_retention_handler/*
- delete_chat_handler: ./rust/cloud-storage/delete_chat_handler/*
- search_upload_handler: ./rust/cloud-storage/search_upload_handler/*
- upload_extractor_lambda_trigger: ./rust/cloud-storage/upload_extractor_lambda_trigger/*
- upload_extractor_lambda_handler: ./rust/cloud-storage/upload_extractor_lambda_handler/*
- email_suppression_handler: ./rust/cloud-storage/email_suppression_handler/*
- deleted_item_poller: ./rust/cloud-storage/deleted_item_poller/*
- email_refresh_handler: ./rust/cloud-storage/email_refresh_handler/*
- email_scheduled_handler: ./rust/cloud-storage/email_scheduled_handler/*
- email_sfs_delete_handler: ./rust/cloud-storage/email_sfs_delete_handler/*
- user_link_cleanup_handler: ./rust/cloud-storage/user_link_cleanup_handler/*
- lambda_aggregate_frecency: ./rust/cloud-storage/lambda_aggregate_frecency/*
-
- check-lambdas:
- needs: diff-check
- runs-on: ubuntu-latest
- if: github.event.pull_request.draft == false
- strategy:
- # we want to fail the particular item that failed not all of them.
- fail-fast: false
- matrix:
- include:
- - service: docx-unzip-handler
- - service: worker-trigger
- - service: document-text-extractor
- - service: organization_retention_trigger
- - service: organization_retention_handler
- - service: delete_chat_handler
- - service: search_upload_handler
- - service: upload_extractor_lambda_trigger
- - service: upload_extractor_lambda_handler
- - service: email_suppression_handler
- - service: deleted_item_poller
- - service: email_refresh_handler
- - service: email_scheduled_handler
- - service: email_sfs_delete_handler
- - service: user_link_cleanup_handler
- steps:
- - name: setup env var
- shell: bash
- run: |
- echo "Check for ${{ matrix.service }}"
- echo "SHOULD_RUN=${{ needs.diff-check.outputs[matrix.service] }}" >> $GITHUB_ENV
- - uses: actions/checkout@v6
- if: env.SHOULD_RUN == 'true'
- - name: check if lambda is built
- if: env.SHOULD_RUN == 'true'
- run: |
- echo "Checking diff to ensure bootstrap.zip is part of PR"
- git fetch origin ${{ github.base_ref }}
- if ! git diff --name-only --diff-filter=AM origin/${{ github.base_ref }} HEAD | grep "rust/cloud-storage/target/lambda/${{ matrix.service }}/bootstrap.zip" > /dev/null; then
- echo "Code changes detected, but new bootstrap.zip for ${{matrix.service}} not found in PR. Please run: just rust/cloud-storage/${{matrix.service}}/build to build and commit bootstrap.zip. Alternatively you can run just rust/cloud-storage/build_lambads to build all lambdas."
- exit 1
- fi
-
- check-no-bootstrap-deletions:
- needs: path-check
- if: needs.path-check.outputs.should_run == 'true' && github.event.pull_request.draft == false
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v6
- - name: check for deleted bootstrap.zip files
- run: |
- git fetch origin ${{ github.base_ref }}
- DELETED=$(git diff --name-only --diff-filter=D origin/${{ github.base_ref }} HEAD | grep "bootstrap\.zip" || true)
- if [ -n "$DELETED" ]; then
- echo "❌ bootstrap.zip files should never be deleted. The following bootstrap.zip files were removed in this PR:"
- echo "$DELETED"
- exit 1
- fi
- echo "✅ No bootstrap.zip files were deleted"
# Collector job that always runs - use this as the required status check
status-check:
name: Cloud Storage Status Check
if: always()
- needs: [path-check, check, test, diff-check, check-lambdas, check-no-bootstrap-deletions]
+ needs: [path-check, check, test]
runs-on: ubuntu-latest
steps:
- name: Check job results
@@ -430,17 +331,11 @@ jobs:
echo "path-check: ${{ needs.path-check.result }}"
echo "check: ${{ needs.check.result }}"
echo "test: ${{ needs.test.result }}"
- echo "diff-check: ${{ needs.diff-check.result }}"
- echo "check-lambdas: ${{ needs.check-lambdas.result }}"
- echo "check-no-bootstrap-deletions: ${{ needs.check-no-bootstrap-deletions.result }}"
# Fail if any job failed (skipped and success are both OK)
if [[ "${{ needs.path-check.result }}" == "failure" ]] || \
[[ "${{ needs.check.result }}" == "failure" ]] || \
- [[ "${{ needs.test.result }}" == "failure" ]] || \
- [[ "${{ needs.diff-check.result }}" == "failure" ]] || \
- [[ "${{ needs.check-lambdas.result }}" == "failure" ]] || \
- [[ "${{ needs.check-no-bootstrap-deletions.result }}" == "failure" ]]; then
+ [[ "${{ needs.test.result }}" == "failure" ]]; then
echo "❌ One or more jobs failed"
exit 1
fi
diff --git a/.github/workflows/code-check-infra.yml b/.github/workflows/code-check-infra.yml
index afe13d5cd6..890ccc11b9 100644
--- a/.github/workflows/code-check-infra.yml
+++ b/.github/workflows/code-check-infra.yml
@@ -24,23 +24,23 @@ jobs:
- 'flake.nix'
- 'flake.lock'
- '.github/actions/setup-cachix/**'
- - '.github/actions/setup-nix-dev-shell/**'
- .github/workflows/code-check-infra.yml
biome-check:
needs: path-check
if: needs.path-check.outputs.should_run == 'true' && github.event.pull_request.draft == false
name: Biome Check
- runs-on: temp-middy
+ runs-on: linux-latest-middy
steps:
- name: Checkout Repo
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Nix dev shell
- uses: ./.github/actions/setup-nix-dev-shell
+ uses: ./.github/actions/setup-cachix
with:
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
+ dev-shell: 'true'
- name: Run Biome
working-directory: infra
run: biome ci --changed --no-errors-on-unmatched --error-on-warnings
@@ -48,13 +48,14 @@ jobs:
check:
needs: path-check
if: needs.path-check.outputs.should_run == 'true' && github.event.pull_request.draft == false
- runs-on: temp-middy
+ runs-on: linux-latest-middy
steps:
- uses: actions/checkout@v6
- name: Setup Nix dev shell
- uses: ./.github/actions/setup-nix-dev-shell
+ uses: ./.github/actions/setup-cachix
with:
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
+ dev-shell: 'true'
- name: install
working-directory: infra
run: bun install --frozen-lockfile
diff --git a/.github/workflows/deploy-all-services.yml b/.github/workflows/deploy-all-services.yml
index 82ca243238..d8c826e863 100644
--- a/.github/workflows/deploy-all-services.yml
+++ b/.github/workflows/deploy-all-services.yml
@@ -27,6 +27,8 @@ on:
required: true
DD_API_KEY:
required: true
+ CACHIX_AUTH_TOKEN:
+ required: true
# Only run 1 deploy-all workflow at a time per environment
concurrency:
@@ -40,7 +42,7 @@ jobs:
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- - uses: actions/checkout@v6
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Set deployment matrix
id: set-matrix
run: |
@@ -49,9 +51,51 @@ jobs:
echo "matrix=${services}" >> $GITHUB_OUTPUT
echo "Deploying services: ${services}"
+ build-lambda-artifacts:
+ name: Build ${{ matrix.service }} Lambda artifacts
+ needs: setup
+ if: ${{ needs.setup.outputs.matrix != '[]' }}
+ runs-on: linux-extra-beefy
+ strategy:
+ fail-fast: false
+ max-parallel: 8
+ matrix:
+ service: ${{ fromJson(needs.setup.outputs.matrix) }}
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
+ with:
+ clean: false
+
+ - name: Configure Cachix
+ uses: ./.github/actions/setup-cachix
+ with:
+ cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
+
+ - name: Check Lambda config
+ id: check-lambdas
+ env:
+ SERVICE: ${{ matrix.service }}
+ run: |
+ has_lambdas=$(jq -r --arg service "$SERVICE" '((.services[$service].deploy_lambdas // []) | length) > 0' .github/services-config.json)
+ echo "has_lambdas=$has_lambdas" >> "$GITHUB_OUTPUT"
+
+ - name: Build Lambda artifacts
+ if: ${{ steps.check-lambdas.outputs.has_lambdas == 'true' }}
+ env:
+ SERVICE: ${{ matrix.service }}
+ run: .github/scripts/build-cloud-storage-lambdas.sh
+
+ - name: Upload Lambda artifacts
+ if: ${{ steps.check-lambdas.outputs.has_lambdas == 'true' }}
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
+ with:
+ name: cloud-storage-lambdas-${{ matrix.service }}-${{ github.sha }}
+ path: lambda-artifacts.tar.gz
+ retention-days: 7
+
deploy-services:
name: Deploy ${{ matrix.service }}
- needs: setup
+ needs: [setup, build-lambda-artifacts]
if: ${{ needs.setup.outputs.matrix != '[]' }}
runs-on:
[
@@ -68,7 +112,7 @@ jobs:
matrix:
service: ${{ fromJson(needs.setup.outputs.matrix) }}
steps:
- - uses: actions/checkout@v6
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Get project name
id: project-name
@@ -76,6 +120,14 @@ jobs:
with:
service-name: ${{ matrix.service }}
+ - name: Check artifact config
+ id: check-artifacts
+ env:
+ SERVICE: ${{ matrix.service }}
+ run: |
+ has_lambdas=$(jq -r --arg service "$SERVICE" '((.services[$service].deploy_lambdas // []) | length) > 0' .github/services-config.json)
+ echo "has_lambdas=$has_lambdas" >> "$GITHUB_OUTPUT"
+
- name: Deploy ${{ matrix.service }}
uses: ./.github/actions/deploy-cloud-storage-pulumi
with:
@@ -84,18 +136,27 @@ jobs:
aws-secret-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
pulumi-access-token: ${{ secrets.PULUMI_ACCESS_TOKEN }}
pulumi-service-name: ${{ steps.project-name.outputs.project-name }}
+ lambda-artifacts: ${{ steps.check-artifacts.outputs.has_lambdas == 'true' && format('cloud-storage-lambdas-{0}-{1}', matrix.service, github.sha) || '' }}
dd-app-key: ${{ secrets.DD_APP_KEY }}
dd-api-key: ${{ secrets.DD_API_KEY }}
deployment-summary:
name: Deployment Summary
runs-on: ubuntu-latest
- needs: deploy-services
+ needs: [setup, build-lambda-artifacts, deploy-services]
if: always()
steps:
- name: Check deployment results
run: |
- if [[ "${{ needs.deploy-services.result }}" == "failure" ]]; then
+ if [[ "${{ needs.setup.result }}" == "failure" ]]; then
+ echo "❌ Deployment setup failed"
+ exit 1
+ elif [[ "${{ needs.setup.result }}" == "skipped" ]]; then
+ echo "⏭️ Deployment setup was skipped"
+ elif [[ "${{ needs.build-lambda-artifacts.result }}" == "failure" ]]; then
+ echo "❌ One or more Lambda artifact builds failed"
+ exit 1
+ elif [[ "${{ needs.deploy-services.result }}" == "failure" ]]; then
echo "❌ One or more service deployments failed"
exit 1
elif [[ "${{ needs.deploy-services.result }}" == "skipped" ]]; then
diff --git a/.github/workflows/deploy-cloud-storage-on-push.yml b/.github/workflows/deploy-cloud-storage-on-push.yml
index ef3405a328..1309aa82d1 100644
--- a/.github/workflows/deploy-cloud-storage-on-push.yml
+++ b/.github/workflows/deploy-cloud-storage-on-push.yml
@@ -30,6 +30,7 @@ on:
- 'infra/**'
- '.github/workflows/deploy-cloud-storage-on-push.yml'
- '.github/actions/deploy-cloud-storage-pulumi/**'
+ - '.github/scripts/build-cloud-storage-lambdas.sh'
- '.github/services-config.json'
- 'flake.nix'
- 'flake.lock'
@@ -45,8 +46,11 @@ jobs:
outputs:
services: ${{ steps.detect.outputs.services }}
has_changes: ${{ steps.detect.outputs.has_changes }}
+ lambda_matrix: ${{ steps.detect.outputs.lambda_matrix }}
+ lambda_services: ${{ steps.detect.outputs.lambda_services }}
+ has_lambdas: ${{ steps.detect.outputs.has_lambdas }}
steps:
- - uses: actions/checkout@v6
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
fetch-depth: 2
@@ -60,29 +64,35 @@ jobs:
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
SERVICES=$(jq -cn --arg service "${{ inputs.service }}" '[$service]')
- echo "services=$SERVICES" >> $GITHUB_OUTPUT
- echo "has_changes=true" >> $GITHUB_OUTPUT
+ HAS_CHANGES=true
echo "Manually selected service: $SERVICES"
- exit 0
- fi
+ else
+ # Make the script executable
+ chmod +x .github/scripts/detect-affected-services.sh
- # Make the script executable
- chmod +x .github/scripts/detect-affected-services.sh
+ # Run the detection script and capture output
+ OUTPUT=$(.github/scripts/detect-affected-services.sh)
- # Run the detection script and capture output
- OUTPUT=$(.github/scripts/detect-affected-services.sh)
+ # Parse the output
+ SERVICES=$(echo "$OUTPUT" | grep "^services=" | cut -d'=' -f2-)
+ HAS_CHANGES=$(echo "$OUTPUT" | grep "^has_changes=" | cut -d'=' -f2-)
+ fi
- # Parse the output
- SERVICES=$(echo "$OUTPUT" | grep "^services=" | cut -d'=' -f2-)
- HAS_CHANGES=$(echo "$OUTPUT" | grep "^has_changes=" | cut -d'=' -f2-)
+ lambda_matrix=$(jq -cn --argjson services "$SERVICES" --slurpfile config .github/services-config.json '$services as $services | $config[0] as $config | [$services[] as $service | ($config.services[$service].deploy_lambdas // [])[] | {service:$service, lambda:.}]')
+ lambda_services=$(jq -cn --argjson matrix "$lambda_matrix" '[$matrix[].service] | unique')
+ has_lambdas=$(jq -rn --argjson matrix "$lambda_matrix" '$matrix | length > 0')
# Set outputs
echo "services=$SERVICES" >> $GITHUB_OUTPUT
echo "has_changes=$HAS_CHANGES" >> $GITHUB_OUTPUT
+ echo "lambda_matrix=$lambda_matrix" >> $GITHUB_OUTPUT
+ echo "lambda_services=$lambda_services" >> $GITHUB_OUTPUT
+ echo "has_lambdas=$has_lambdas" >> $GITHUB_OUTPUT
# Log for debugging
echo "Detected services: $SERVICES"
echo "Has changes: $HAS_CHANGES"
+ echo "Lambda matrix: $lambda_matrix"
migrate-db:
name: Run Database Migrations
@@ -90,7 +100,7 @@ jobs:
if: ${{ needs.detect-changes.outputs.has_changes == 'true' }}
runs-on: db-migrator
steps:
- - uses: actions/checkout@v6
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
sparse-checkout: .github/
@@ -110,7 +120,7 @@ jobs:
matrix:
service: ${{ fromJson(needs.detect-changes.outputs.services) }}
steps:
- - uses: actions/checkout@v6
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
clean: false
@@ -153,10 +163,83 @@ jobs:
path: prebuilt-binaries.tar.gz
retention-days: 7
+ build-lambda-artifacts:
+ name: Build ${{ matrix.lambda }} Lambda artifact
+ needs: detect-changes
+ if: ${{ needs.detect-changes.outputs.has_changes == 'true' && needs.detect-changes.outputs.has_lambdas == 'true' }}
+ runs-on: linux-extra-beefy
+ strategy:
+ fail-fast: false
+ max-parallel: 8
+ matrix:
+ include: ${{ fromJson(needs.detect-changes.outputs.lambda_matrix || '[]') }}
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
+ with:
+ clean: false
+
+ - name: Configure Cachix
+ uses: ./.github/actions/setup-cachix
+ with:
+ cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
+
+ - name: Build Lambda artifact
+ shell: bash
+ env:
+ LAMBDA: ${{ matrix.lambda }}
+ run: |
+ set -euo pipefail
+ nix develop .# -c bash -lc '
+ set -euo pipefail
+ cd rust/cloud-storage
+ echo "::group::Build $LAMBDA"
+ ulimit -n 10240
+ just "$LAMBDA/build"
+ test -f "target/lambda/$LAMBDA/bootstrap.zip"
+ echo "::endgroup::"
+ '
+ mkdir -p "lambda-artifacts/target/lambda/$LAMBDA"
+ cp "rust/cloud-storage/target/lambda/$LAMBDA/bootstrap.zip" "lambda-artifacts/target/lambda/$LAMBDA/bootstrap.zip"
+
+ - name: Upload Lambda artifact
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
+ with:
+ name: cloud-storage-lambda-${{ matrix.service }}-${{ matrix.lambda }}-${{ github.sha }}
+ path: lambda-artifacts
+ retention-days: 7
+
+ package-lambda-artifacts:
+ name: Package ${{ matrix.service }} Lambda artifacts
+ needs: [detect-changes, build-lambda-artifacts]
+ if: ${{ needs.detect-changes.outputs.has_changes == 'true' && needs.detect-changes.outputs.has_lambdas == 'true' }}
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ max-parallel: 8
+ matrix:
+ service: ${{ fromJson(needs.detect-changes.outputs.lambda_services || '[]') }}
+ steps:
+ - name: Download Lambda artifacts
+ uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
+ with:
+ pattern: cloud-storage-lambda-${{ matrix.service }}-*-${{ github.sha }}
+ path: lambda-artifacts
+ merge-multiple: true
+
+ - name: Package Lambda artifacts
+ run: tar -C lambda-artifacts -czf lambda-artifacts.tar.gz target
+
+ - name: Upload Lambda artifacts
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
+ with:
+ name: cloud-storage-lambdas-${{ matrix.service }}-${{ github.sha }}
+ path: lambda-artifacts.tar.gz
+ retention-days: 7
+
deploy-services:
name: Deploy ${{ matrix.service }}
- needs: [detect-changes, migrate-db, build-service-binaries]
- if: ${{ needs.detect-changes.outputs.has_changes == 'true' }}
+ needs: [detect-changes, migrate-db, build-service-binaries, build-lambda-artifacts, package-lambda-artifacts]
+ if: ${{ always() && needs.detect-changes.outputs.has_changes == 'true' && needs.migrate-db.result == 'success' && needs.build-service-binaries.result == 'success' && (needs.build-lambda-artifacts.result == 'success' || needs.build-lambda-artifacts.result == 'skipped') && (needs.package-lambda-artifacts.result == 'success' || needs.package-lambda-artifacts.result == 'skipped') }}
runs-on:
[
runs-on,
@@ -172,7 +255,7 @@ jobs:
matrix:
service: ${{ fromJson(needs.detect-changes.outputs.services) }}
steps:
- - uses: actions/checkout@v6
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Get project name
id: project-name
@@ -180,13 +263,15 @@ jobs:
with:
service-name: ${{ matrix.service }}
- - name: Check prebuilt binaries config
- id: check-binaries
+ - name: Check artifact config
+ id: check-artifacts
env:
SERVICE: ${{ matrix.service }}
run: |
has_binaries=$(jq -r --arg service "$SERVICE" '((.services[$service].deploy_binaries // []) | length) > 0' .github/services-config.json)
+ has_lambdas=$(jq -r --arg service "$SERVICE" '((.services[$service].deploy_lambdas // []) | length) > 0' .github/services-config.json)
echo "has_binaries=$has_binaries" >> "$GITHUB_OUTPUT"
+ echo "has_lambdas=$has_lambdas" >> "$GITHUB_OUTPUT"
- name: Deploy ${{ matrix.service }}
uses: ./.github/actions/deploy-cloud-storage-pulumi
@@ -196,19 +281,23 @@ jobs:
aws-secret-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
pulumi-access-token: ${{ secrets.PULUMI_ACCESS_TOKEN }}
pulumi-service-name: ${{ steps.project-name.outputs.project-name }}
- prebuilt-binaries-artifact: ${{ steps.check-binaries.outputs.has_binaries == 'true' && format('cloud-storage-service-binaries-{0}-{1}', matrix.service, github.sha) || '' }}
+ prebuilt-binaries-artifact: ${{ steps.check-artifacts.outputs.has_binaries == 'true' && format('cloud-storage-service-binaries-{0}-{1}', matrix.service, github.sha) || '' }}
+ lambda-artifacts: ${{ steps.check-artifacts.outputs.has_lambdas == 'true' && format('cloud-storage-lambdas-{0}-{1}', matrix.service, github.sha) || '' }}
dd-app-key: ${{ secrets.DD_APP_KEY }}
dd-api-key: ${{ secrets.DD_API_KEY }}
deployment-summary:
name: Deployment Summary
runs-on: ubuntu-latest
- needs: [detect-changes, migrate-db, build-service-binaries, deploy-services]
+ needs: [detect-changes, migrate-db, build-service-binaries, build-lambda-artifacts, package-lambda-artifacts, deploy-services]
if: always()
steps:
- name: Check deployment results
run: |
- if [[ "${{ needs.detect-changes.outputs.has_changes }}" == "false" ]]; then
+ if [[ "${{ needs.detect-changes.result }}" == "failure" ]]; then
+ echo "❌ Failed to detect changed services"
+ exit 1
+ elif [[ "${{ needs.detect-changes.outputs.has_changes }}" == "false" ]]; then
echo "ℹ️ No cloud-storage services were affected by the changes"
elif [[ "${{ needs.migrate-db.result }}" == "failure" ]]; then
echo "❌ Database migrations failed"
@@ -216,6 +305,12 @@ jobs:
elif [[ "${{ needs.build-service-binaries.result }}" == "failure" ]]; then
echo "❌ One or more service binary builds failed"
exit 1
+ elif [[ "${{ needs.build-lambda-artifacts.result }}" == "failure" ]]; then
+ echo "❌ One or more Lambda artifact builds failed"
+ exit 1
+ elif [[ "${{ needs.package-lambda-artifacts.result }}" == "failure" ]]; then
+ echo "❌ One or more Lambda artifact packages failed"
+ exit 1
elif [[ "${{ needs.deploy-services.result }}" == "failure" ]]; then
echo "❌ One or more service deployments failed"
exit 1
diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml
index c5d39b1c74..69139112bd 100644
--- a/.github/workflows/deploy-preview.yml
+++ b/.github/workflows/deploy-preview.yml
@@ -32,6 +32,8 @@ jobs:
- name: Setup
uses: ./.github/actions/setup-reqs-web
+ with:
+ cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
# Build identical to dev.macro.com deployment
- name: Build
diff --git a/.github/workflows/deploy-pulumi-stack.yml b/.github/workflows/deploy-pulumi-stack.yml
index 1387d15a59..0650b60d68 100644
--- a/.github/workflows/deploy-pulumi-stack.yml
+++ b/.github/workflows/deploy-pulumi-stack.yml
@@ -14,6 +14,10 @@ on:
type: string
required: true
description: The name of the pulumi service to deploy. This will be the exact name of the folder containing your stacks.
+ cloud-storage-service-name:
+ type: string
+ required: false
+ description: Optional service key from .github/services-config.json; set this for Lambda-backed stacks so CI can build Lambda zips before Pulumi runs.
concurrency:
group: ${{ github.workflow }}-${{ inputs.pulumi-service-name }}-${{ inputs.environment }}
@@ -30,8 +34,6 @@ jobs:
ssh=false,
'run-id=${{github.run_id}}',
]
- outputs:
- level: ${{ steps.set-level.outputs.level }}
steps:
- uses: actions/checkout@v6
with:
@@ -43,5 +45,7 @@ jobs:
aws-secret-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
pulumi-access-token: ${{ secrets.PULUMI_ACCESS_TOKEN }}
pulumi-service-name: ${{ inputs.pulumi-service-name }} # TODO: we should have validation that this is a valid pulumi service name before we allow it to be set here
+ cloud-storage-service-name: ${{ inputs.cloud-storage-service-name }}
+ cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
dd-app-key: ${{ secrets.DD_APP_KEY }}
dd-api-key: ${{ secrets.DD_API_KEY }}
diff --git a/.github/workflows/deploy-services-batch.yml b/.github/workflows/deploy-services-batch.yml
index c9ab94ae09..972d74ac6a 100644
--- a/.github/workflows/deploy-services-batch.yml
+++ b/.github/workflows/deploy-services-batch.yml
@@ -26,7 +26,7 @@ jobs:
outputs:
matrix: ${{ steps.parse.outputs.matrix }}
steps:
- - uses: actions/checkout@v6
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Parse and validate services
id: parse
run: |
@@ -69,9 +69,50 @@ jobs:
echo "matrix=${matrix}" >> $GITHUB_OUTPUT
fi
+ build-lambda-artifacts:
+ name: Build ${{ matrix.service }} Lambda artifacts
+ needs: parse-services
+ runs-on: linux-extra-beefy
+ strategy:
+ fail-fast: false
+ max-parallel: 8
+ matrix:
+ service: ${{ fromJson(needs.parse-services.outputs.matrix) }}
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
+ with:
+ clean: false
+
+ - name: Configure Cachix
+ uses: ./.github/actions/setup-cachix
+ with:
+ cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
+
+ - name: Check Lambda config
+ id: check-lambdas
+ env:
+ SERVICE: ${{ matrix.service }}
+ run: |
+ has_lambdas=$(jq -r --arg service "$SERVICE" '((.services[$service].deploy_lambdas // []) | length) > 0' .github/services-config.json)
+ echo "has_lambdas=$has_lambdas" >> "$GITHUB_OUTPUT"
+
+ - name: Build Lambda artifacts
+ if: ${{ steps.check-lambdas.outputs.has_lambdas == 'true' }}
+ env:
+ SERVICE: ${{ matrix.service }}
+ run: .github/scripts/build-cloud-storage-lambdas.sh
+
+ - name: Upload Lambda artifacts
+ if: ${{ steps.check-lambdas.outputs.has_lambdas == 'true' }}
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
+ with:
+ name: cloud-storage-lambdas-${{ matrix.service }}-${{ github.sha }}
+ path: lambda-artifacts.tar.gz
+ retention-days: 7
+
deploy-services:
name: Deploy ${{ matrix.service }}
- needs: parse-services
+ needs: [parse-services, build-lambda-artifacts]
runs-on:
[
runs-on,
@@ -87,7 +128,7 @@ jobs:
matrix:
service: ${{ fromJson(needs.parse-services.outputs.matrix) }}
steps:
- - uses: actions/checkout@v6
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Get project name
id: project-name
@@ -95,6 +136,14 @@ jobs:
with:
service-name: ${{ matrix.service }}
+ - name: Check artifact config
+ id: check-artifacts
+ env:
+ SERVICE: ${{ matrix.service }}
+ run: |
+ has_lambdas=$(jq -r --arg service "$SERVICE" '((.services[$service].deploy_lambdas // []) | length) > 0' .github/services-config.json)
+ echo "has_lambdas=$has_lambdas" >> "$GITHUB_OUTPUT"
+
- name: Deploy ${{ matrix.service }}
uses: ./.github/actions/deploy-cloud-storage-pulumi
with:
@@ -103,18 +152,25 @@ jobs:
aws-secret-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
pulumi-access-token: ${{ secrets.PULUMI_ACCESS_TOKEN }}
pulumi-service-name: ${{ steps.project-name.outputs.project-name }}
+ lambda-artifacts: ${{ steps.check-artifacts.outputs.has_lambdas == 'true' && format('cloud-storage-lambdas-{0}-{1}', matrix.service, github.sha) || '' }}
dd-app-key: ${{ secrets.DD_APP_KEY }}
dd-api-key: ${{ secrets.DD_API_KEY }}
summary:
name: Deployment Summary
runs-on: ubuntu-latest
- needs: deploy-services
+ needs: [parse-services, build-lambda-artifacts, deploy-services]
if: always()
steps:
- name: Report results
run: |
- if [[ "${{ needs.deploy-services.result }}" == "failure" ]]; then
+ if [[ "${{ needs.parse-services.result }}" == "failure" ]]; then
+ echo "❌ Failed to parse services"
+ exit 1
+ elif [[ "${{ needs.build-lambda-artifacts.result }}" == "failure" ]]; then
+ echo "❌ One or more Lambda artifact builds failed"
+ exit 1
+ elif [[ "${{ needs.deploy-services.result }}" == "failure" ]]; then
echo "❌ One or more deployments failed"
exit 1
else
diff --git a/.github/workflows/deploy-web-app.yml b/.github/workflows/deploy-web-app.yml
index 67632a6cec..a54f5f67fa 100644
--- a/.github/workflows/deploy-web-app.yml
+++ b/.github/workflows/deploy-web-app.yml
@@ -41,6 +41,8 @@ on:
required: true
POSTHOG_API_KEY:
required: true
+ CACHIX_AUTH_TOKEN:
+ required: true
concurrency:
group: ${{ github.workflow }}-web-app-${{ inputs.environment }}
@@ -58,6 +60,8 @@ jobs:
ref: ${{ github.ref_name }}
- name: Setup
uses: ./.github/actions/setup-reqs-web
+ with:
+ cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: Build
working-directory: js/app
run: just build-${{ inputs.environment }}
diff --git a/.github/workflows/release-production.yml b/.github/workflows/release-production.yml
index 596af48d47..439cbdf9a7 100644
--- a/.github/workflows/release-production.yml
+++ b/.github/workflows/release-production.yml
@@ -35,6 +35,7 @@ jobs:
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
DD_APP_KEY: ${{ secrets.DD_APP_KEY }}
DD_API_KEY: ${{ secrets.DD_API_KEY }}
+ CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
build:
name: Build
@@ -47,6 +48,8 @@ jobs:
uses: actions/checkout@v6
- name: Setup Prereqs
uses: ./.github/actions/setup-reqs-web
+ with:
+ cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: Build for Production
working-directory: js/app
run: just build-prod
@@ -74,6 +77,8 @@ jobs:
uses: actions/checkout@v6
- name: Setup Prereqs
uses: ./.github/actions/setup-reqs-web
+ with:
+ cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: Download Build Artifact
uses: actions/download-artifact@v5
with:
diff --git a/.github/workflows/reusable-deploy-service.yml b/.github/workflows/reusable-deploy-service.yml
index 159978d241..4d214615cd 100644
--- a/.github/workflows/reusable-deploy-service.yml
+++ b/.github/workflows/reusable-deploy-service.yml
@@ -93,8 +93,46 @@ jobs:
path: prebuilt-binaries.tar.gz
retention-days: 7
+ build-lambda-artifacts:
+ name: Build ${{ inputs.service-name }} Lambda artifacts
+ runs-on: linux-extra-beefy
+ outputs:
+ has_lambdas: ${{ steps.check-lambdas.outputs.has_lambdas }}
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
+ with:
+ ref: ${{ github.ref_name }}
+ clean: false
+
+ - name: Configure Cachix
+ uses: ./.github/actions/setup-cachix
+ with:
+ cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
+
+ - name: Check Lambda config
+ id: check-lambdas
+ env:
+ SERVICE: ${{ inputs.service-name }}
+ run: |
+ has_lambdas=$(jq -r --arg service "$SERVICE" '((.services[$service].deploy_lambdas // []) | length) > 0' .github/services-config.json)
+ echo "has_lambdas=$has_lambdas" >> "$GITHUB_OUTPUT"
+
+ - name: Build Lambda artifacts
+ if: ${{ steps.check-lambdas.outputs.has_lambdas == 'true' }}
+ env:
+ SERVICE: ${{ inputs.service-name }}
+ run: .github/scripts/build-cloud-storage-lambdas.sh
+
+ - name: Upload Lambda artifacts
+ if: ${{ steps.check-lambdas.outputs.has_lambdas == 'true' }}
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
+ with:
+ name: cloud-storage-lambdas-${{ inputs.service-name }}-${{ github.sha }}
+ path: lambda-artifacts.tar.gz
+ retention-days: 7
+
deploy:
- needs: build-service-binaries
+ needs: [build-service-binaries, build-lambda-artifacts]
runs-on:
[
runs-on,
@@ -105,7 +143,7 @@ jobs:
'run-id=${{github.run_id}}-${{ inputs.service-name }}',
]
steps:
- - uses: actions/checkout@v6
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
ref: ${{ github.ref_name }}
@@ -123,6 +161,7 @@ jobs:
pulumi-access-token: ${{ secrets.PULUMI_ACCESS_TOKEN }}
pulumi-service-name: ${{ inputs.pulumi-stack-name || steps.project-name.outputs.project-name }}
prebuilt-binaries-artifact: ${{ needs.build-service-binaries.outputs.has_binaries == 'true' && format('cloud-storage-service-binaries-{0}-{1}', inputs.service-name, github.sha) || '' }}
+ lambda-artifacts: ${{ needs.build-lambda-artifacts.outputs.has_lambdas == 'true' && format('cloud-storage-lambdas-{0}-{1}', inputs.service-name, github.sha) || '' }}
dd-app-key: ${{ secrets.DD_APP_KEY }}
dd-api-key: ${{ secrets.DD_API_KEY }}
use-docker: ${{ inputs.use-docker }}
diff --git a/.github/workflows/reusable-preview-service.yml b/.github/workflows/reusable-preview-service.yml
index 63fd253edf..af8410a5e6 100644
--- a/.github/workflows/reusable-preview-service.yml
+++ b/.github/workflows/reusable-preview-service.yml
@@ -39,10 +39,12 @@ on:
required: true
DD_API_KEY:
required: true
+ CACHIX_AUTH_TOKEN:
+ required: true
jobs:
preview:
- runs-on: ubuntu-latest
+ runs-on: linux-extra-beefy
steps:
- uses: actions/checkout@v6
@@ -64,3 +66,5 @@ jobs:
use-docker: ${{ inputs.use-docker }}
use-lfs: ${{ inputs.use-lfs }}
github-token: ${{ inputs.github-token }}
+ cloud-storage-service-name: ${{ inputs.service-name }}
+ cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
diff --git a/.github/workflows/web-app-check-main.yml b/.github/workflows/web-app-check-main.yml
index 8517013303..68b0b8b226 100644
--- a/.github/workflows/web-app-check-main.yml
+++ b/.github/workflows/web-app-check-main.yml
@@ -31,7 +31,6 @@ jobs:
- 'js/lexical-core/**'
- 'js/lexical-service/**'
- '.github/actions/setup-cachix/**'
- - '.github/actions/setup-nix-dev-shell/**'
- '.github/actions/setup-reqs-web/**'
- '.github/workflows/web-app-check-main.yml'
api_changed:
@@ -43,7 +42,6 @@ jobs:
- 'js/app/scripts/generate-api-schema.ts'
- 'js/app/scripts/services.ts'
- '.github/actions/setup-cachix/**'
- - '.github/actions/setup-nix-dev-shell/**'
- '.github/actions/setup-reqs-web/**'
- '.github/workflows/web-app-check-main.yml'
@@ -52,7 +50,7 @@ jobs:
# Run the type check if rust code or frontend code has changed.
if: needs.path-check.outputs.should_run == 'true' || needs.path-check.outputs.api_changed == 'true'
name: Typecheck
- runs-on: temp-middy
+ runs-on: linux-extra-beefy
steps:
- name: Checkout Repo
uses: actions/checkout@v6
@@ -107,16 +105,17 @@ jobs:
needs: path-check
if: needs.path-check.outputs.should_run == 'true'
name: Biome Check
- runs-on: temp-middy
+ runs-on: linux-latest-middy
steps:
- name: Checkout Repo
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Nix dev shell
- uses: ./.github/actions/setup-nix-dev-shell
+ uses: ./.github/actions/setup-cachix
with:
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
+ dev-shell: 'true'
- name: Run Biome
working-directory: js/app
run: biome ci --changed --no-errors-on-unmatched --error-on-warnings
@@ -125,7 +124,7 @@ jobs:
needs: path-check
if: needs.path-check.outputs.should_run == 'true'
name: Theme Hygiene Inspector
- runs-on: temp-middy
+ runs-on: linux-latest-middy
steps:
- name: Checkout Repo
uses: actions/checkout@v6
@@ -143,7 +142,7 @@ jobs:
needs: path-check
if: needs.path-check.outputs.should_run == 'true'
name: Test
- runs-on: temp-middy
+ runs-on: linux-latest-middy
steps:
- name: Checkout Repo
uses: actions/checkout@v6
@@ -160,14 +159,15 @@ jobs:
needs: path-check
if: needs.path-check.outputs.should_run == 'true'
name: Cycles Import Check
- runs-on: temp-middy
+ runs-on: linux-latest-middy
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Nix dev shell
- uses: ./.github/actions/setup-nix-dev-shell
+ uses: ./.github/actions/setup-cachix
with:
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
+ dev-shell: 'true'
- name: Cycles Import Check
working-directory: js/app
run: biome lint --changed --no-errors-on-unmatched --only=suspicious/noImportCycles
@@ -176,7 +176,7 @@ jobs:
needs: path-check
if: needs.path-check.outputs.should_run == 'true'
name: Build
- runs-on: temp-middy
+ runs-on: linux-latest-middy
steps:
- name: Checkout Repo
uses: actions/checkout@v6
diff --git a/.tmp-zigtest/t b/.tmp-zigtest/t
new file mode 100755
index 0000000000..e96b4c17d6
Binary files /dev/null and b/.tmp-zigtest/t differ
diff --git a/rust/cloud-storage/.gitignore b/rust/cloud-storage/.gitignore
index bc3194c348..8e2383e7af 100644
--- a/rust/cloud-storage/.gitignore
+++ b/rust/cloud-storage/.gitignore
@@ -1,16 +1,9 @@
-# Ignore everything in target
-/target/*
+# Ignore build output
+/target/
# Generated tool schemas (generated by gen-api script)
ai_tools/schemas/
-# But keep the lambda directory
-!/target/lambda/
-
-# And all files under lambda subdirectories
-!/target/lambda/**/bootstrap
-!/target/lambda/**/bootstrap.zip
-
!*/**/.env.sample
*/**/.env
diff --git a/rust/cloud-storage/README.md b/rust/cloud-storage/README.md
index 3379583086..dfb51bc5fd 100644
--- a/rust/cloud-storage/README.md
+++ b/rust/cloud-storage/README.md
@@ -32,7 +32,7 @@ To learn more read the [infra](../../infra/README.md) documentation.
## Instructions
-- If you haven't built anything in his project before you will need to run `just build_lambdas`
+- Lambda `bootstrap.zip` files are built by CI for deployments. For local Pulumi deploys, run `just build_lambdas` first.
- cd `infra`
- install node modules `npm i`
- ensure you are on your correct AWS account and have pulumi cli logged into your correct work account
diff --git a/rust/cloud-storage/target/lambda/dataloss_prevention_handler/bootstrap.zip b/rust/cloud-storage/target/lambda/dataloss_prevention_handler/bootstrap.zip
deleted file mode 100644
index b9fbc1b037..0000000000
Binary files a/rust/cloud-storage/target/lambda/dataloss_prevention_handler/bootstrap.zip and /dev/null differ
diff --git a/rust/cloud-storage/target/lambda/delete_chat_handler/bootstrap.zip b/rust/cloud-storage/target/lambda/delete_chat_handler/bootstrap.zip
deleted file mode 100644
index 253f5c9a61..0000000000
Binary files a/rust/cloud-storage/target/lambda/delete_chat_handler/bootstrap.zip and /dev/null differ
diff --git a/rust/cloud-storage/target/lambda/deleted_item_poller/bootstrap.zip b/rust/cloud-storage/target/lambda/deleted_item_poller/bootstrap.zip
deleted file mode 100644
index 83fea639ef..0000000000
Binary files a/rust/cloud-storage/target/lambda/deleted_item_poller/bootstrap.zip and /dev/null differ
diff --git a/rust/cloud-storage/target/lambda/document_text_extractor/bootstrap.zip b/rust/cloud-storage/target/lambda/document_text_extractor/bootstrap.zip
deleted file mode 100644
index 420bb8ecf6..0000000000
Binary files a/rust/cloud-storage/target/lambda/document_text_extractor/bootstrap.zip and /dev/null differ
diff --git a/rust/cloud-storage/target/lambda/docx_unzip_handler/bootstrap.zip b/rust/cloud-storage/target/lambda/docx_unzip_handler/bootstrap.zip
deleted file mode 100644
index 895652b8bf..0000000000
Binary files a/rust/cloud-storage/target/lambda/docx_unzip_handler/bootstrap.zip and /dev/null differ
diff --git a/rust/cloud-storage/target/lambda/email_refresh_handler/bootstrap.zip b/rust/cloud-storage/target/lambda/email_refresh_handler/bootstrap.zip
deleted file mode 100644
index 4a2aecfdc6..0000000000
Binary files a/rust/cloud-storage/target/lambda/email_refresh_handler/bootstrap.zip and /dev/null differ
diff --git a/rust/cloud-storage/target/lambda/email_scheduled_handler/bootstrap.zip b/rust/cloud-storage/target/lambda/email_scheduled_handler/bootstrap.zip
deleted file mode 100644
index e15f949cb1..0000000000
Binary files a/rust/cloud-storage/target/lambda/email_scheduled_handler/bootstrap.zip and /dev/null differ
diff --git a/rust/cloud-storage/target/lambda/email_sfs_delete_handler/bootstrap.zip b/rust/cloud-storage/target/lambda/email_sfs_delete_handler/bootstrap.zip
deleted file mode 100644
index 23a9466258..0000000000
Binary files a/rust/cloud-storage/target/lambda/email_sfs_delete_handler/bootstrap.zip and /dev/null differ
diff --git a/rust/cloud-storage/target/lambda/email_suppression_handler/bootstrap.zip b/rust/cloud-storage/target/lambda/email_suppression_handler/bootstrap.zip
deleted file mode 100644
index f64be1cb5f..0000000000
Binary files a/rust/cloud-storage/target/lambda/email_suppression_handler/bootstrap.zip and /dev/null differ
diff --git a/rust/cloud-storage/target/lambda/image_optimizer/bootstrap.zip b/rust/cloud-storage/target/lambda/image_optimizer/bootstrap.zip
deleted file mode 100644
index 7514c4eb02..0000000000
Binary files a/rust/cloud-storage/target/lambda/image_optimizer/bootstrap.zip and /dev/null differ
diff --git a/rust/cloud-storage/target/lambda/memory_scheduler/bootstrap.zip b/rust/cloud-storage/target/lambda/memory_scheduler/bootstrap.zip
deleted file mode 100644
index c3d2310a95..0000000000
Binary files a/rust/cloud-storage/target/lambda/memory_scheduler/bootstrap.zip and /dev/null differ
diff --git a/rust/cloud-storage/target/lambda/memory_worker/bootstrap.zip b/rust/cloud-storage/target/lambda/memory_worker/bootstrap.zip
deleted file mode 100644
index baabef3b28..0000000000
Binary files a/rust/cloud-storage/target/lambda/memory_worker/bootstrap.zip and /dev/null differ
diff --git a/rust/cloud-storage/target/lambda/organization_retention_handler/bootstrap.zip b/rust/cloud-storage/target/lambda/organization_retention_handler/bootstrap.zip
deleted file mode 100644
index 9389db6e97..0000000000
Binary files a/rust/cloud-storage/target/lambda/organization_retention_handler/bootstrap.zip and /dev/null differ
diff --git a/rust/cloud-storage/target/lambda/organization_retention_trigger/bootstrap.zip b/rust/cloud-storage/target/lambda/organization_retention_trigger/bootstrap.zip
deleted file mode 100644
index ff8bafdb2e..0000000000
Binary files a/rust/cloud-storage/target/lambda/organization_retention_trigger/bootstrap.zip and /dev/null differ
diff --git a/rust/cloud-storage/target/lambda/search_upload_handler/bootstrap.zip b/rust/cloud-storage/target/lambda/search_upload_handler/bootstrap.zip
deleted file mode 100644
index e3b940f1be..0000000000
Binary files a/rust/cloud-storage/target/lambda/search_upload_handler/bootstrap.zip and /dev/null differ
diff --git a/rust/cloud-storage/target/lambda/upload_extractor_lambda_handler/bootstrap.zip b/rust/cloud-storage/target/lambda/upload_extractor_lambda_handler/bootstrap.zip
deleted file mode 100644
index a56f72395e..0000000000
Binary files a/rust/cloud-storage/target/lambda/upload_extractor_lambda_handler/bootstrap.zip and /dev/null differ
diff --git a/rust/cloud-storage/target/lambda/upload_extractor_lambda_trigger/bootstrap.zip b/rust/cloud-storage/target/lambda/upload_extractor_lambda_trigger/bootstrap.zip
deleted file mode 100644
index 7044426922..0000000000
Binary files a/rust/cloud-storage/target/lambda/upload_extractor_lambda_trigger/bootstrap.zip and /dev/null differ
diff --git a/rust/cloud-storage/target/lambda/user_link_cleanup_handler/bootstrap.zip b/rust/cloud-storage/target/lambda/user_link_cleanup_handler/bootstrap.zip
deleted file mode 100644
index 4ba61e875e..0000000000
Binary files a/rust/cloud-storage/target/lambda/user_link_cleanup_handler/bootstrap.zip and /dev/null differ
diff --git a/rust/cloud-storage/target/lambda/worker_trigger/bootstrap.zip b/rust/cloud-storage/target/lambda/worker_trigger/bootstrap.zip
deleted file mode 100644
index 3d9c0cf954..0000000000
Binary files a/rust/cloud-storage/target/lambda/worker_trigger/bootstrap.zip and /dev/null differ