diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1970be7b..fec0c5e5 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -8,9 +8,11 @@ schedules: always: true variables: + BUILD_COMMIT: "0.23.0rc1" MANYLINUX_URL: "https://pypi.python.org/simple" jobs: + - template: azure/posix-sdist.yml - template: azure/windows.yml parameters: name: windows diff --git a/azure/posix-sdist.yml b/azure/posix-sdist.yml new file mode 100644 index 00000000..9300fddd --- /dev/null +++ b/azure/posix-sdist.yml @@ -0,0 +1,130 @@ +jobs: + - job: Linux_Source_Dist + pool: + vmImage: ubuntu-16.04 + variables: + NIGHTLY_BUILD_COMMIT: "master" + NIGHTLY_BUILD: "true" + JUNITXML: "test-data.xml" + TEST_DIR: "tmp_for_test" + TEST_VENV: "test_env" + MB_PYTHON_VERSION: "3.8" + steps: + - checkout: self + submodules: true + - task: UsePythonVersion@0 + inputs: + versionSpec: $(MB_PYTHON_VERSION) + displayName: Set python version + - bash: | + set -e + SKIP_BUILD="false" + if [ "$BUILD_REASON" == "Schedule" ]; then + BUILD_COMMIT=$NIGHTLY_BUILD_COMMIT + if [ "$NIGHTLY_BUILD" != "true" ]; then + SKIP_BUILD="true" + fi + fi + + echo "Building scikit-learn@$BUILD_COMMIT" + echo "##vso[task.setvariable variable=BUILD_COMMIT]$BUILD_COMMIT" + echo "##vso[task.setvariable variable=SKIP_BUILD]$SKIP_BUILD" + displayName: Define build env variables + + - bash: | + set -e + + python -m venv build_env + source build_env/bin/activate + + # Need because setup.py enforces these to be installed + python -m pip install numpy scipy Cython + + cd scikit-learn + git checkout $BUILD_COMMIT + python setup.py sdist + displayName: Create build venv with build dependices and build source dist + + - bash: | + set -e + + source build_env/bin/activate + python -m pip install twine + + twine check scikit-learn/dist/* + displayName: Twine check + - bash: | + set -e + + python -m venv $TEST_VENV + source $TEST_VENV/bin/activate + python --version + python -m pip install -U pip + + # pyproject.toml will be released with >=0.23 + if [[ "$BUILD_COMMIT" =~ ^0.22* ]]; then + python -m pip install Cython + fi + + # Uses pep 517 + pip install scikit-learn/dist/*.tar.gz + displayName: Create test venv and install using source dist + + - bash: | + set -e + source $TEST_VENV/bin/activate + + mkdir $TEST_DIR + cd $TEST_DIR + + python -m pip install pytest + pytest -l --junitxml=$JUNITXML --pyargs sklearn + displayName: Runs tests + + - task: PublishTestResults@2 + inputs: + testResultsFiles: "$(TEST_DIR)/$(JUNITXML)" + testRunTitle: ${{ format('{0}-$(Agent.JobName)', 'Linux_Source_Dist') }} + displayName: "Publish Test Results" + condition: eq(variables['SKIP_BUILD'], 'false') + + - bash: | + set -e + if [ "$BUILD_REASON" == "Schedule" ]; then + ANACONDA_ORG="scipy-wheels-nightly" + TOKEN="$SCIKIT_LEARN_NIGHTLY_UPLOAD_TOKEN" + else + ANACONDA_ORG="scikit-learn-wheels-staging" + TOKEN="$SCIKIT_LEARN_STAGING_UPLOAD_TOKEN" + fi + if [ "$TOKEN" == "" ]; then + echo "##[warning] Could not find anaconda.org upload token in secret variables" + fi + echo "##vso[task.setvariable variable=TOKEN]$TOKEN" + echo "##vso[task.setvariable variable=ANACONDA_ORG]$ANACONDA_ORG" + displayName: Retrieve secret upload token + condition: and(succeeded(), eq(variables['SKIP_BUILD'], 'false'), ne(variables['Build.Reason'], 'PullRequest'), variables['SCIKIT_LEARN_NIGHTLY_UPLOAD_TOKEN'], variables['SCIKIT_LEARN_STAGING_UPLOAD_TOKEN']) + env: + # Secret variables need to mapped to env variables explicitly: + SCIKIT_LEARN_NIGHTLY_UPLOAD_TOKEN: $(SCIKIT_LEARN_NIGHTLY_UPLOAD_TOKEN) + SCIKIT_LEARN_STAGING_UPLOAD_TOKEN: $(SCIKIT_LEARN_STAGING_UPLOAD_TOKEN) + + - bash: | + echo "##vso[task.prependpath]$CONDA/bin" + sudo chown -R $USER $CONDA + displayName: Add conda to PATH + condition: and(succeeded(), eq(variables['SKIP_BUILD'], 'false'), ne(variables['Build.Reason'], 'PullRequest'), variables['TOKEN']) + + - bash: conda install -q -y anaconda-client + displayName: Install anaconda-client + condition: and(succeeded(), eq(variables['SKIP_BUILD'], 'false'), ne(variables['Build.Reason'], 'PullRequest'), variables['TOKEN']) + + - bash: | + set -e + # The --force option forces a replacement if the remote file already + # exists. + ls scikit-learn/dist/*.tar.gz + anaconda -t $TOKEN upload --force -u $ANACONDA_ORG scikit-learn/dist/*.tar.gz + echo "PyPI-style index: https://pypi.anaconda.org/$ANACONDA_ORG/simple" + displayName: Upload to anaconda.org (only if secret token is retrieved) + condition: variables['TOKEN'] diff --git a/azure/posix.yml b/azure/posix.yml index 127ee532..89e5c14f 100644 --- a/azure/posix.yml +++ b/azure/posix.yml @@ -9,7 +9,6 @@ jobs: vmImage: ${{ parameters.vmImage }} variables: REPO_DIR: "scikit-learn" - BUILD_COMMIT: "0.23.0rc1" PLAT: "x86_64" NP_BUILD_DEP: "numpy==1.13.3" CYTHON_BUILD_DEP: "cython==0.29.14" diff --git a/azure/windows.yml b/azure/windows.yml index f267b1ef..78d8846e 100644 --- a/azure/windows.yml +++ b/azure/windows.yml @@ -8,7 +8,6 @@ jobs: pool: vmImage: ${{ parameters.vmImage }} variables: - BUILD_COMMIT: "0.23.0rc1" SKLEARN_SKIP_NETWORK_TESTS: "1" NP_BUILD_DEP: "1.13.3" CYTHON_BUILD_DEP: "0.29.14"