From e97247900c74c320d28989991dacdf98a5b8dd3e Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Sun, 9 Aug 2020 10:41:12 -0500 Subject: [PATCH] Error if recipe is in wrong directory (#12339) * Error if recipe is in wrong directory * Add a test recipe * Debug script * debug 2 * FIx checking meta.yaml path * Use abspath * Remove installing vs2008 * Add recipe in wrong dir * Remove test recipes --- .appveyor.yml.notused | 2 +- .azure-pipelines/azure-pipelines-osx.yml | 2 +- .azure-pipelines/azure-pipelines-win.yml | 40 ++---------------------- .ci_support/build_all.py | 15 +++++++-- .circleci/build_steps.sh | 15 +++++---- .travis_scripts/build_all | 2 +- 6 files changed, 25 insertions(+), 51 deletions(-) diff --git a/.appveyor.yml.notused b/.appveyor.yml.notused index 591db49767d2c..825c8d5d5cb52 100644 --- a/.appveyor.yml.notused +++ b/.appveyor.yml.notused @@ -45,7 +45,7 @@ install: build: off test_script: - - python .ci_support\build_all.py recipes --arch %PLATFORM% + - python .ci_support\build_all.py --arch %PLATFORM% # copy any newly created conda packages into the conda_packages dir - cmd: mkdir conda_packages diff --git a/.azure-pipelines/azure-pipelines-osx.yml b/.azure-pipelines/azure-pipelines-osx.yml index 3c3ff6cb7a82f..7879f866622e4 100755 --- a/.azure-pipelines/azure-pipelines-osx.yml +++ b/.azure-pipelines/azure-pipelines-osx.yml @@ -65,7 +65,7 @@ jobs: echo "" # We just want to build all of the recipes. - python .ci_support/build_all.py ./recipes + python .ci_support/build_all.py - publish: /usr/local/miniconda/conda-bld/osx-64/ artifact: conda_pkgs_osx diff --git a/.azure-pipelines/azure-pipelines-win.yml b/.azure-pipelines/azure-pipelines-win.yml index fa4569ddba4af..604ca86322842 100755 --- a/.azure-pipelines/azure-pipelines-win.yml +++ b/.azure-pipelines/azure-pipelines-win.yml @@ -10,38 +10,6 @@ jobs: CF_MAX_PY_VER: 37 timeoutInMinutes: 360 steps: - # TODO: Fast finish on azure pipelines? - - script: | - echo "Fast Finish" - - - script: | - choco install vcpython27 -fdv -y --debug - displayName: Install vcpython27.msi (if needed) - - - powershell: | - Set-PSDebug -Trace 1 - - $batchcontent = @" - ECHO ON - SET vcpython=C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0 - - DIR "%vcpython%" - - CALL "%vcpython%\vcvarsall.bat" %* - "@ - - $batchDir = "C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0\VC" - $batchPath = "$batchDir" + "\vcvarsall.bat" - New-Item -Path $batchPath -ItemType "file" -Force - - Set-Content -Value $batchcontent -Path $batchPath - - Get-ChildItem -Path $batchDir - - Get-ChildItem -Path ($batchDir + '\..') - - displayName: Patch vs2008 (if needed) - - task: CondaEnvironment@1 inputs: packageSpecs: 'python=3.6 conda-build>=3.18 conda>4.7.12 conda-forge::conda-forge-ci-setup=2 networkx=2.3 conda-forge-pinning' # Optional @@ -85,11 +53,9 @@ jobs: # Special cased version setting some more things! - script: | git fetch --force origin master:master - python .ci_support\build_all.py recipes --arch 64 + python .ci_support\build_all.py --arch 64 + + displayName: Build recipe - displayName: Build recipe (maybe vs2008) - env: { - VS90COMNTOOLS: "C:\\Program Files (x86)\\Common Files\\Microsoft\\Visual C++ for Python\\9.0\\VC\\bin", - } - publish: C:\\Miniconda\\conda-bld\\win-64\\ artifact: conda_pkgs_win diff --git a/.ci_support/build_all.py b/.ci_support/build_all.py index abbd4638c43d8..8af4418f3c005 100644 --- a/.ci_support/build_all.py +++ b/.ci_support/build_all.py @@ -123,11 +123,20 @@ def build_folders(recipes_dir, folders, arch, channel_urls): conda_build.api.build([recipe], config=get_config(arch, channel_urls)) +def check_recipes_in_correct_dir(root_dir, correct_dir): + from pathlib import Path + for path in Path(root_dir).rglob('meta.yaml'): + path = path.absolute().relative_to(root_dir) + if path.parts[0] != correct_dir: + raise RuntimeError(f"recipe {path.parts} in wrong directory") + if len(path.parts) != 3: + raise RuntimeError(f"recipe {path.parts} in wrong directory") + if __name__ == "__main__": parser = argparse.ArgumentParser() - parser.add_argument('recipes_dir', default=os.getcwd(), - help='Directory where the recipes are') parser.add_argument('--arch', default='64', help='target architecture (64 or 32)') args = parser.parse_args() - build_all(args.recipes_dir, args.arch) + root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + check_recipes_in_correct_dir(root_dir, "recipes") + build_all(os.path.join(root_dir, "recipes"), args.arch) diff --git a/.circleci/build_steps.sh b/.circleci/build_steps.sh index 032ca42b5ec76..4204f2c96363d 100755 --- a/.circleci/build_steps.sh +++ b/.circleci/build_steps.sh @@ -22,18 +22,17 @@ show_channel_urls: true CONDARC # Copy the host recipes folder so we don't ever muck with it -cp -r /home/conda/staged-recipes/recipes ~/conda-recipes -cp -r /home/conda/staged-recipes/.ci_support ~/.ci_support +cp -r /home/conda/staged-recipes ~/staged-recipes-copy # Find the recipes from master in this PR and remove them. echo "Pending recipes." -ls -la ~/conda-recipes +ls -la ~/staged-recipes-copy/recipes echo "Finding recipes merged in master and removing them from the build." pushd /home/conda/staged-recipes/recipes > /dev/null if [ "${AZURE}" == "True" ]; then git fetch --force origin master:master fi -git ls-tree --name-only master -- . | xargs -I {} sh -c "rm -rf ~/conda-recipes/{} && echo Removing recipe: {}" +git ls-tree --name-only master -- . | xargs -I {} sh -c "rm -rf ~/staged-recipes-copy/recipes/{} && echo Removing recipe: {}" popd > /dev/null # Unused, but needed by conda-build currently... :( @@ -44,15 +43,15 @@ conda index /home/conda/staged-recipes/build_artifacts conda install --yes --quiet "conda>4.7.12" conda-forge-ci-setup=3.* conda-forge-pinning networkx=2.3 "conda-build>=3.16" export FEEDSTOCK_ROOT="${FEEDSTOCK_ROOT:-/home/conda/staged-recipes}" -export CI_SUPPORT="/home/conda/.ci_support" -setup_conda_rc "${FEEDSTOCK_ROOT}" "/home/conda/conda-recipes" "${CI_SUPPORT}/${CONFIG}.yaml" +export CI_SUPPORT="/home/conda/staged-recipes-copy/.ci_support" +setup_conda_rc "${FEEDSTOCK_ROOT}" "/home/conda/staged-recipes-copy/recipes" "${CI_SUPPORT}/${CONFIG}.yaml" source run_conda_forge_build_setup # yum installs anything from a "yum_requirements.txt" file that isn't a blank line or comment. -find ~/conda-recipes -mindepth 2 -maxdepth 2 -type f -name "yum_requirements.txt" \ +find ~/staged-recipes-copy/recipes -mindepth 2 -maxdepth 2 -type f -name "yum_requirements.txt" \ | xargs -n1 cat | { grep -v -e "^#" -e "^$" || test $? == 1; } | \ xargs -r /usr/bin/sudo -n yum install -y -python ~/.ci_support/build_all.py ~/conda-recipes +python ${CI_SUPPORT}/build_all.py touch "/home/conda/staged-recipes/build_artifacts/conda-forge-build-done" diff --git a/.travis_scripts/build_all b/.travis_scripts/build_all index 44202749424b8..f8eabca39a4c2 100755 --- a/.travis_scripts/build_all +++ b/.travis_scripts/build_all @@ -38,4 +38,4 @@ popd > /dev/null echo "" # We just want to build all of the recipes. -python .ci_support/build_all.py ./recipes +python .ci_support/build_all.py