Skip to content

Commit

Permalink
bring logging utils
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimergp committed Sep 7, 2023
1 parent 3c28636 commit a4d95cf
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 30 deletions.
33 changes: 23 additions & 10 deletions .scripts/build_steps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@
# benefit from the improvement.

set -xeuo pipefail

export FEEDSTOCK_ROOT="${FEEDSTOCK_ROOT:-/home/conda/staged-recipes}"
source "${FEEDSTOCK_ROOT}/.scripts/logging_utils.sh"

# This closes the matching `startgroup` on `run_docker_build.sh`
( endgroup "Start Docker" ) 2> /dev/null

( startgroup "Configuring conda" ) 2> /dev/null

export PYTHONUNBUFFERED=1
export CI_SUPPORT="/home/conda/staged-recipes-copy/.ci_support"

cat >~/.condarc <<CONDARC
always_yes: true
Expand All @@ -15,10 +25,10 @@ channels:
- conda-forge
conda-build:
root-dir: /home/conda/staged-recipes/build_artifacts
root-dir: ${FEEDSTOCK_ROOT}/build_artifacts
pkgs_dirs:
- /home/conda/staged-recipes/build_artifacts/pkg_cache
- ${FEEDSTOCK_ROOT}/build_artifacts/pkg_cache
- /opt/conda/pkgs
show_channel_urls: true
Expand All @@ -27,7 +37,7 @@ solver: libmamba
CONDARC

# Copy the host recipes folder so we don't ever muck with it
cp -r /home/conda/staged-recipes ~/staged-recipes-copy
cp -r ${FEEDSTOCK_ROOT} ~/staged-recipes-copy

# Remove any macOS system files
find ~/staged-recipes-copy/recipes -maxdepth 1 -name ".DS_Store" -delete
Expand All @@ -36,21 +46,17 @@ find ~/staged-recipes-copy/recipes -maxdepth 1 -name ".DS_Store" -delete
echo "Pending recipes."
ls -la ~/staged-recipes-copy/recipes
echo "Finding recipes merged in main and removing them from the build."
pushd /home/conda/staged-recipes/recipes > /dev/null
pushd "${FEEDSTOCK_ROOT}/recipes" > /dev/null
if [ "${AZURE}" == "True" ]; then
git fetch --force origin main:main
fi
git ls-tree --name-only main -- . | xargs -I {} sh -c "rm -rf ~/staged-recipes-copy/recipes/{} && echo Removing recipe: {}"
popd > /dev/null


# Make sure build_artifacts is a valid channel
conda index /home/conda/staged-recipes/build_artifacts

conda install --quiet --file /home/conda/staged-recipes/.ci_support/requirements.txt
conda install --quiet --file ${FEEDSTOCK_ROOT}/.ci_support/requirements.txt

export FEEDSTOCK_ROOT="${FEEDSTOCK_ROOT:-/home/conda/staged-recipes}"
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

Expand All @@ -59,6 +65,13 @@ find ~/staged-recipes-copy/recipes -mindepth 2 -maxdepth 2 -type f -name "yum_re
| xargs -n1 cat | { grep -v -e "^#" -e "^$" || test $? == 1; } | \
xargs -r /usr/bin/sudo -n yum install -y

# Make sure build_artifacts is a valid channel
conda index ${FEEDSTOCK_ROOT}/build_artifacts

( endgroup "Configuring conda" ) 2> /dev/null

python ${CI_SUPPORT}/build_all.py

touch "/home/conda/staged-recipes/build_artifacts/conda-forge-build-done"
( startgroup "Final checks" ) 2> /dev/null

touch "${FEEDSTOCK_ROOT}/build_artifacts/conda-forge-build-done"
35 changes: 35 additions & 0 deletions .scripts/logging_utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# Provide a unified interface for the different logging
# utilities CI providers offer. If unavailable, provide
# a compatible fallback (e.g. bare `echo xxxxxx`).

function startgroup {
# Start a foldable group of log lines
# Pass a single argument, quoted
case ${CI:-} in
azure )
echo "##[group]$1";;
travis )
echo "$1"
echo -en 'travis_fold:start:'"${1// /}"'\\r';;
github_actions )
echo "::group::$1";;
* )
echo "$1";;
esac
} 2> /dev/null

