Skip to content

Commit

Permalink
Simplify CI
Browse files Browse the repository at this point in the history
This comes after a big refactoring of our CI pipeline.
  • Loading branch information
regisb committed Oct 2, 2020
1 parent 91c28a5 commit 9d0f2d9
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 63 deletions.
37 changes: 9 additions & 28 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,17 @@ stages:

test:
script:
- apk add --no-cache make
- make ci-install-alpine-requirements
- pip install .
- make ci-install-python-requirements
- make bootstrap-dev
- make test

build:images:
script:
- apk add --no-cache make
- make ci-install-alpine-requirements
- pip install .
- make ci-build-images
tags:
- private
- make ci-bootstrap-images
- tutor images build all
stage: build

build:docs:
script:
- apk add --no-cache make
- make ci-install-alpine-requirements
- pip install -r requirements/docs.txt
- make docs
artifacts:
Expand All @@ -36,39 +27,29 @@ build:docs:

build:pypi:
script:
- apk add --no-cache make
- make ci-install-alpine-requirements
- make ci-install-python-requirements
- make package
- make bootstrap-dev
- make build-pythonpackage
artifacts:
paths:
- dist/
stage: build

deploy:images:
script:
- apk add --no-cache make
- make ci-install-alpine-requirements
- pip install .
- make ci-push-images
- make ci-bootstrap-images
- docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"
- tutor images push all
only:
- tags
tags:
- private
stage: deploy:images

deploy:pypi:
script:
- apk add --no-cache make
- make ci-install-alpine-requirements
- make ci-install-python-requirements
- make ci-pypi
- make push-pythonpackage
dependencies:
- build:pypi
only:
- tags
tags:
- private
stage: deploy:pypi

deploy:docs:
Expand Down
14 changes: 11 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,24 @@ matrix:
- os: osx
language: generic

env:
jobs:
- PATH=/tmp/bin/:$PATH

script:
# In Mac OS python and pip binaries are v2, so we create symlinks
- mkdir /tmp/bin && ln -s $(which python3) /tmp/bin/python && ln -s $(which pip3) /tmp/bin/pip
- pip install --upgrade pip setuptools==44.0.0
- make ci-info
- make ci-install-plugins
- make bootstrap-dev-plugins
- make test
- make ci-bundle
- make bundle
- make ci-test-bundle

deploy:
# Create github release and push binary to github
- provider: script
script: make ci-github
script: make ci-push-bundle
skip_cleanup: true
on:
tags: true
52 changes: 20 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ upgrade-requirements: ## Upgrade requirements files
pip-compile --upgrade requirements/dev.in
pip-compile --upgrade requirements/docs.in

package: ## Build a package ready to upload to pypi
python3 setup.py sdist
build-pythonpackage: ## Build a python package ready to upload to pypi
python setup.py sdist

test: test-lint test-unit test-format test-package ## Run all tests by decreasing order or priority
push-pythonpackage: ## Push python packages to pypi
twine upload --skip-existing dist/tutor-*.tar.gz

test: test-lint test-unit test-format test-pythonpackage ## Run all tests by decreasing order or priority

test-format: ## Run code formatting tests
black --check --diff $(BLACK_OPTS)
Expand All @@ -30,14 +33,21 @@ test-lint: ## Run code linting tests
pylint --errors-only --ignore=templates ${SRC_DIRS}

test-unit: ## Run unit tests
python3 -m unittest discover tests
python -m unittest discover tests

test-package: package ## Test that package can be uploaded to pypi
test-pythonpackage: build-pythonpackage ## Test that package can be uploaded to pypi
twine check dist/tutor-openedx-$(shell make version).tar.gz

format: ## Format code automatically
black $(BLACK_OPTS)

bootstrap-dev: ## Install dev requirements
pip install .
pip install -r requirements/dev.txt

bootstrap-dev-plugins: bootstrap-dev ## Install dev requirement and all supported plugins
pip install -r requirements/plugins.txt

###### Deployment

bundle: ## Bundle the tutor package in a single "dist/tutor" executable
Expand Down Expand Up @@ -69,22 +79,10 @@ release-overhangio:
###### Continuous integration tasks

ci-info: ## Print info about environment
python3 --version
pip3 --version

ci-install-alpine-requirements: ## Install requirements for a python:alpine image
apk add --no-cache docker gcc libffi-dev libressl-dev musl-dev yaml-dev

ci-install-python-requirements: ## Install requirements
pip3 install --upgrade pip
pip3 install setuptools==44.0.0
pip install .
pip3 install -r requirements/dev.txt

ci-install-plugins: ci-install-python-requirements ## Install all supported plugins
pip3 install -r requirements/plugins.txt
python --version
pip --version

ci-bundle: bundle ## Create bundle and run basic tests
ci-test-bundle: ## Run basic tests on bundle
ls -lh ./dist/tutor
./dist/tutor --version
./dist/tutor config printroot
Expand All @@ -103,7 +101,7 @@ ci-bundle: bundle ## Create bundle and run basic tests
&& bzip2 -d -f ./github-release.bz2 \
&& chmod a+x ./github-release

ci-github: ./releases/github-release ## Upload assets to github
ci-push-bundle: ./releases/github-release ## Upload assets to github
sed "s/TUTOR_VERSION/v$(shell make version)/g" docs/_release_description.md > releases/description.md
git log -1 --pretty=format:%b >> releases/description.md
./releases/github-release release \
Expand All @@ -121,19 +119,9 @@ ci-github: ./releases/github-release ## Upload assets to github
--replace

ci-bootstrap-images:
pip install -r requirements/plugins.txt
pip install .
tutor config save

ci-build-images: ci-bootstrap-images ## Build docker images
tutor images build all

ci-push-images: ci-bootstrap-images ## Push docker images to hub.docker.com
docker login -u "$$DOCKER_USERNAME" -p "$$DOCKER_PASSWORD"
tutor images push all

ci-pypi: ## Push packages to pypi
twine upload --skip-existing dist/tutor-*.tar.gz

###### Additional commands

version: ## Print the current tutor version
Expand Down

0 comments on commit 9d0f2d9

Please sign in to comment.