Skip to content

Commit

Permalink
Merge pull request #1577 from dbast/main
Browse files Browse the repository at this point in the history
Burn in flow_run_id, remote_url, sha into package meta data
  • Loading branch information
isuruf authored Nov 6, 2023
2 parents 5d113a9 + 593ffa1 commit df653f1
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 4 deletions.
5 changes: 4 additions & 1 deletion conda_smithy/templates/appveyor.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ install:
build: off

test_script:
- cmd: conda.exe build {{ recipe_dir }} -m .ci_support\%CONFIG%.yaml
- set "flow_run_id=appveyor_%APPVEYOR_BUILD_ID%"
- set "remote_url=https://github.com/%APPVEYOR_REPO_NAME%"
- set "sha=%APPVEYOR_REPO_COMMIT%"
- cmd: conda.exe build {{ recipe_dir }} -m .ci_support\%CONFIG%.yaml --extra-meta flow_run_id=%flow_run_id% remote_url=%remote_url% sha=%sha%
{%- if conda_forge_output_validation %}
- set "FEEDSTOCK_NAME=%APPVEYOR_REPO_NAME:*/=%"
- cmd: validate_recipe_outputs "%FEEDSTOCK_NAME%"
Expand Down
3 changes: 3 additions & 0 deletions conda_smithy/templates/azure-pipelines-linux.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ jobs:
- script: |
export CI=azure
export flow_run_id=azure_$(Build.BuildNumber).$(System.JobAttempt)
export remote_url=$(Build.Repository.Uri)
export sha=$(Build.SourceVersion)
export GIT_BRANCH=$BUILD_SOURCEBRANCHNAME
export FEEDSTOCK_NAME=$(basename ${BUILD_REPOSITORY_NAME})
{%- if upload_on_branch %}
Expand Down
3 changes: 3 additions & 0 deletions conda_smithy/templates/azure-pipelines-osx.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ jobs:
{%- endif %}
- script: |
export CI=azure
export flow_run_id=azure_$(Build.BuildNumber).$(System.JobAttempt)
export remote_url=$(Build.Repository.Uri)
export sha=$(Build.SourceVersion)
export OSX_FORCE_SDK_DOWNLOAD="1"
export GIT_BRANCH=$BUILD_SOURCEBRANCHNAME
export FEEDSTOCK_NAME=$(basename ${BUILD_REPOSITORY_NAME})
Expand Down
3 changes: 3 additions & 0 deletions conda_smithy/templates/azure-pipelines-win.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ jobs:
PYTHONUNBUFFERED: 1
CONFIG: $(CONFIG)
CI: azure
flow_run_id: azure_$(Build.BuildNumber).$(System.JobAttempt)
remote_url: $(Build.Repository.Uri)
sha: $(Build.SourceVersion)
UPLOAD_PACKAGES: $(UPLOAD_PACKAGES)
UPLOAD_TEMP: $(UPLOAD_TEMP)
{%- if upload_on_branch %}
Expand Down
9 changes: 8 additions & 1 deletion conda_smithy/templates/build_steps.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ if [[ -f "${FEEDSTOCK_ROOT}/LICENSE.txt" ]]; then
cp "${FEEDSTOCK_ROOT}/LICENSE.txt" "${RECIPE_ROOT}/recipe-scripts-license.txt"
fi

if [[ "${sha:-}" == "" ]]; then
pushd ${FEEDSTOCK_ROOT}
sha=$(git rev-parse HEAD)
popd
fi

if [[ "${BUILD_WITH_CONDA_DEBUG:-0}" == 1 ]]; then
if [[ "x${BUILD_OUTPUT_ID:-}" != "x" ]]; then
EXTRA_CB_OPTIONS="${EXTRA_CB_OPTIONS:-} --output-id ${BUILD_OUTPUT_ID}"
Expand All @@ -96,7 +102,8 @@ if [[ "${BUILD_WITH_CONDA_DEBUG:-0}" == 1 ]]; then
else
{{ BUILD_CMD }} "${RECIPE_ROOT}" -m "${CI_SUPPORT}/${CONFIG}.yaml" \
--suppress-variables ${EXTRA_CB_OPTIONS:-} \
--clobber-file "${CI_SUPPORT}/clobber_${CONFIG}.yaml"
--clobber-file "${CI_SUPPORT}/clobber_${CONFIG}.yaml" \
--extra-meta flow_run_id="${flow_run_id:-}" remote_url="${remote_url:-}" sha="${sha:-}"

