|
| 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 | + |
0 commit comments