Skip to content

Commit

Permalink
Merge branch 'dev' into feature/dev-without-data-api
Browse files Browse the repository at this point in the history
  • Loading branch information
solomon-negusse authored Aug 15, 2024
2 parents 66c1de6 + 116c344 commit ea80ec4
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 12 deletions.
4 changes: 2 additions & 2 deletions scripts/delete_workspace
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

set -e

docker-compose -f terraform/docker/docker-compose.yml build
docker-compose -f terraform/docker/docker-compose.yml run --entrypoint delete_workspace --rm terraform "$@"
docker compose -f terraform/docker/docker-compose.yml build
docker compose -f terraform/docker/docker-compose.yml run --entrypoint delete_workspace --rm terraform "$@"
6 changes: 2 additions & 4 deletions scripts/develop
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

set -e



# Default values
POSITIONAL=()
BUILD=true
Expand All @@ -26,8 +24,8 @@ done
set -- "${POSITIONAL[@]}" # restore positional parameters

if [ "${BUILD}" = true ]; then
docker-compose -f docker-compose.dev.yml up --abort-on-container-exit --remove-orphans --build
docker compose -f docker-compose.dev.yml up --abort-on-container-exit --remove-orphans --build
else
docker-compose -f docker-compose.dev.yml up --abort-on-container-exit --remove-orphans
docker compose -f docker-compose.dev.yml up --abort-on-container-exit --remove-orphans
fi

4 changes: 2 additions & 2 deletions scripts/infra
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ set -e

GIT_SHA=$(git rev-parse HEAD)

docker-compose -f terraform/docker/docker-compose.yml build
docker-compose -f terraform/docker/docker-compose.yml run --rm terraform "$@" -var="git_sha=${GIT_SHA}" -w default # force terraform to always use default branch
docker compose -f terraform/docker/docker-compose.yml build
docker compose -f terraform/docker/docker-compose.yml run --rm terraform "$@" -var="git_sha=${GIT_SHA}" -w default # force terraform to always use default branch
2 changes: 1 addition & 1 deletion scripts/terraform
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

set -e

docker-compose -f terraform/docker/docker-compose.yml run --rm --entrypoint terraform --workdir /usr/local/src/terraform terraform "$@"
docker compose -f terraform/docker/docker-compose.yml run --rm --entrypoint terraform --workdir /usr/local/src/terraform terraform "$@"
8 changes: 5 additions & 3 deletions scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ set -e

PYTHON_RUNTIME="python3.10"
MERCANTILE_VERSION="1.2.1"
NUMPY_VERSION="1.26.4"
PILLOW_VERSION="9.5.0"
RASTERIO_VERSION="1.3.8"

MERCANTILE_FILENAME="${PYTHON_RUNTIME}-mercantile_${MERCANTILE_VERSION}.zip"
NUMPY_FILENAME="${PYTHON_RUNTIME}-numpy_${NUMPY_VERSION}.zip"
PILLOW_FILENAME="${PYTHON_RUNTIME}-pillow_${PILLOW_VERSION}.zip"
RASTERIO_FILENAME="${PYTHON_RUNTIME}-rasterio_${RASTERIO_VERSION}.zip"

Expand Down Expand Up @@ -39,13 +41,13 @@ for filename in $MERCANTILE_FILENAME $PILLOW_FILENAME $RASTERIO_FILENAME; do
done

if [ "${BUILD}" = true ]; then
docker-compose -f docker-compose.test.yml --project-name gfw-tile-cache_test build app
docker compose -f docker-compose.test.yml --project-name gfw-tile-cache_test build app
fi

set +e
docker-compose -f docker-compose.test.yml --project-name gfw-tile-cache_test run --rm app tests/"$@" -vv
docker compose -f docker-compose.test.yml --project-name gfw-tile-cache_test run --rm app tests/"$@" -vv
exit_code=$?
docker-compose -f docker-compose.test.yml --project-name gfw-tile-cache_test down --remove-orphans
docker compose -f docker-compose.test.yml --project-name gfw-tile-cache_test down --remove-orphans
rm -rf tests/terraform/terraform.tfstate* \
tests/terraform/.terraform.lock.hcl \
tests/terraform/.terraform/modules/modules.json
Expand Down
1 change: 1 addition & 0 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ module "lambda_raster_tiler" {
source = "./modules/lambda_raster_tiler"
environment = var.environment
lambda_layers = [
data.terraform_remote_state.lambda_layers.outputs.py310_numpy_1264_arn,
data.terraform_remote_state.lambda_layers.outputs.py310_pillow_950_arn,
data.terraform_remote_state.lambda_layers.outputs.py310_rasterio_138_arn,
data.terraform_remote_state.lambda_layers.outputs.py310_mercantile_121_arn
Expand Down
Binary file added tests/fixtures/python3.10-numpy_1.26.4.zip
Binary file not shown.
19 changes: 19 additions & 0 deletions tests/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ provider "aws" {
locals {
lambda_runtime_sn = replace(replace(var.lambda_runtime, ".", ""), "thon", "")
mercantile_layer_filename = "${var.lambda_runtime}-${var.mercantile_name_version}.zip"
numpy_layer_filename = "${var.lambda_runtime}-${var.numpy_name_version}.zip"
pillow_layer_filename = "${var.lambda_runtime}-${var.pillow_name_version}.zip"
rasterio_layer_filename = "${var.lambda_runtime}-${var.rasterio_name_version}.zip"
}
Expand All @@ -46,6 +47,23 @@ resource "aws_s3_bucket" "tiles_test" {
force_destroy = true
}

resource "aws_s3_bucket_object" "numpy_layer" {
bucket = aws_s3_bucket.pipelines_test.id
key = "lambda_layers/${local.numpy_layer_filename}"
source = "../fixtures/${local.numpy_layer_filename}"
etag = filemd5("../fixtures/${local.numpy_layer_filename}")
}

resource "aws_lambda_layer_version" "numpy_layer" {
layer_name = substr("${local.lambda_runtime_sn}_${replace(var.numpy_name_version, ".", "")}", 0, 64)
s3_bucket = aws_s3_bucket_object.numpy_layer.bucket
s3_key = aws_s3_bucket_object.numpy_layer.key
compatible_runtimes = [var.lambda_runtime]
source_code_hash = filebase64sha256(
"../fixtures/${local.numpy_layer_filename}"
)
}

resource "aws_s3_bucket_object" "rasterio_layer" {
bucket = aws_s3_bucket.pipelines_test.id
key = "lambda_layers/${local.rasterio_layer_filename}"
Expand Down Expand Up @@ -101,6 +119,7 @@ module "lambda_raster_tiler" {
source = "../../terraform/modules/lambda_raster_tiler"
environment = "test"
lambda_layers = [
aws_lambda_layer_version.numpy_layer.arn,
aws_lambda_layer_version.pillow_layer.arn,
aws_lambda_layer_version.rasterio_layer.arn,
aws_lambda_layer_version.mercantile_layer.arn
Expand Down
6 changes: 6 additions & 0 deletions tests/terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ variable "mercantile_name_version" {
default = "mercantile_1.2.1"
}

variable "numpy_name_version" {
description = "Name and version, separated by underscore (example: numpy_1.26.4)"
type = string
default = "numpy_1.26.4"
}

variable "pillow_name_version" {
description = "Name and version, separated by underscore (example: pillow_9.5.0)"
type = string
Expand Down

0 comments on commit ea80ec4

Please sign in to comment.