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

Set up continuous integration #5

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
961894d
Issue #2: add simple test case to check CI is running properly
dzhoshkun Sep 6, 2019
990bec9
Issue #2: add a simple CI config to run tests on Windows and Linux
dzhoshkun Sep 6, 2019
0ef0404
Issue #2: add a Dockerfile and docker setup stage to CI
dzhoshkun Sep 6, 2019
17bd0ab
Fix CI config file keyword
dzhoshkun Sep 6, 2019
b404a6c
Issue #2: remove "gce" tag from CI section for docker build
dzhoshkun Sep 6, 2019
54ba9c7
Revert "Issue #2: remove "gce" tag from CI section for docker build"
dzhoshkun Sep 6, 2019
dbbd4d0
Issue #2: use "2-ensure-docker-build-runs" tag for docker image inste…
dzhoshkun Sep 6, 2019
928c3a6
Issue #2: use temporary Windows docker image in Windows CI job
dzhoshkun Sep 6, 2019
d78e299
Issue #2: add docker tags to CI config
dzhoshkun Sep 6, 2019
72346a2
Issue #2: move Linux Dockerfile to linux folder [ci-skip]
dzhoshkun Sep 6, 2019
ebc6e0c
#2: use regular runner on Hopper due to https://gitlab.com/gitlab-org…
dzhoshkun Sep 24, 2019
0b5e30e
#2: use a virtualenv in the absence of proper Docker support on Hoppe…
dzhoshkun Sep 24, 2019
df4fc7b
#2: make it explicit in Docker configuration that only Linux is suppo…
dzhoshkun Sep 24, 2019
4bc0a56
#2: fix Docker folder path in CI config
dzhoshkun Sep 24, 2019
1aa1b28
#2: comment out "only" section in CI Docker build configuration to fo…
dzhoshkun Sep 24, 2019
eff3657
#2: use "master" as Docker image version in CI config to force its cr…
dzhoshkun Sep 24, 2019
ff6b181
Revert "#2: use "master" as Docker image version in CI config to forc…
dzhoshkun Sep 24, 2019
3fb6373
Revert "#2: comment out "only" section in CI Docker build configurati…
dzhoshkun Sep 24, 2019
236b7ba
#2: use "master" version for Docker image to be pulled from registry …
dzhoshkun Sep 24, 2019
0e23f8c
#5: use same Docker image path when building and for testing
dzhoshkun Oct 22, 2019
7f1bb68
#5: add pytest as a dev dependency to setup.py
dzhoshkun Oct 22, 2019
1dc4891
#5: add a before_script section to base test task to install dev depe…
dzhoshkun Oct 22, 2019
cb7d7d4
#5: remove pytest installation step from Dockerfile
dzhoshkun Oct 22, 2019
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
54 changes: 54 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
stages:
- setup
- test

setup:docker:linux:
image: docker:18.09.0
stage: setup
variables:
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
DOCKER_IMAGE_NAME_CI: ${CI_REGISTRY_IMAGE}/puma-ci-linux:${CI_COMMIT_REF_SLUG}
services:
- docker:dind
script:
# Login to our registry
- echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin ${CI_REGISTRY}
- cd ./ci/docker/linux
- docker build --target PUMA_CI_LINUX -t ${DOCKER_IMAGE_NAME_CI} .
- docker push ${DOCKER_IMAGE_NAME_CI}
tags:
- docker
- gce
only:
changes:
- ci/docker/linux/**/*

.test_base_task: &test_base_task
script:
- pytest
dzhoshkun marked this conversation as resolved.
Show resolved Hide resolved

test:windows:
<<: *test_base_task
tags:
- gift-hopper
- windows
# This section should ideally be identical to the Linux section. However, we can't yet use Docker
# on the Hopper Windows version (1903) due to https://gitlab.com/gitlab-org/gitlab-runner/issues/4396
variables:
WORKON_HOME: /c/Users/Public/PythonVirtualEnvs
VIRTUAL_ENV_NAME: xononav-ci-${CI_JOB_ID}
before_script:
# Create and activate virtual environment
- mkvirtualenv.bat --python=python3.7.1.exe ${VIRTUAL_ENV_NAME}
- source ${WORKON_HOME}/${VIRTUAL_ENV_NAME}/Scripts/activate
after_script:
# Cleanup virtual environment
- rmvirtualenv.bat ${VIRTUAL_ENV_NAME}

test:linux:
<<: *test_base_task
image: registry.gitlab.com/gift-surg/puma/puma-ci-linux:master
tags:
- gift-little
- docker
15 changes: 15 additions & 0 deletions ci/docker/linux/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM ubuntu:18.04 AS PUMA_CI_LINUX
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
tzdata \
git-core \
python3.7 \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be specifying version numbers here to ensure that subsequent builds are the same - the only problem is that these versions aren't available indefinitely from the apt repositories, causing failed builds later on.
I'm not sure what the best solution is for this - I think for now it's okay, but in the future if we were to be more strict then we may have to come up with a more permanent (non trivial!) solution

python3-distutils \
curl \
&& rm -rf /var/lib/apt/lists/*
# Make python3.7 available via python
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.7 1
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
RUN python get-pip.py
# Install needed tools
RUN pip install pytest
dzhoshkun marked this conversation as resolved.
Show resolved Hide resolved
Empty file added tests/__init__.py
Empty file.
7 changes: 7 additions & 0 deletions tests/ensure_ci_works_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from unittest import TestCase


class EnsureCIWorksTest(TestCase):

def test_ci_works(self):
self.assertTrue(True)