Skip to content

Instantly share code, notes, and snippets.

@briggleman
Last active August 6, 2024 20:48
Show Gist options
  • Select an option

  • Save briggleman/138e5514f9a6647fbf8359033decd3d8 to your computer and use it in GitHub Desktop.

Select an option

Save briggleman/138e5514f9a6647fbf8359033decd3d8 to your computer and use it in GitHub Desktop.

Revisions

  1. briggleman revised this gist May 22, 2020. 1 changed file with 42 additions and 8 deletions.
    50 changes: 42 additions & 8 deletions gitlab-ci.yml
    Original file line number Diff line number Diff line change
    @@ -9,20 +9,22 @@
    stages:
    - test
    - version
    - build
    - deploy

    test:
    stage: test
    image: python:3.7.4-slim-buster
    script:
    - apt-get update && apt-get install -y build-essential gcc
    - apt-get update && apt-get install -y build-essential
    - pip install --upgrade pip
    - pip install poetry
    - poetry --version
    - poetry config settings.virtualenvs.create false
    - poetry config virtualenvs.create false
    - poetry install
    - pytest --cov=my_code_dir tests/
    - pytest --cov=your_directory tests/ --disable-pytest-warnings
    except:
    - tags
    - schedules

    version:
    stage: version
    @@ -33,13 +35,45 @@ version:
    - pip3 install --upgrade pip
    - pip install poetry
    script:
    - poetry version v$(release next-version --bump-patch)
    - release changelog
    - release commit-and-tag pyproject.toml CHANGELOG.md
    - poetry version v$(release next-version --allow-current)
    - release commit-and-tag pyproject.toml
    only:
    refs:
    - master
    except:
    changes:
    - pyproject.toml
    - CHANGELOG.md

    build:
    stage: build
    image: docker:stable
    services:
    - docker:dind
    before_script:
    - apk add --no-cache curl jq python py-pip
    - pip install --upgrade pip
    - pip install awscli
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    script:
    - docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG -f pro.dockerfile .
    - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG $CI_REGISTRY_IMAGE:latest
    - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG $AWS_ECS_REGISTRY/$CI_PROJECT_NAME:$CI_COMMIT_TAG
    - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG $AWS_ECS_REGISTRY/$CI_PROJECT_NAME:latest
    - docker push $CI_REGISTRY_IMAGE
    - $(aws ecr get-login --no-include-email --region $AWS_REGION)
    - docker push $AWS_ECS_REGISTRY/$CI_PROJECT_NAME
    only:
    - tags
    when: on_success

    deploy:
    stage: deploy
    image: python:3.7.4-slim
    before_script:
    - pip install --upgrade pip
    - pip install awscli
    script:
    - aws ecs update-service --cluster $AWS_SAND_CLUSTER --service some-service-name --region $AWS_REGION --force-new-deployment
    only:
    - tags
    when: on_success
  2. briggleman created this gist Oct 29, 2019.
    45 changes: 45 additions & 0 deletions gitlab-ci.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,45 @@
    # example ci/cd file for gitlab ci/cd w/ poetry
    # this file will run tests on merge and will bump
    # the version on commit to master using go-semrel
    # go-semrel commits will trigger a final test for
    # the code coverage pipeline. this file ensures
    # both the pipeline badge and coverage badge are
    # populated and that the pyproject.toml file is
    # bumped as well
    stages:
    - test
    - version

    test:
    stage: test
    image: python:3.7.4-slim-buster
    script:
    - apt-get update && apt-get install -y build-essential gcc
    - pip install --upgrade pip
    - pip install poetry
    - poetry --version
    - poetry config settings.virtualenvs.create false
    - poetry install
    - pytest --cov=my_code_dir tests/
    except:
    - tags

    version:
    stage: version
    image: registry.gitlab.com/juhani/go-semrel-gitlab:v0.20.4
    before_script:
    - apt-get update
    - apt-get install -y python3 python3-pip
    - pip3 install --upgrade pip
    - pip install poetry
    script:
    - poetry version v$(release next-version --bump-patch)
    - release changelog
    - release commit-and-tag pyproject.toml CHANGELOG.md
    only:
    refs:
    - master
    except:
    changes:
    - pyproject.toml
    - CHANGELOG.md