{%- if conda_forge_output_validation %}
( startgroup "Validating outputs" ) 2> /dev/null
Expand Down
6 changes: 6 additions & 0 deletions conda_smithy/templates/circle.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ jobs:
{%- if data.platform.startswith('linux') %}
command: |
export CI=circle
export flow_run_id="circle_$CIRCLE_WORKFLOW_ID"
export remote_url="$CIRCLE_REPOSITORY_URL"
export sha="$CIRCLE_SHA1"
export FEEDSTOCK_NAME=$(basename ${CIRCLE_PROJECT_REPONAME})
if [[ "${CIRCLE_PR_NUMBER:-}" == "" ]]; then
export IS_PR_BUILD="False"
Expand All @@ -57,6 +60,9 @@ jobs:
{%- else %}
command: |
export CI=circle
export flow_run_id="circle_$CIRCLE_WORKFLOW_ID"
export remote_url="$CIRCLE_REPOSITORY_URL"
export sha="$CIRCLE_SHA1"
export FEEDSTOCK_NAME=$(basename ${CIRCLE_PROJECT_REPONAME})
if [[ "${CIRCLE_PR_NUMBER:-}" == "" ]]; then
export IS_PR_BUILD="False"
Expand Down
3 changes: 3 additions & 0 deletions conda_smithy/templates/drone.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ steps:
- export RECIPE_ROOT="$FEEDSTOCK_ROOT/{{ recipe_dir }}"
- export CI=drone
- export GIT_BRANCH="$DRONE_BRANCH"
- export flow_run_id="drone_$DRONE_BUILD_NUMBER"
- export remote_url="$DRONE_REPO_LINK"
- export sha="$DRONE_COMMIT_SHA"
- export FEEDSTOCK_NAME=$(basename ${DRONE_REPO_NAME})
{%- if upload_on_branch %}
- export UPLOAD_ON_BRANCH="{{ upload_on_branch }}"
Expand Down
9 changes: 9 additions & 0 deletions conda_smithy/templates/github-actions.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ jobs:
run: |
echo "::group::Configure binfmt_misc"
docker run --rm --privileged multiarch/qemu-user-static:register --reset --credential yes
export flow_run_id="github_$GITHUB_RUN_ID"
export remote_url="https://github.com/$GITHUB_REPOSITORY"
export sha="$GITHUB_SHA"
export FEEDSTOCK_NAME="$(basename $GITHUB_REPOSITORY)"
export GIT_BRANCH="$(basename $GITHUB_REF)"
if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
Expand All @@ -149,6 +152,9 @@ jobs:
{%- endfor %}
shell: bash
run: |
export flow_run_id="github_$GITHUB_RUN_ID"
export remote_url="https://github.com/$GITHUB_REPOSITORY"
export sha="$GITHUB_SHA"
export FEEDSTOCK_NAME="$(basename $GITHUB_REPOSITORY)"
export GIT_BRANCH="$(basename $GITHUB_REF)"
if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
Expand All @@ -175,6 +181,9 @@ jobs:
- name: Build on windows
shell: cmd
run: |
set "flow_run_id=github_%GITHUB_RUN_ID%"
set "remote_url=https://github.com/%GITHUB_REPOSITORY%"
set "sha=%GITHUB_SHA%"
call ".scripts\run_win_build.bat"
env:
PYTHONUNBUFFERED: 1
Expand Down
3 changes: 3 additions & 0 deletions conda_smithy/templates/run_docker_build.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ export IS_PR_BUILD="${IS_PR_BUILD:-False}"
-e CPU_COUNT \
-e BUILD_WITH_CONDA_DEBUG \
-e BUILD_OUTPUT_ID \
-e flow_run_id \
-e remote_url \
-e sha \
{%- for secret in secrets %}
-e {{ secret }} \
{%- endfor %}
Expand Down
7 changes: 6 additions & 1 deletion conda_smithy/templates/run_osx_build.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ else
echo -e "\n\nNot mangling homebrew as we are not running in CI"
fi

if [[ "${sha:-}" == "" ]]; then
sha=$(git rev-parse HEAD)
fi

{% if build_setup -%}
echo -e "\n\nRunning the build setup script."
{{ build_setup }}
Expand Down Expand Up @@ -97,7 +101,8 @@ else
{% endif %}
{{ BUILD_CMD }} ./{{ recipe_dir }} -m ./.ci_support/${CONFIG}.yaml \
--suppress-variables ${EXTRA_CB_OPTIONS:-} \
--clobber-file ./.ci_support/clobber_${CONFIG}.yaml
--clobber-file ./.ci_support/clobber_${CONFIG}.yaml \
--extra-meta flow_run_id="$flow_run_id" remote_url="$remote_url" sha="$sha"


{%- if conda_forge_output_validation %}
Expand Down
4 changes: 4 additions & 0 deletions conda_smithy/templates/run_win_build.bat.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ if NOT [%HOST_PLATFORM%] == [%BUILD_PLATFORM%] (
)
{%- endif %}

if NOT [%flow_run_id%] == [] (
set "EXTRA_CB_OPTIONS=%EXTRA_CB_OPTIONS% --extra-meta flow_run_id=%flow_run_id% remote_url=%remote_url% sha=%sha%"
)

call :end_group

:: Build the recipe
Expand Down
3 changes: 3 additions & 0 deletions conda_smithy/templates/travis.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ matrix:
script:
- export CI=travis
- export GIT_BRANCH="$TRAVIS_BRANCH"
- export flow_run_id="travis_$TRAVIS_JOB_ID"
- export sha="$TRAVIS_COMMIT"
- export remote_url="https://github.com/$TRAVIS_REPO_SLUG"
- export FEEDSTOCK_NAME=$(basename ${TRAVIS_REPO_SLUG})
{%- if upload_on_branch %}
- export UPLOAD_ON_BRANCH="{{ upload_on_branch }}"
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies:
- pytest-cov
# Runtime dependencies, duplicated in conda_smithy.recipe/meta.yaml
- conda >=4.2
- conda-build >=3.18.3
- conda-build >=3.21.8
- conda-package-handling >=1.9.0
- jinja2
- requests
Expand Down
26 changes: 26 additions & 0 deletions news/burn_in_ids.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
**Added:**

* Add ``flow_run_id`` (CI provider specific), ``remote_url`` and ``sha`` as extra-meta data to packages.
Enables tracing back packages to a specific commit in a feedstock and to a specific CI run.
When packages are built using ``build-locally.py`` only ``sha`` will have a non-empty value.
Requires ``conda-build >=3.21.8``. (#1577)

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>

0 comments on commit df653f1

Please sign in to comment.