Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c35a16e317 | ||
| 3f2d6093d0 | |||
| fcd7f5f95e |
@@ -1,30 +1,8 @@
|
||||
|
||||
stages:
|
||||
- 'test'
|
||||
- 'build'
|
||||
- 'push'
|
||||
|
||||
pytest:
|
||||
stage: 'test'
|
||||
image: python
|
||||
only:
|
||||
- test
|
||||
- tags
|
||||
cache:
|
||||
paths:
|
||||
- $CI_PROJECT_DIR/venv/
|
||||
before_script:
|
||||
- cd $CI_PROJECT_DIR
|
||||
- python -m venv venv
|
||||
- chmod u+x venv/bin/activate
|
||||
- source venv/bin/activate
|
||||
- pip install --upgrade --quiet pip
|
||||
- pip install --quiet -U -r requirements.txt
|
||||
- pip install --quiet -U -r tests/requirements.txt
|
||||
script:
|
||||
- pytest -v
|
||||
|
||||
|
||||
variables:
|
||||
# DOCKER_HOST: tcp://docker:2375
|
||||
# fill those if you have a proxy in your environment
|
||||
@@ -34,9 +12,20 @@ variables:
|
||||
|
||||
make_image:
|
||||
stage: build
|
||||
needs:
|
||||
- pytest
|
||||
image: docker:26.1.3
|
||||
only:
|
||||
# We want this job to be run on tags only.
|
||||
refs:
|
||||
- tags
|
||||
- push
|
||||
changes:
|
||||
- ^README.md
|
||||
- ^CHANGELOG
|
||||
- ^.gitattribute
|
||||
- ^.gitignore
|
||||
- ^.gitlab-ci.yml
|
||||
- src/**/*
|
||||
- requirements.txt
|
||||
services:
|
||||
- docker:26.1.3-dind
|
||||
|
||||
@@ -65,11 +54,21 @@ make_image:
|
||||
|
||||
# Here, the goal is to tag the "master" branch as "latest"
|
||||
Push latest:
|
||||
needs: ['make_image']
|
||||
variables:
|
||||
# We are just playing with Docker here.
|
||||
# We do not need GitLab to clone the source code.
|
||||
GIT_STRATEGY: none
|
||||
stage: push
|
||||
only:
|
||||
changes:
|
||||
- ^README.md
|
||||
- ^CHANGELOG
|
||||
- ^.gitattribute
|
||||
- ^.gitignore
|
||||
- ^.gitlab-ci.yml
|
||||
- src/**/*
|
||||
- requirements.txt
|
||||
before_script:
|
||||
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
||||
script:
|
||||
@@ -84,10 +83,26 @@ Push latest:
|
||||
# Finally, the goal here is to Docker tag any Git tag
|
||||
# GitLab will start a new pipeline everytime a Git tag is created, which is pretty awesome
|
||||
Push commit:
|
||||
needs: ['make_image']
|
||||
variables:
|
||||
# Again, we do not need the source code here. Just playing with Docker.
|
||||
GIT_STRATEGY: none
|
||||
stage: push
|
||||
only:
|
||||
# We want this job to be run on tags only.
|
||||
refs:
|
||||
- ^tags
|
||||
- push
|
||||
changes:
|
||||
- ^README.md
|
||||
- ^CHANGELOG
|
||||
- ^.gitattribute
|
||||
- ^.gitignore
|
||||
- ^.gitlab-ci.yml
|
||||
- src/**/*
|
||||
- requirements.txt
|
||||
|
||||
|
||||
before_script:
|
||||
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
||||
script:
|
||||
@@ -96,13 +111,23 @@ Push commit:
|
||||
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
|
||||
|
||||
Push tag:
|
||||
needs: ['make_image']
|
||||
variables:
|
||||
# Again, we do not need the source code here. Just playing with Docker.
|
||||
GIT_STRATEGY: none
|
||||
stage: push
|
||||
only:
|
||||
# We want this job to be run on tags only.
|
||||
refs:
|
||||
- tags
|
||||
changes:
|
||||
- ^README.md
|
||||
- ^CHANGELOG
|
||||
- ^.gitattribute
|
||||
- ^.gitignore
|
||||
- ^.gitlab-ci.yml
|
||||
- src/**/*
|
||||
- requirements.txt
|
||||
before_script:
|
||||
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
||||
script:
|
||||
|
||||
Reference in New Issue
Block a user