-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Partial Code Release (from: 15195d89) - MIT License
- Supervised model / NoPress (policy, draw, value) - Self-play model
- Loading branch information
0 parents
commit 2a16758
Showing
888 changed files
with
617,662 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
# Created by .ignore support plugin (hsz.mobi) | ||
### Python template | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.notes | ||
.idea | ||
.Python | ||
env/ | ||
venv-dip/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*,cover | ||
.hypothesis/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# dotenv | ||
.env | ||
.env* | ||
|
||
# virtualenv | ||
.venv | ||
venv/ | ||
ENV/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# Empty directories | ||
diplomacy/games | ||
|
||
# Pickle | ||
*.p | ||
*.pkl | ||
|
||
# Outputs | ||
out* | ||
zzz* | ||
|
||
# Mac | ||
*.DS_Store | ||
|
||
# Emacs | ||
*~ | ||
*# | ||
|
||
# File backups | ||
*.bak | ||
|
||
# Protocol buffers | ||
*.pb | ||
|
||
# Tests | ||
.pytest_cache | ||
data | ||
*tests.xml | ||
|
||
# Tensorboard | ||
events.out.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,262 @@ | ||
// Pipeline | ||
import groovy.json.JsonSlurper | ||
import hudson.Util | ||
import java.util.concurrent.TimeUnit | ||
|
||
// Constants | ||
String PENDING_MSG = "Jenkins started the build." | ||
String SUCCESS_MSG = "The Jenkins build completed successfully." | ||
String FAILURE_MSG = "The Jenkins build failed." | ||
|
||
// Parsing data | ||
def data = new JsonSlurper().parseText(env.payload) | ||
|
||
// Detecting Git URL | ||
String USERNAME = data.repository.owner.login | ||
String REPOSITORY = data.repository.name | ||
String GITHUB_URL = data.repository.ssh_url | ||
|
||
// Determining current pipeline | ||
int exit_status = 0 | ||
String BUILD_TYPE = "" | ||
String COMMIT_HASH = "" | ||
String SHORT_HASH = "" | ||
String PR_BRANCH = "" | ||
String COMMIT_BRANCH = "" | ||
String COMMIT_URL = "" | ||
String BASE_HASH = "0000000" | ||
String SENDER = "" | ||
int PR_NUMBER = 0 | ||
String CHECKOUT_BRANCH = "" | ||
String CHECKOUT_REF = "" | ||
String ROOT_CONTEXT = "jenkins/diplomacy.ai" | ||
String CONTEXT = "" | ||
String MESSAGE = "" | ||
|
||
// ---- Push ---- | ||
if (data.ref != null && data.after.substring(0, 7) != "0000000") { | ||
BUILD_TYPE = "push" | ||
COMMIT_HASH = data.after | ||
SHORT_HASH = COMMIT_HASH.substring(0, 7) | ||
COMMIT_BRANCH = data.ref.replaceAll("refs/heads/", "") | ||
COMMIT_URL = data.compare | ||
SENDER = data.pusher.name | ||
CHECKOUT_BRANCH = COMMIT_HASH | ||
CHECKOUT_REF = "" | ||
CONTEXT = ROOT_CONTEXT + "/push" | ||
MESSAGE = data.head_commit.message | ||
currentBuild.description = "${SHORT_HASH} - ${COMMIT_BRANCH} - ${MESSAGE}" | ||
|
||
// ---- Pull Request ---- | ||
} else if (data.pull_request != null \ | ||
&& data.number > 0 \ | ||
&& (data.action == "opened" || data.action == "reopened" || data.action == "synchronize")) { | ||
BUILD_TYPE = "pr" | ||
COMMIT_HASH = data.pull_request.head.sha | ||
SHORT_HASH = COMMIT_HASH.substring(0, 7) | ||
PR_BRANCH = data.pull_request.head.label | ||
COMMIT_BRANCH = data.pull_request.base.ref | ||
COMMIT_URL = data.pull_request.html_url | ||
BASE_HASH = data.pull_request.base.sha | ||
SENDER = data.pull_request.user.login | ||
PR_NUMBER = data.pull_request.number | ||
CHECKOUT_BRANCH = COMMIT_HASH | ||
CHECKOUT_REF = "+refs/pull/*:refs/remotes/origin/pr/* +refs/heads/*:refs/remotes/origin/*" | ||
CONTEXT = ROOT_CONTEXT + "/pr" | ||
MESSAGE = data.pull_request.title | ||
currentBuild.description = "${SHORT_HASH} - PR #${PR_NUMBER} - ${MESSAGE}" | ||
|
||
// ---- No need to build ---- | ||
} else { | ||
currentBuild.result = "SUCCESS" | ||
currentBuild.description = "---" | ||
return | ||
} | ||
|
||
|
||
// ====== STAGES ======= | ||
data = null | ||
String STRIPPED_BRANCH = COMMIT_BRANCH.replaceAll("/", "_") | ||
|
||
// ------------------------------- | ||
// 1. Setting Status | ||
try { | ||
githubNotify account: USERNAME, context: ROOT_CONTEXT, credentialsId: 'ppaquette-jenkins-api-as-password', description: PENDING_MSG, gitApiUrl: '', repo: REPOSITORY, sha: COMMIT_HASH, status: 'PENDING', targetUrl: '' | ||
} catch(err) { | ||
echo "Error setting status on GitHub commit: ${err}" | ||
exit_status = 1 | ||
currentBuild.result = "FAILURE" | ||
} | ||
|
||
// ------------------------------- | ||
// 2. Running tests | ||
parallel_test = [:] | ||
|
||
// Running Python 3.7 everytime, except for "web", "webdip", "build", "build_cpu" branch | ||
if (BUILD_TYPE == 'push' && (COMMIT_BRANCH == 'web' || COMMIT_BRANCH == 'webdip' || COMMIT_BRANCH == 'build' || COMMIT_BRANCH == 'build_cpu')) { | ||
// Skipping | ||
} else { | ||
parallel_test['python_3.7'] = { | ||
node('ubuntu-1604-large') { | ||
stage('Python 3.7') { | ||
try { | ||
timeout(time: 20, activity: true, unit: 'MINUTES') { | ||
githubNotify account: USERNAME, context: CONTEXT + "/python3.7", credentialsId: 'ppaquette-jenkins-api-as-password', description: PENDING_MSG, gitApiUrl: '', repo: REPOSITORY, sha: COMMIT_HASH, status: 'PENDING', targetUrl: '' | ||
withCredentials([sshUserPrivateKey(credentialsId: 'jenkins-ssh-key', keyFileVariable: 'SSH_KEY_FILE', passphraseVariable: '', usernameVariable: '')]) { | ||
withCredentials([string(credentialsId: 'GITHUB_TOKEN', variable: 'GITHUB_TOKEN')]) { | ||
checkout([$class: 'GitSCM', branches: [[name: CHECKOUT_BRANCH]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[name: 'origin', refspec: CHECKOUT_REF, credentialsId: 'jenkins-ssh-key', url: GITHUB_URL]]]) | ||
sh ".jenkins/merge_pr.sh $PR_NUMBER $COMMIT_HASH $BASE_HASH $SSH_KEY_FILE \ | ||
&& wget -nv https://storage.googleapis.com/ppaquette-diplomacy/files/Miniconda3-py37.sh -O miniconda.sh \ | ||
&& chmod +x ./miniconda.sh \ | ||
&& rm -Rf $HOME/miniconda \ | ||
&& ./miniconda.sh -b -p $HOME/miniconda \ | ||
&& export PATH=$HOME/miniconda/bin:$PATH \ | ||
&& conda create -y -q -n py37 python=3.7 \ | ||
&& export PATH=$HOME/miniconda/envs/py37/bin:$PATH \ | ||
&& mkdir -p $HOME/.cache/diplomacy \ | ||
&& wget -nv https://storage.googleapis.com/ppaquette-diplomacy/cache-jenkins/convoy_paths_cache.pkl -O $HOME/.cache/diplomacy/convoy_paths_cache.pkl \ | ||
&& .jenkins/get_cache.sh $PR_NUMBER $STRIPPED_BRANCH \ | ||
&& .jenkins/expand_vars.sh \ | ||
&& pip install -r requirements.txt \ | ||
&& pip install -r requirements_dev.txt \ | ||
&& git checkout -- requirements.txt requirements_dev.txt \ | ||
&& touch run_install_nvm.sh \ | ||
&& chmod +x run_install_nvm.sh \ | ||
&& ./run_install_nvm.sh \ | ||
&& echo '--------------------------------------------------' \ | ||
&& pip --version \ | ||
&& python --version \ | ||
&& which python \ | ||
&& git rev-parse HEAD \ | ||
&& git log -n 1 \ | ||
&& ./run_tests.sh \ | ||
&& .jenkins/set_cache.sh $PR_NUMBER $STRIPPED_BRANCH" | ||
} | ||
} | ||
githubNotify account: USERNAME, context: CONTEXT + "/python3.7", credentialsId: 'ppaquette-jenkins-api-as-password', description: SUCCESS_MSG, gitApiUrl: '', repo: REPOSITORY, sha: COMMIT_HASH, status: 'SUCCESS', targetUrl: '' | ||
} | ||
} catch(err) { | ||
echo "Error encountered in parallel (Python 3.7): ${err}" | ||
exit_status = 1 | ||
currentBuild.result = "FAILURE" | ||
githubNotify account: USERNAME, context: CONTEXT + "/python3.7", credentialsId: 'ppaquette-jenkins-api-as-password', description: FAILURE_MSG, gitApiUrl: '', repo: REPOSITORY, sha: COMMIT_HASH, status: 'FAILURE', targetUrl: '' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
// Only running 3.6 for Pull Requests (and for "jenkins" branch) | ||
|
||
if (BUILD_TYPE == 'pr' || (BUILD_TYPE == 'push' && COMMIT_BRANCH == 'jenkins')) { | ||
parallel_test['python_3.6'] = { | ||
node('ubuntu-1604-large') { | ||
stage('Python 3.6') { | ||
try { | ||
timeout(time: 20, activity: true, unit: 'MINUTES') { | ||
githubNotify account: USERNAME, context: CONTEXT + "/python3.6", credentialsId: 'ppaquette-jenkins-api-as-password', description: PENDING_MSG, gitApiUrl: '', repo: REPOSITORY, sha: COMMIT_HASH, status: 'PENDING', targetUrl: '' | ||
withCredentials([sshUserPrivateKey(credentialsId: 'jenkins-ssh-key', keyFileVariable: 'SSH_KEY_FILE', passphraseVariable: '', usernameVariable: '')]) { | ||
withCredentials([string(credentialsId: 'GITHUB_TOKEN', variable: 'GITHUB_TOKEN')]) { | ||
checkout([$class: 'GitSCM', branches: [[name: CHECKOUT_BRANCH]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[name: 'origin', refspec: CHECKOUT_REF, credentialsId: 'jenkins-ssh-key', url: GITHUB_URL]]]) | ||
sh ".jenkins/merge_pr.sh $PR_NUMBER $COMMIT_HASH $BASE_HASH $SSH_KEY_FILE \ | ||
&& wget -nv https://storage.googleapis.com/ppaquette-diplomacy/files/Miniconda3-py37.sh -O miniconda.sh \ | ||
&& chmod +x ./miniconda.sh \ | ||
&& rm -Rf $HOME/miniconda \ | ||
&& ./miniconda.sh -b -p $HOME/miniconda \ | ||
&& export PATH=$HOME/miniconda/bin:$PATH \ | ||
&& conda create -y -q -n py36 python=3.6 \ | ||
&& export PATH=$HOME/miniconda/envs/py36/bin:$PATH \ | ||
&& mkdir -p $HOME/.cache/diplomacy \ | ||
&& wget -nv https://storage.googleapis.com/ppaquette-diplomacy/cache-jenkins/convoy_paths_cache.pkl -O $HOME/.cache/diplomacy/convoy_paths_cache.pkl \ | ||
&& .jenkins/get_cache.sh $PR_NUMBER $STRIPPED_BRANCH \ | ||
&& .jenkins/expand_vars.sh \ | ||
&& pip install -r requirements.txt \ | ||
&& pip install -r requirements_dev.txt \ | ||
&& git checkout -- requirements.txt requirements_dev.txt \ | ||
&& touch run_install_nvm.sh \ | ||
&& chmod +x run_install_nvm.sh \ | ||
&& ./run_install_nvm.sh \ | ||
&& echo '--------------------------------------------------' \ | ||
&& pip --version \ | ||
&& python --version \ | ||
&& which python \ | ||
&& git rev-parse HEAD \ | ||
&& git log -n 1 \ | ||
&& ./run_tests.sh \ | ||
&& .jenkins/set_cache.sh $PR_NUMBER $STRIPPED_BRANCH" | ||
} | ||
} | ||
githubNotify account: USERNAME, context: CONTEXT + "/python3.6", credentialsId: 'ppaquette-jenkins-api-as-password', description: SUCCESS_MSG, gitApiUrl: '', repo: REPOSITORY, sha: COMMIT_HASH, status: 'SUCCESS', targetUrl: '' | ||
} | ||
} catch(err) { | ||
echo "Error encountered in parallel (Python 3.6): ${err}" | ||
exit_status = 1 | ||
currentBuild.result = "FAILURE" | ||
githubNotify account: USERNAME, context: CONTEXT + "/python3.6", credentialsId: 'ppaquette-jenkins-api-as-password', description: FAILURE_MSG, gitApiUrl: '', repo: REPOSITORY, sha: COMMIT_HASH, status: 'FAILURE', targetUrl: '' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
parallel parallel_test | ||
|
||
// ------------------------------- | ||
// 3. Deploying | ||
if (exit_status == 0 \ | ||
&& BUILD_TYPE == 'push' \ | ||
&& (COMMIT_BRANCH == 'master' || COMMIT_BRANCH == 'dev' || COMMIT_BRANCH == 'build' || COMMIT_BRANCH == 'build_cpu' || COMMIT_BRANCH == 'web' || COMMIT_BRANCH == 'webdip')) { | ||
|
||
node('ubuntu-1604-deploy') { | ||
stage('Deploy') { | ||
try { | ||
timeout(time: 30, activity: true, unit: 'MINUTES') { | ||
githubNotify account: USERNAME, context: ROOT_CONTEXT + "/deploy", credentialsId: 'ppaquette-jenkins-api-as-password', description: PENDING_MSG, gitApiUrl: '', repo: REPOSITORY, sha: COMMIT_HASH, status: 'PENDING', targetUrl: '' | ||
withCredentials([string(credentialsId: 'GITHUB_TOKEN', variable: 'GITHUB_TOKEN')]) { | ||
checkout([$class: 'GitSCM', branches: [[name: CHECKOUT_BRANCH]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[name: 'origin', refspec: CHECKOUT_REF, credentialsId: 'jenkins-ssh-key', url: GITHUB_URL]]]) | ||
sh "wget -nv https://storage.googleapis.com/ppaquette-diplomacy/files/Miniconda3-py37.sh -O miniconda.sh \ | ||
&& chmod +x ./miniconda.sh \ | ||
&& rm -Rf $HOME/miniconda \ | ||
&& ./miniconda.sh -b -p $HOME/miniconda \ | ||
&& export PATH=$HOME/miniconda/bin:$PATH \ | ||
&& conda create -y -q -n py37 python=3.7 \ | ||
&& export PATH=$HOME/miniconda/envs/py37/bin:$PATH \ | ||
&& mkdir -p $HOME/.cache/diplomacy \ | ||
&& wget -nv https://storage.googleapis.com/ppaquette-diplomacy/cache-jenkins/convoy_paths_cache.pkl -O $HOME/.cache/diplomacy/convoy_paths_cache.pkl \ | ||
&& .jenkins/get_cache.sh $PR_NUMBER $STRIPPED_BRANCH \ | ||
&& .jenkins/expand_vars.sh \ | ||
&& pip install -r requirements.txt \ | ||
&& pip install -r requirements_dev.txt \ | ||
&& git checkout -- requirements.txt requirements_dev.txt \ | ||
&& touch run_install_nvm.sh \ | ||
&& chmod +x run_install_nvm.sh \ | ||
&& ./run_install_nvm.sh \ | ||
&& echo '--------------------------------------------------' \ | ||
&& pip --version \ | ||
&& python --version \ | ||
&& which python \ | ||
&& git rev-parse HEAD \ | ||
&& git log -n 1 \ | ||
&& ./run_deploy.sh $USERNAME/$REPOSITORY $PR_NUMBER $COMMIT_BRANCH $COMMIT_HASH $GITHUB_TOKEN" | ||
} | ||
githubNotify account: USERNAME, context: ROOT_CONTEXT + "/deploy", credentialsId: 'ppaquette-jenkins-api-as-password', description: SUCCESS_MSG, gitApiUrl: '', repo: REPOSITORY, sha: COMMIT_HASH, status: 'SUCCESS', targetUrl: '' | ||
} | ||
} catch(err) { | ||
echo "Error encountered in deployment: ${err}" | ||
exit_status = 1 | ||
currentBuild.result = "FAILURE" | ||
githubNotify account: USERNAME, context: ROOT_CONTEXT + "/deploy", credentialsId: 'ppaquette-jenkins-api-as-password', description: FAILURE_MSG, gitApiUrl: '', repo: REPOSITORY, sha: COMMIT_HASH, status: 'FAILURE', targetUrl: '' | ||
} | ||
} | ||
} | ||
} | ||
|
||
// ------------------------------- | ||
// 4. Updating git status | ||
if (exit_status == 1) { | ||
currentBuild.result = "FAILURE" | ||
githubNotify account: USERNAME, context: ROOT_CONTEXT, credentialsId: 'ppaquette-jenkins-api-as-password', description: FAILURE_MSG, gitApiUrl: '', repo: REPOSITORY, sha: COMMIT_HASH, status: 'FAILURE', targetUrl: '' | ||
} else { | ||
currentBuild.result = "SUCCESS" | ||
githubNotify account: USERNAME, context: ROOT_CONTEXT, credentialsId: 'ppaquette-jenkins-api-as-password', description: SUCCESS_MSG, gitApiUrl: '', repo: REPOSITORY, sha: COMMIT_HASH, status: 'SUCCESS', targetUrl: '' | ||
} |
Oops, something went wrong.