Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gitlab-ci sample #20

Merged
merged 32 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
236277d
feat(ci:sync): add Gitlab sync
lakkeger Feb 14, 2024
ec61974
feat(ci:gitlab): add initial gitlab ci pipeline
lakkeger Feb 14, 2024
5878542
fix(ci:gitlab): add bash
lakkeger Feb 14, 2024
1948f75
fix(ci:gitlab): add git
lakkeger Feb 14, 2024
61c1769
fix(ci:gitlab): add pyenv to path
lakkeger Feb 14, 2024
3f3e34c
fix(ci:gitlab): add make
lakkeger Feb 14, 2024
8e12c4f
fix(ci:gitlab): run bash
lakkeger Feb 14, 2024
1cccac6
fix(ci:gitlab): add virtualenv-init
lakkeger Feb 14, 2024
5b510f0
feat(ci:gitlab): trying different approach
lakkeger Feb 14, 2024
14e35ef
fix(ci:gitlab): add zip install
lakkeger Feb 14, 2024
f08dc6f
fix(ci:gitlab): add jq to before_script
lakkeger Feb 14, 2024
f7ca10f
fix(ci:gitlab): add remote DOCKER_SOCK
lakkeger Feb 14, 2024
cb2ee93
feat(ci:gitlab): add pytests
lakkeger Feb 15, 2024
2b97e80
fix(ci:gitlab): change service name
lakkeger Feb 15, 2024
18fe31c
fix(ci:gitlab): tie LS service to jobs
lakkeger Feb 15, 2024
605f5b0
fix(ci:gitlab): move deploy into test job
lakkeger Feb 15, 2024
dc320ef
debug(ci:gitlab): add debug switches
lakkeger Feb 15, 2024
f0ae0c6
fix(ci:gitlab): improve LS control
lakkeger Feb 15, 2024
17c9991
feat(ci:gitlab): add pod artifact and pip dep cache
lakkeger Feb 15, 2024
b635929
fix(ci:gitlab): add LS auth for pro
lakkeger Feb 15, 2024
2eb83de
debug(ci:gitlab): LS service debug
lakkeger Feb 15, 2024
5bceaf3
fix(test): change request url to mock domain
lakkeger Feb 16, 2024
e40e2ff
debug(ci:gitlab): add log dump
lakkeger Feb 16, 2024
8cf2f0f
debug(ci:gitlab): move all steps in one job
lakkeger Feb 16, 2024
d64b28c
fix(ci:gitlab): lambda deps
lakkeger Feb 16, 2024
f2475fe
refactor(ci:gitlab): separate jobs again
lakkeger Feb 16, 2024
de0ed0e
style(ci:gitlab): clean up code
lakkeger Feb 16, 2024
3c76b98
feat(ci:gitlab): add after_script to dump logs
lakkeger Feb 20, 2024
5d43f54
fix(ci:gitlab): remove ci debug variable
lakkeger Feb 21, 2024
179bac4
fix(ci:gitlab): add curl install
lakkeger Feb 21, 2024
831b43c
fix(ci:gitlab): fix diagnose endpoint url
lakkeger Feb 21, 2024
ca3ba98
fix(ci:sync): change Gitlab repo URL
lakkeger Mar 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading