Skip to content

Commit

Permalink
Merge pull request #5 from hhtong/ci
Browse files Browse the repository at this point in the history
Add CircleCI config file
  • Loading branch information
Heidi Tong authored Dec 29, 2020
2 parents e3dd205 + 4874e3f commit d11e449
Show file tree
Hide file tree
Showing 2 changed files with 222 additions and 0 deletions.
218 changes: 218 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
version: 2.1

orbs:
win: circleci/[email protected]

jobs:
#
# linux
#

test-py39: &full-test-template
docker:
- image: circleci/python:3.9

working_directory: ~/repo/

steps:
- checkout

- restore_cache: &restore-cache-template
key: v1-dependencies-{{ checksum "requirements.txt" }}-{{ .Environment.CIRCLE_JOB }}
- run: python -m virtualenv env
- run: &install-dependences-template
name: install requirements
command: |
env/bin/pip install -r ./requirements.txt
env/bin/pip install coverage
- save_cache: &save-cache-template
key: v1-dependencies-{{ checksum "requirements.txt" }}-{{ .Environment.CIRCLE_JOB }}
paths:
- env

- run: env/bin/coverage run -m unittest discover

test-py38:
<<: *full-test-template
docker:
- image: circleci/python:3.8

test-py37:
<<: *full-test-template
docker:
- image: circleci/python:3.7

test-py36:
<<: *full-test-template
docker:
- image: circleci/python:3.6

test-py35:
<<: *full-test-template
docker:
- image: circleci/python:3.5

#
# macOS
#

test-osx-py39: &osx-tests-template
macos:
xcode: "12.2.0"
environment:
PYTHON: 3.9.0
HOMEBREW_NO_AUTO_UPDATE: 1

working_directory: ~/repo

steps:
- checkout

- run: brew install pyenv

# Install desired python version
- restore_cache:
keys:
- pyenv-{{ .Environment.CIRCLE_JOB }}-xcode-12.2.0
- run: pyenv install $PYTHON -s
- save_cache:
key: pyenv-{{ .Environment.CIRCLE_JOB }}-xcode-12.2.0
paths:
- ~/.pyenv

# Set local python version
- run:
name: create virtualenv
command: |
eval "$(pyenv init -)"
pyenv local $PYTHON
python -m pip install virtualenv
python -m virtualenv env
# Restore cache
- restore_cache: *restore-cache-template

- run: *install-dependences-template

- save_cache: *save-cache-template

- run: env/bin/coverage run -m unittest discover

test-osx-py38:
<<: *osx-tests-template
environment:
PYTHON: 3.8.0
HOMEBREW_NO_AUTO_UPDATE: 1

test-osx-py37:
<<: *osx-tests-template
environment:
PYTHON: 3.7.0
HOMEBREW_NO_AUTO_UPDATE: 1

test-osx-py36:
<<: *osx-tests-template
environment:
PYTHON: 3.6.5
HOMEBREW_NO_AUTO_UPDATE: 1

test-osx-py35:
<<: *osx-tests-template
environment:
PYTHON: 3.5.5
HOMEBREW_NO_AUTO_UPDATE: 1

#
# Windows x64
#

test-win-py39: &win-tests-template
executor:
name: win/default

environment:
PYTHON: 3.9.0

working_directory: ~/repo

steps:
- checkout

# Install python
- restore_cache:
key: nuget-{{ .Environment.CIRCLE_JOB }}
- run:
name: install python
command: nuget install python -Version $env:PYTHON -ExcludeVersion -OutputDirectory .
- save_cache:
key: nuget-{{ .Environment.CIRCLE_JOB }}
paths:
- .\python

# Set up virtual environment
- run:
name: create virtualenv
command: |
.\python\tools\python.exe --version
.\python\tools\python.exe -m pip install virtualenv
.\python\tools\python.exe -m virtualenv env
# Install requirements
- restore_cache: *restore-cache-template

- run: &win-install-dependencies-template
name: install dependencies
command: |
env\Scripts\activate.ps1
python --version
pip install -r requirements.txt
pip install coverage
- save_cache: *save-cache-template

# Run tests
- run: &win-run-unittests-template
name: run unittests
command: |
env\Scripts\activate.ps1
coverage run -m unittest discover
test-win-py38:
<<: *win-tests-template
environment:
PYTHON: 3.8.0

test-win-py37:
<<: *win-tests-template
environment:
PYTHON: 3.7.5

test-win-py36:
<<: *win-tests-template
environment:
PYTHON: 3.6.8

test-win-py35:
<<: *win-tests-template
environment:
PYTHON: 3.5.4

workflows:
version: 2.1
tests:
jobs:
- test-py39
- test-py38
- test-py37
- test-py36
- test-py35
- test-osx-py39
- test-osx-py38
- test-osx-py37
- test-osx-py36
- test-osx-py35
- test-win-py39
- test-win-py38
- test-win-py37
- test-win-py36
- test-win-py35
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[![Linux/Mac/Windows build status](
https://circleci.com/gh/dwave-examples/nurse-scheduling.svg?style=svg)](
https://circleci.com/gh/dwave-examples/nurse-scheduling)

# Nurse Scheduling

This is a demo of a nurse scheduling model developed by Ikeda, Nakamura
Expand Down

0 comments on commit d11e449

Please sign in to comment.