diff --git a/conda_smithy/feedstock_content/build-locally.py b/conda_smithy/feedstock_content/build-locally.py index 00eeb34b1..f3d4f62fd 100755 --- a/conda_smithy/feedstock_content/build-locally.py +++ b/conda_smithy/feedstock_content/build-locally.py @@ -13,6 +13,7 @@ def setup_environment(ns): os.environ["CONFIG"] = ns.config os.environ["UPLOAD_PACKAGES"] = "False" + os.environ["IS_PR_BUILD"] = "True" if ns.debug: os.environ["BUILD_WITH_CONDA_DEBUG"] = "1" if ns.output_id: diff --git a/conda_smithy/templates/azure-pipelines-linux.yml.tmpl b/conda_smithy/templates/azure-pipelines-linux.yml.tmpl index 08cc3144f..13aebefad 100644 --- a/conda_smithy/templates/azure-pipelines-linux.yml.tmpl +++ b/conda_smithy/templates/azure-pipelines-linux.yml.tmpl @@ -33,6 +33,11 @@ jobs: {%- if docker.run_args is defined %} export CONDA_FORGE_DOCKER_RUN_ARGS="{{ docker.run_args }}" {%- endif %} + if [[ "${BUILD_REASON:-}" == "PullRequest" ]]; then + export IS_PR_BUILD="True" + else + export IS_PR_BUILD="False" + fi .scripts/run_docker_build.sh displayName: Run docker build env: diff --git a/conda_smithy/templates/azure-pipelines-osx.yml.tmpl b/conda_smithy/templates/azure-pipelines-osx.yml.tmpl index 04a92dc56..cf57d1d70 100644 --- a/conda_smithy/templates/azure-pipelines-osx.yml.tmpl +++ b/conda_smithy/templates/azure-pipelines-osx.yml.tmpl @@ -19,6 +19,11 @@ jobs: {%- if upload_on_branch %} export UPLOAD_ON_BRANCH="{{ upload_on_branch }}" {%- endif %} + if [[ "${BUILD_REASON:-}" == "PullRequest" ]]; then + export IS_PR_BUILD="True" + else + export IS_PR_BUILD="False" + fi ./.scripts/run_osx_build.sh displayName: Run OSX build env: diff --git a/conda_smithy/templates/azure-pipelines-win.yml.tmpl b/conda_smithy/templates/azure-pipelines-win.yml.tmpl index c0f87103d..417430c33 100644 --- a/conda_smithy/templates/azure-pipelines-win.yml.tmpl +++ b/conda_smithy/templates/azure-pipelines-win.yml.tmpl @@ -137,4 +137,4 @@ jobs: {%- for secret in secrets %} {{ secret }}: $({{ secret }}) {%- endfor %} - condition: and(succeeded(), not(eq(variables['UPLOAD_PACKAGES'], 'False'))) + condition: and(succeeded(), not(eq(variables['UPLOAD_PACKAGES'], 'False')), not(eq(variables['Build.Reason'], 'PullRequest'))) diff --git a/conda_smithy/templates/build_steps.sh.tmpl b/conda_smithy/templates/build_steps.sh.tmpl index 20df267d3..ed1ad0c46 100644 --- a/conda_smithy/templates/build_steps.sh.tmpl +++ b/conda_smithy/templates/build_steps.sh.tmpl @@ -86,7 +86,7 @@ else ( startgroup "Uploading packages" ) 2> /dev/null - if [[ "${UPLOAD_PACKAGES}" != "False" ]]; then + if [[ "${UPLOAD_PACKAGES}" != "False" ]] && [[ "${IS_PR_BUILD}" == "False" ]]; then upload_package {% if conda_forge_output_validation %}--validate --feedstock-name="${FEEDSTOCK_NAME}" {% endif %}{% if private_upload %} --private{% endif %} "${FEEDSTOCK_ROOT}" "${RECIPE_ROOT}" "${CONFIG_FILE}" fi diff --git a/conda_smithy/templates/circle.yml.tmpl b/conda_smithy/templates/circle.yml.tmpl index b7f239542..82746bf91 100644 --- a/conda_smithy/templates/circle.yml.tmpl +++ b/conda_smithy/templates/circle.yml.tmpl @@ -22,7 +22,7 @@ jobs: machine: true {%- else %} macos: - xcode: "9.0" + xcode: "13.0.0" {%- endif %} environment: - CONFIG: "{{ data.config_name }}" @@ -43,11 +43,21 @@ jobs: command: | export CI=circle export FEEDSTOCK_NAME=$(basename ${CIRCLE_PROJECT_REPONAME}) + if [[ "${CIRCLE_PR_NUMBER:-}" == "" ]]; then + export IS_PR_BUILD="False" + else + export IS_PR_BUILD="True" + fi ./.scripts/run_docker_build.sh {%- else %} command: | export CI=circle export FEEDSTOCK_NAME=$(basename ${CIRCLE_PROJECT_REPONAME}) + if [[ "${CIRCLE_PR_NUMBER:-}" == "" ]]; then + export IS_PR_BUILD="False" + else + export IS_PR_BUILD="True" + fi ./.scripts/run_osx_build.sh {%- endif %} {%- if idle_timeout_minutes %} diff --git a/conda_smithy/templates/drone.yml.tmpl b/conda_smithy/templates/drone.yml.tmpl index b96da1973..b460ffc12 100644 --- a/conda_smithy/templates/drone.yml.tmpl +++ b/conda_smithy/templates/drone.yml.tmpl @@ -37,6 +37,7 @@ steps: {%- if upload_on_branch %} - export UPLOAD_ON_BRANCH="{{ upload_on_branch }}" {%- endif %} + - export IS_PR_BUILD=$(if [[ "$${DRONE_PULL_REQUEST:-}" == "" ]]; then echo "False"; else echo "True"; fi) - sed -i '$ichown -R conda:conda "$FEEDSTOCK_ROOT"' /opt/docker/bin/entrypoint - /opt/docker/bin/entrypoint $FEEDSTOCK_ROOT/.scripts/build_steps.sh - echo "Done building" diff --git a/conda_smithy/templates/github-actions.tmpl b/conda_smithy/templates/github-actions.tmpl index 3022fd1a1..e3bf18461 100644 --- a/conda_smithy/templates/github-actions.tmpl +++ b/conda_smithy/templates/github-actions.tmpl @@ -94,6 +94,11 @@ jobs: docker run --rm --privileged multiarch/qemu-user-static:register --reset --credential yes export FEEDSTOCK_NAME="$(basename $GITHUB_REPOSITORY)" export GIT_BRANCH="$(basename $GITHUB_REF)" + if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then + export IS_PR_BUILD="True" + else + export IS_PR_BUILD="False" + fi echo "::endgroup::" ./.scripts/run_docker_build.sh @@ -113,6 +118,11 @@ jobs: run: | export FEEDSTOCK_NAME="$(basename $GITHUB_REPOSITORY)" export GIT_BRANCH="$(basename $GITHUB_REF)" + if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then + export IS_PR_BUILD="True" + else + export IS_PR_BUILD="False" + fi ./.scripts/run_osx_build.sh {%- for choco_pkg in choco %} @@ -155,12 +165,19 @@ jobs: {%- endif %} set "FEEDSTOCK_NAME=%GITHUB_REPOSITORY:*/=%" set "GIT_BRANCH=%GITHUB_REF:refs/heads/=%" + if /i "%GITHUB_EVENT_NAME%" == "pull_request" ( + set "IS_PR_BUILD=True" + ) else ( + set "IS_PR_BUILD=False" + ) {%- if conda_forge_output_validation %} validate_recipe_outputs "%FEEDSTOCK_NAME%" if errorlevel 1 exit 1 {%- endif %} if /i "%UPLOAD_PACKAGES%" == "true" ( - upload_package {% if conda_forge_output_validation %}--validate --feedstock-name="%FEEDSTOCK_NAME%"{% endif %}{% if private_upload %} --private{% endif %} .\ ".\{{ recipe_dir }}" .ci_support\%CONFIG%.yaml + if /i "%IS_PR_BUILD%" == "false" ( + upload_package {% if conda_forge_output_validation %}--validate --feedstock-name="%FEEDSTOCK_NAME%"{% endif %}{% if private_upload %} --private{% endif %} .\ ".\{{ recipe_dir }}" .ci_support\%CONFIG%.yaml + ) ) env: PYTHONUNBUFFERED: 1 diff --git a/conda_smithy/templates/run_docker_build.sh.tmpl b/conda_smithy/templates/run_docker_build.sh.tmpl index f861eb56a..6d12ead8d 100644 --- a/conda_smithy/templates/run_docker_build.sh.tmpl +++ b/conda_smithy/templates/run_docker_build.sh.tmpl @@ -75,12 +75,14 @@ fi ( startgroup "Start Docker" ) 2> /dev/null export UPLOAD_PACKAGES="${UPLOAD_PACKAGES:-True}" +export IS_PR_BUILD="${IS_PR_BUILD:-False}" {{ docker.executable }} run ${DOCKER_RUN_ARGS} \ -v "${RECIPE_ROOT}":/home/conda/recipe_root:rw,z,delegated \ -v "${FEEDSTOCK_ROOT}":/home/conda/feedstock_root:rw,z,delegated \ -e CONFIG \ -e HOST_USER_ID \ -e UPLOAD_PACKAGES \ + -e IS_PR_BUILD \ -e GIT_BRANCH \ -e UPLOAD_ON_BRANCH \ -e CI \ diff --git a/conda_smithy/templates/run_osx_build.sh.tmpl b/conda_smithy/templates/run_osx_build.sh.tmpl index af4527767..dfe4ae369 100644 --- a/conda_smithy/templates/run_osx_build.sh.tmpl +++ b/conda_smithy/templates/run_osx_build.sh.tmpl @@ -81,7 +81,7 @@ exit 1 {%- else %} ( startgroup "Uploading packages" ) 2> /dev/null -if [[ "${UPLOAD_PACKAGES}" != "False" ]]; then +if [[ "${UPLOAD_PACKAGES}" != "False" ]] && [[ "${IS_PR_BUILD}" == "False" ]]; then upload_package {% if conda_forge_output_validation %}--validate --feedstock-name="${FEEDSTOCK_NAME}"{% endif %}{% if private_upload %} --private{% endif %} ./ ./{{ recipe_dir }} ./.ci_support/${CONFIG}.yaml fi diff --git a/conda_smithy/templates/travis.yml.tmpl b/conda_smithy/templates/travis.yml.tmpl index 1b982b1ca..c24943f97 100644 --- a/conda_smithy/templates/travis.yml.tmpl +++ b/conda_smithy/templates/travis.yml.tmpl @@ -55,9 +55,10 @@ script: {%- if upload_on_branch %} - export UPLOAD_ON_BRANCH="{{ upload_on_branch }}" {%- endif %} + - if [[ "${TRAVIS_PULL_REQUEST:-}" == "false" ]]; then export IS_PR_BUILD="False"; else export IS_PR_BUILD="True"; fi {% if 'osx' in platformset %} - if [[ ${PLATFORM} =~ .*osx.* ]]; then {%- if idle_timeout_minutes %} travis_wait {{ idle_timeout_minutes }}{% endif %} ./.scripts/run_osx_build.sh; fi {%- endif %} {% if 'linux' in platformset %} - if [[ ${PLATFORM} =~ .*linux.* ]]; then {%- if idle_timeout_minutes %} travis_wait {{ idle_timeout_minutes }}{% endif %} ./.scripts/run_docker_build.sh; fi -{%- endif %} \ No newline at end of file +{%- endif %} diff --git a/news/is_pr_build.rst b/news/is_pr_build.rst new file mode 100644 index 000000000..fb6a1e72f --- /dev/null +++ b/news/is_pr_build.rst @@ -0,0 +1,23 @@ +**Added:** + +* Added explicit check to not upload packages on PR builds. + +**Changed:** + +* Updated CircleCI xcode version to 13.0.0 to prevent failures. + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +*