Skip to content

Commit

Permalink
Add gitlab-ci sample (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
lakkeger authored Mar 14, 2024
1 parent 3fc30f2 commit 76b9864
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 2 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Sync repo to Gitlab
on: [ push, delete, workflow_dispatch ]

jobs:
sync:
name: Gitlab Sync
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Mirroring Repository
uses: pixta-dev/[email protected]
with:
target_repo_url: [email protected]:localstack.cloud/samples/sample-serverless-image-resizer-s3-lambda.git
ssh_private_key: ${{ secrets.GITLAB_SSH_PRIVATE_KEY }}
65 changes: 65 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
image: docker:20.10.16-dind

stages:
- deploy
- test

variables:
AWS_ACCESS_KEY_ID: test
AWS_SECRET_ACCESS_KEY: test
AWS_DEFAULT_REGION: us-east-1
AWS_REGION: us-east-1
AWS_ENDPOINT_URL: http://localhost.localstack.cloud:4566
PIP_CACHE_DIR: $CI_PROJECT_DIR/.cache/pip
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
DEBUG: 1
LS_LOG: trace

services:
- name: docker:20.10.16-dind
alias: docker
command: ["--tls=false"]

default:
before_script: &default_before_scripts
- apk update
- apk add --no-cache gcc musl-dev linux-headers bash zip jq curl
- apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/v3.15/main python3~3.9
- apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/v3.15/community py3-psutil~5.8
- python3 -m ensurepip
- python3 -m pip install --no-cache --upgrade pip setuptools
- mkdir -p $PIP_CACHE_DIR
- python3 -m pip install localstack awscli awscli-local
- docker pull localstack/localstack-pro:latest
- dind_ip="$(getent hosts docker | cut -d' ' -f1)"
- echo "${dind_ip} localhost.localstack.cloud " >> /etc/hosts
- localstack start -d
- localstack wait -t 30
- (test -f ./ls-state-pod.zip && localstack state import ./ls-state-pod.zip) || true
after_script:
- curl "$AWS_ENDPOINT_URL/_localstack/diagnose" | tee ls_diagnose.log
- docker ps | tee docker_ps.log
- docker inspect localstack-main | tee docker_inspect.log
cache:
paths:
- $CI_PROJECT_DIR/.cache/pip
artifacts:
paths:
- $CI_PROJECT_DIR/ls-state-pod.zip
expire_in: 1 days

deploy:
stage: deploy
script:
- ./bin/deploy.sh
- localstack state export ./ls-state-pod.zip

test:
stage: test
before_script:
- *default_before_scripts
- python3 -m pip install -r requirements-dev.txt
script:
- python3 -m pytest tests

2 changes: 1 addition & 1 deletion bin/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ else
cd lambdas/resize
rm -rf package lambda.zip
mkdir package
pip install -r requirements.txt -t package
pip install -r requirements.txt --platform manylinux2014_x86_64 --only-binary=:all: -t package
zip lambda.zip handler.py
cd package
zip -r ../lambda.zip *;
Expand Down
2 changes: 1 addition & 1 deletion tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def test_failure_sns_to_ses_integration():
s3.upload_file(file, Bucket=source_bucket, Key=key)

def _check_message():
response = requests.get("http://localhost:4566/_aws/ses")
response = requests.get("http://localhost.localstack.cloud:4566/_aws/ses")
messages = response.json()["messages"]
assert key in messages[-1]["Body"]["text_part"]

Expand Down

0 comments on commit 76b9864

Please sign in to comment.