diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0d15a3f..db367f5 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -7,6 +7,12 @@ on: pull_request: types: [opened, synchronize, reopened, labeled] +# Serialize runs per ref so two concurrent runs never deploy the same stack at +# once (AWS Lambda allows only one in-flight code update per function). +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false + jobs: setup: runs-on: ubuntu-latest @@ -34,7 +40,7 @@ jobs: - name: Cache uv uses: actions/cache@v4 with: - path: ~/.cache/uv + path: ${{ runner.temp }}/setup-uv-cache key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }} restore-keys: | uv-${{ runner.os }}- @@ -98,7 +104,7 @@ jobs: - name: Cache uv uses: actions/cache@v4 with: - path: ~/.cache/uv + path: ${{ runner.temp }}/setup-uv-cache key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }} - name: Install dependencies @@ -126,7 +132,7 @@ jobs: - name: Cache uv uses: actions/cache@v4 with: - path: ~/.cache/uv + path: ${{ runner.temp }}/setup-uv-cache key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }} - name: Install dependencies @@ -175,6 +181,14 @@ jobs: - name: Install uv uses: astral-sh/setup-uv@v5 + - name: Cache uv + uses: actions/cache@v4 + with: + path: ${{ runner.temp }}/setup-uv-cache + key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }} + restore-keys: | + uv-${{ runner.os }}- + - name: Install dependencies run: uv sync --no-dev diff --git a/build_scripts/deploy.sh b/build_scripts/deploy.sh index 14d7ce7..3323e25 100755 --- a/build_scripts/deploy.sh +++ b/build_scripts/deploy.sh @@ -172,13 +172,15 @@ update_lambda_code() { for FUNCTION in "${LAMBDA_FUNCTIONS[@]}"; do ( echo "Updating Lambda function code: $FUNCTION..." - if ! aws lambda update-function-code \ + if ERROR_OUTPUT=$(aws lambda update-function-code \ --function-name "$FUNCTION" \ - --zip-file fileb://$OUTPUT_DIR/$KEY &>/dev/null; then + --zip-file fileb://$OUTPUT_DIR/$KEY 2>&1); then + echo "Lambda function code updated successfully: $FUNCTION." + else echo "Error: Failed to update Lambda function code: $FUNCTION." + echo "$ERROR_OUTPUT" exit 1 fi - echo "Lambda function code updated successfully: $FUNCTION." ) & PIDS+=($!) UPDATE_COUNT=$((UPDATE_COUNT + 1)) @@ -273,7 +275,7 @@ if [ $? -ne 0 ]; then echo "Error: Dependency export failed." exit 1 fi -uv run pip install --no-deps -r $OUTPUT_DIR/requirements.txt -t $OUTPUT_DIR +uv pip install --no-deps -r $OUTPUT_DIR/requirements.txt -t $OUTPUT_DIR if [ $? -ne 0 ]; then echo "Error: Dependency install failed." exit 1