function endgroup {
# End a foldable group of log lines
# Pass a single argument, quoted

case ${CI:-} in
azure )
echo "##[endgroup]";;
travis )
echo -en 'travis_fold:end:'"${1// /}"'\\r';;
github_actions )
echo "::endgroup::";;
esac
} 2> /dev/null
11 changes: 11 additions & 0 deletions .scripts/run_docker_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

# NOTE: This script has been adapted from content generated by github.com/conda-forge/conda-smithy

source .scripts/logging_utils.sh

( startgroup "Configure Docker" ) 2> /dev/null

REPO_ROOT=$(cd "$(dirname "$0")/.."; pwd;)
ARTIFACTS="$REPO_ROOT/build_artifacts"
THISDIR="$( cd "$( dirname "$0" )" >/dev/null && pwd )"
Expand Down Expand Up @@ -43,6 +47,10 @@ DOCKER_RUN_ARGS="-it"
if [ "${AZURE}" == "True" ]; then
DOCKER_RUN_ARGS=""
fi
( endgroup "Configure Docker" ) 2> /dev/null

( startgroup "Start Docker" ) 2> /dev/null
# this group is closed in build_steps.sh

docker pull "${DOCKER_IMAGE}"
docker run ${DOCKER_RUN_ARGS} \
Expand All @@ -59,3 +67,6 @@ docker run ${DOCKER_RUN_ARGS} \

# verify that the end of the script was reached
test -f "$DONE_CANARY"

# This closes the last group opened in `build_steps.sh`
( endgroup "Final checks" ) 2> /dev/null
39 changes: 19 additions & 20 deletions .scripts/run_osx_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,33 @@

set -x

echo -e "\n\nInstalling a fresh version of Miniforge."
if [[ ${CI} == "travis" ]]; then
echo -en 'travis_fold:start:install_miniforge\\r'
fi
source .scripts/logging_utils.sh

( startgroup "Ensuring Miniforge" ) 2> /dev/null

MINIFORGE_URL="https://github.com/conda-forge/miniforge/releases/latest/download"
MINIFORGE_FILE="Miniforge3-MacOSX-x86_64.sh"
curl -L -O "${MINIFORGE_URL}/${MINIFORGE_FILE}"
bash $MiniFORGE_FILE -b
if [[ ${CI} == "travis" ]]; then
echo -en 'travis_fold:end:install_miniforge\\r'
fi
MINIFORGE_ROOT="${MINIFORGE_ROOT:-${HOME}/Miniforge3}"

echo -e "\n\nConfiguring conda."
if [[ ${CI} == "travis" ]]; then
echo -en 'travis_fold:start:configure_conda\\r'
if [[ -d "${MINIFORGE_ROOT}" ]]; then
echo "Miniforge already installed at ${MINIFORGE_ROOT}."
else
echo "Installing Miniforge"
curl -L -O "${MINIFORGE_URL}/${MINIFORGE_FILE}"
bash $MINIFORGE_FILE -bp "${MINIFORGE_ROOT}"
fi

( endgroup "Ensuring Miniforge" ) 2> /dev/null

( startgroup "Configuring conda" ) 2> /dev/null

cat >~/.condarc <<CONDARC
always_yes: true
show_channel_urls: true
solver: libmamba
CONDARC

source ${HOME}/Mambaforge/etc/profile.d/conda.sh
source "${MINIFORGE_ROOT}/etc/profile.d/conda.sh"
conda activate base

echo -e "\n\nInstalling conda-forge-ci-setup=3, conda-build."
Expand All @@ -48,18 +51,12 @@ fi
echo -e "\n\nRunning the build setup script."
source run_conda_forge_build_setup


if [[ ${CI} == "travis" ]]; then
echo -en 'travis_fold:end:configure_conda\\r'
fi

set -e

# make sure there is a package directory so that artifact publishing works
mkdir -p /Users/runner/Mambaforge/conda-bld/osx-64/
mkdir -p "${MINIFORGE_ROOT}/conda-bld/osx-64/"

# Find the recipes from main in this PR and remove them.

echo ""
echo "Finding recipes merged in main and removing them from the build."
pushd ./recipes > /dev/null
Expand All @@ -68,5 +65,7 @@ git ls-tree --name-only main -- . | xargs -I {} sh -c "rm -rf {} && echo Removin
popd > /dev/null
echo ""

( endgroup "Configuring conda" ) 2> /dev/null

# We just want to build all of the recipes.
python .ci_support/build_all.py

0 comments on commit a4d95cf

Please sign in to comment.