Skip to content

Commit 76b9864

Browse files
authored
Add gitlab-ci sample (#20)
1 parent 3fc30f2 commit 76b9864

File tree

4 files changed

+84
-2
lines changed

4 files changed

+84
-2
lines changed

.github/workflows/sync.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Sync repo to Gitlab
2+
on: [ push, delete, workflow_dispatch ]
3+
4+
jobs:
5+
sync:
6+
name: Gitlab Sync
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v3
11+
with:
12+
fetch-depth: 0
13+
- name: Mirroring Repository
14+
uses: pixta-dev/repository-mirroring-action@v1.1.1
15+
with:
16+
target_repo_url: git@gitlab.com:localstack.cloud/samples/sample-serverless-image-resizer-s3-lambda.git
17+
ssh_private_key: ${{ secrets.GITLAB_SSH_PRIVATE_KEY }}

.gitlab-ci.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
image: docker:20.10.16-dind
2+
3+
stages:
4+
- deploy
5+
- test
6+
7+
variables:
8+
AWS_ACCESS_KEY_ID: test
9+
AWS_SECRET_ACCESS_KEY: test
10+
AWS_DEFAULT_REGION: us-east-1
11+
AWS_REGION: us-east-1
12+
AWS_ENDPOINT_URL: http://localhost.localstack.cloud:4566
13+
PIP_CACHE_DIR: $CI_PROJECT_DIR/.cache/pip
14+
DOCKER_HOST: tcp://docker:2375
15+
DOCKER_TLS_CERTDIR: ""
16+
DEBUG: 1
17+
LS_LOG: trace
18+
19+
services:
20+
- name: docker:20.10.16-dind
21+
alias: docker
22+
command: ["--tls=false"]
23+
24+
default:
25+
before_script: &default_before_scripts
26+
- apk update
27+
- apk add --no-cache gcc musl-dev linux-headers bash zip jq curl
28+
- apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/v3.15/main python3~3.9
29+
- apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/v3.15/community py3-psutil~5.8
30+
- python3 -m ensurepip
31+
- python3 -m pip install --no-cache --upgrade pip setuptools
32+
- mkdir -p $PIP_CACHE_DIR
33+
- python3 -m pip install localstack awscli awscli-local
34+
- docker pull localstack/localstack-pro:latest
35+
- dind_ip="$(getent hosts docker | cut -d' ' -f1)"
36+
- echo "${dind_ip} localhost.localstack.cloud " >> /etc/hosts
37+
- localstack start -d
38+
- localstack wait -t 30
39+
- (test -f ./ls-state-pod.zip && localstack state import ./ls-state-pod.zip) || true
40+
after_script:
41+
- curl "$AWS_ENDPOINT_URL/_localstack/diagnose" | tee ls_diagnose.log
42+
- docker ps | tee docker_ps.log
43+
- docker inspect localstack-main | tee docker_inspect.log
44+
cache:
45+
paths:
46+
- $CI_PROJECT_DIR/.cache/pip
47+
artifacts:
48+
paths:
49+
- $CI_PROJECT_DIR/ls-state-pod.zip
50+
expire_in: 1 days
51+
52+
deploy:
53+
stage: deploy
54+
script:
55+
- ./bin/deploy.sh
56+
- localstack state export ./ls-state-pod.zip
57+
58+
test:
59+
stage: test
60+
before_script:
61+
- *default_before_scripts
62+
- python3 -m pip install -r requirements-dev.txt
63+
script:
64+
- python3 -m pytest tests
65+

bin/deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ else
6161
cd lambdas/resize
6262
rm -rf package lambda.zip
6363
mkdir package
64-
pip install -r requirements.txt -t package
64+
pip install -r requirements.txt --platform manylinux2014_x86_64 --only-binary=:all: -t package
6565
zip lambda.zip handler.py
6666
cd package
6767
zip -r ../lambda.zip *;

tests/test_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def test_failure_sns_to_ses_integration():
7171
s3.upload_file(file, Bucket=source_bucket, Key=key)
7272

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

0 commit comments

Comments
 (0)