From 6129db605083648fcd296b68d71a85762bdd0dfe Mon Sep 17 00:00:00 2001 From: Luiz Scheinkman Date: Mon, 5 Nov 2018 09:40:55 -0800 Subject: [PATCH] DEVOPS-387: Move contributor validation to circleci. --- .circleci/config.yml | 121 ++++++++++++++++++++++++++++++ ci/circle/validate-contributor.sh | 61 +++++++++++++++ circle.yml | 46 ------------ 3 files changed, 182 insertions(+), 46 deletions(-) create mode 100644 .circleci/config.yml create mode 100755 ci/circle/validate-contributor.sh delete mode 100644 circle.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000000..e164edb3c1 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,121 @@ +version: 2 +jobs: + validate-contributor: + machine: true + steps: + - checkout + - run: + name: Validate contributor license + command: ci/circle/validate-contributor.sh + + build-and-test-osx: + macos: + xcode: '8.3.3' + working_directory: ~/numenta/nupic + parallelism: 1 + environment: + XCODE_SCHEME: nupic + XCODE_WORKSPACE: nupic + ARCHFLAGS: "-arch x86_64" + PYTHONPATH: "$HOME/Library/Python/2.7/lib/python/site-packages" + PYBIN: "$HOME/Library/Python/2.7/bin" + + steps: + # Machine setup + - run: + name: Make sure to use OS X in CircleCI Web UI + command: | + if [[ "$OSTYPE" != "darwin"* ]]; then + echo "Must set option to use OS X in CircleCI Web UI" && exit 1; + fi + - run: sudo systemsetup -settimezone 'GMT' + - run: + name: Restoring system python + command: | + brew update + brew uninstall python + curl https://bootstrap.pypa.io/get-pip.py | python - --user + echo 'export PATH=$HOME/Library/Python/2.7/bin:$PATH' >> $BASH_ENV + - checkout + + # Dependencies + # Restore the dependency cache + - restore_cache: + keys: + # This branch if available + - v1-dep-{{ .Branch }}- + # Default branch if not + - v1-dep-master- + # Any branch if there are none on the default branch - this should be unnecessary if you have your default branch configured correctly + - v1-dep- + + - run: + name: Install dependencies + command: | + pip install --upgrade --user --ignore-installed setuptools setuptools-scm wheel + pip install --no-cache-dir --user -r requirements.txt --verbose || exit + brew install mysql@5.7 + brew tap homebrew/services + brew tap homebrew/services + brew services start mysql@5.7 + + # Save dependency cache + - save_cache: + key: v1-dep-{{ .Branch }}-{{ epoch }} + paths: + # This is a broad list of cache paths to include many possible development environments + # You can probably delete some of these entries + - vendor/bundle + - ~/virtualenvs + - ~/.m2 + - ~/.ivy2 + - ~/.bundle + - ~/.go_workspace + - ~/.gradle + - ~/.cache/bower + + # Build + - run: + name: Building wheel + environment: + VERBOSE: 1 + command: python setup.py bdist_wheel + + # Test + - run: + name: Running python tests + command: | + mkdir test_reports + pip install --user --no-index --find-links=`pwd`/dist/ nupic + python setup.py test --pytest-args="--junitxml=test_reports/py_test_report.xml --verbose --boxed --cov nupic --cov-report html unit integration" + environment: + NTA_CONF_PROP_nupic_cluster_database_host: 127.0.0.1 + + - store_test_results: + path: test_reports + - store_artifacts: + path: dist + + deploy-s3: + machine: true + steps: + - attach_workspace: + at: dist + - run: + name: Deploying to S3 + command: ci/circle/deploy_s3-osx.sh + +workflows: + version: 2 + build-test-deploy: + jobs: + - validate-contributor + - build-and-test-osx: + requires: + - validate-contributor + - deploy-s3: + requires: + - build-and-test-osx + filters: + branches: + only: master diff --git a/ci/circle/validate-contributor.sh b/ci/circle/validate-contributor.sh new file mode 100755 index 0000000000..e1543bee06 --- /dev/null +++ b/ci/circle/validate-contributor.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# ---------------------------------------------------------------------- +# Numenta Platform for Intelligent Computing (NuPIC) +# Copyright (C) 2018, Numenta, Inc. Unless you have purchased from +# Numenta, Inc. a separate commercial license for this software code, the +# following terms and conditions apply: +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero Public License version 3 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Affero Public License for more details. +# +# You should have received a copy of the GNU Affero Public License +# along with this program. If not, see http://www.gnu.org/licenses. +# +# http://numenta.org/licenses/ +# ---------------------------------------------------------------------- + +set -o errexit + +# Download latest contributors list +curl http://staging.numenta.org/resources/contributors.csv -o contributors.csv + +# Checks if the given user is a valid contributor +# parameters: +# 1. Name +# 2. Email +function isValidContributor() { + + # Validate name + if [ "$(cut -d, -f1 ./contributors.csv | grep "$1")" ]; then + return 0 + fi + + # Validate email + if [ "$(cut -d, -f3 ./contributors.csv | grep "$2")" ]; then + return 0 + fi + + return 1 +} + +# Get last commiter's name and email +SHA=$(git rev-list --no-merges -1 HEAD) +NAME=$(git log -n 1 --pretty=format:%an ${SHA}) +EMAIL=$(git log -n 1 --pretty=format:%ae ${SHA}) + +# Validate contributor +if isValidContributor "${NAME}" "${EMAIL}"; then + echo "${NAME} signed the Contributor License" + exit 0 +fi + +# Not Found +echo "${NAME} <${EMAIL}> must sign the Contributor License (http://numenta.org/licenses/cl/)" +exit 1 + diff --git a/circle.yml b/circle.yml deleted file mode 100644 index 656d9ab87b..0000000000 --- a/circle.yml +++ /dev/null @@ -1,46 +0,0 @@ -machine: - timezone: - GMT - xcode: - version: 8.3 - environment: - XCODE_SCHEME: nupic - XCODE_WORKSPACE: nupic - ARCHFLAGS: "-arch x86_64" - PYTHONPATH: "$HOME/Library/Python/2.7/lib/python/site-packages" - PATH: "$HOME/Library/Python/2.7/bin:$PATH" - PYBIN: "$HOME/Library/Python/2.7/bin" - pre: - - sudo pip install --ignore-installed --upgrade --verbose virtualenv - # Link virtualenv to /usr/local/bin if it doesn't exist and always give exit status of 0. - - "([ ! -e /usr/local/bin/virtualenv ] && ln -s ~/Library/Python/2.7/bin/virtualenv /usr/local/bin/virtualenv) || true" - - if [[ "$OSTYPE" != "darwin"* ]]; then echo "Must set option to use OS X in CircleCI Web UI" && exit 1; fi - -dependencies: - override: - # Install all dependencies - - brew update - - brew install mysql - - brew tap homebrew/services - - brew services start mysql - - sudo pip install --upgrade pip - - pip install --upgrade --user --ignore-installed setuptools wheel - - pip install --user -r requirements.txt --quiet || exit - -compile: - override: - # Remove the virtualenv before it can cause problems. As of May 2017 the CircleCI virtualenv/path setup causes some tests to fail unnecessarily. - - rm -r ~/virtualenvs - - python setup.py bdist_wheel - - pip install --user --no-index --find-links=`pwd`/dist/ nupic - -test: - override: - - python setup.py test --pytest-args="--verbose --boxed --junit-xml=`pwd`/nupic-test-results.xml --cov nupic --cov-report html unit integration" - post: - # We want to have the test report and wheel in both Circle_Artifacts as - # well as dist, for the sake of debugging - - cp dist/*.whl $CIRCLE_ARTIFACTS/ - - cp nupic-test-results.xml $CIRCLE_ARTIFACTS/ - # If not on a fork, upload artifacts to S3 - - if [[ "$CIRCLE_REPOSITORY_URL" == "https://github.com/numenta/nupic" ]]; then ci/circle/deploy_s3-osx.sh; else echo "Skipping deployment, as this is a fork"; fi