Skip to content

Commit

Permalink
Cleaner CI conda env setup | Selective weekly dependabot updates
Browse files Browse the repository at this point in the history
  • Loading branch information
abejgonzalez committed Aug 5, 2024
1 parent a3cda51 commit 55aff23
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 37 deletions.
1 change: 1 addition & 0 deletions .github/actions/cleanup-conda/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ runs:
steps:
- name: Remove extra conda environments
run: |
conda env list
CONDA_REMOVE_NAMES=$(conda env list | awk '{print $1}' | tail -n +3 | grep "${{ env.conda-env-name-no-time }}" || true)
if [ -z "$CONDA_REMOVE_NAMES" ]; then
echo "No matching conda environments for ${{ env.conda-env-name-no-time }}. Skip removal."
Expand Down
26 changes: 11 additions & 15 deletions .github/actions/create-conda-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,20 @@ runs:
steps:
- name: Create conda environments
run: |
conda env list
if conda env list | grep -q "envs/${{ env.conda-env-name-no-time }}"; then
echo "Using pre-existing conda environments with prefix ${{ env.conda-env-name-no-time }}"
else
echo "Creating a conda environment for each toolchain with the toolchain installed"
conda activate base
conda-lock install --conda $(which conda) -n ${{ env.conda-env-name-no-time }}-$(date --date "${{ env.workflow-timestamp }}" +%Y%m%d)-riscv-tools ./conda-reqs/conda-lock-reqs/conda-requirements-riscv-tools-linux-64.conda-lock.yml
conda deactivate
echo "Add extra toolchain collateral + CIRCT to RISC-V install area"
git submodule update --init ./tools/install-circt
conda activate ${{ env.conda-env-name-no-time }}-$(date --date "${{ env.workflow-timestamp }}" +%Y%m%d)-riscv-tools
./scripts/build-toolchain-extra.sh riscv-tools -p $CONDA_PREFIX/riscv-tools
./tools/install-circt/bin/download-release-or-nightly-circt.sh \
-f circt-full-shared-linux-x64.tar.gz \
-i $CONDA_PREFIX \
-v version-file \
-x ./conda-reqs/circt.json \
-g ${{ github.token }}
conda deactivate
./build-setup.sh \
--conda-env-name ${{ env.conda-env-name-no-time }}-$(date --date "${{ env.workflow-timestamp }}" +%Y%m%d) \
--github-token ${{ github.token }} \
--verbose \
--skip-submodules \
--skip-ctags \
--skip-precompile \
--skip-firesim \
--skip-marshal \
--skip-clean
fi
shell: bash -leo pipefail {0}
23 changes: 13 additions & 10 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
version: 2

# update weekly (to avoid spam)
updates:
# submit a PR for bumping submodules daily (for selected submodules).
# bump submodules.
# updates a submodule to the latest commit on the branch given in .gitmodules.
# if branch not given, then it defaults to the main/master branch.
- package-ecosystem: gitsubmodule
schedule:
interval: "daily"
interval: "weekly"
directory: /
labels:
- "dependencies"
- "changelog:omit"
# ignore certain submodules
ignore:
- dependency-name: "generators/gemmini"
- dependency-name: "generators/rocket-chip"
- dependency-name: "generators/rocket-chip-blocks"
- dependency-name: "generators/rocket-chip-inclusive-cache"
# allow certain submodules
allow:
- dependency-name: "sims/firesim"
- dependency-name: "software/baremetal-ide"
- dependency-name: "software/firemarshal"
- dependency-name: "toolchains/riscv-tools/riscv-isa-sim"
- dependency-name: "toolchains/riscv-tools/riscv-openocd"
- dependency-name: "toolchains/riscv-tools/riscv-pk"
- dependency-name: "toolchains/riscv-tools/riscv-spike-devices"
- dependency-name: "toolchains/riscv-tools/riscv-tests"
- dependency-name: "toolchains/riscv-tools/riscv-tools-feedstock"
# submit a PR for bumping GH-A dependencies
- package-ecosystem: github-actions
schedule:
interval: "daily"
interval: "weekly"
directory: /
labels:
- "dependencies"
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/update-circt.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: update-circt

# run daily
# TODO: update weekly (to avoid spam)
on:
schedule:
- cron: 0,15,30,45 * * * *
#- cron: 0 8 * * *
#- cron: 0 0 * * 1

defaults:
run:
Expand All @@ -23,3 +23,4 @@ jobs:
pr-reviewers: ''
pr-labels: 'changelog:changed'
circt-config: './conda-reqs/circt.json'
github-token: ${{ secrets.BARTENDER_PERSONAL_ACCESS_TOKEN }}
41 changes: 31 additions & 10 deletions scripts/build-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ usage() {
echo " --help -h : Display this message"
echo " --verbose -v : Verbose printout"
echo " --use-unpinned-deps -ud : Use unpinned conda environment"
echo " --use-lean-conda : Install a leaner version of the repository (Smaller conda env, no FireSim, no FireMarshal)"
echo " --use-lean-conda : Install a leaner version of the repository (smaller conda env, no FireSim, no FireMarshal)"
echo " --build-circt : Builds CIRCT from source, instead of downloading the precompiled binary"
echo " --conda-env-name NAME : Optionally use a global conda env name instead of storing env in Chipyard directory"
echo " --github-token TOKEN : Optionally use a Github token to download CIRCT"

echo " --skip -s N : Skip step N in the list above. Use multiple times to skip multiple steps ('-s N -s M ...')."
echo " --skip-conda : Skip Conda initialization (step 1)"
Expand All @@ -61,6 +63,8 @@ USE_UNPINNED_DEPS=false
USE_LEAN_CONDA=false
SKIP_LIST=()
BUILD_CIRCT=false
GLOBAL_ENV_NAME=""
GITHUB_TOKEN="null"

# getopts does not support long options, and is inflexible
while [ "$1" != "" ];
Expand All @@ -78,6 +82,12 @@ do
SKIP_LIST+=(4 6 7 8 9) ;;
--build-circt)
BUILD_CIRCT=true ;;
--conda-env-name)
shift
GLOBAL_ENV_NAME=${1} ;;
--github-token)
shift
GITHUB_TOKEN=${1} ;;
-ud | --use-unpinned-deps )
USE_UNPINNED_DEPS=true ;;
--skip | -s)
Expand Down Expand Up @@ -154,24 +164,35 @@ if run_step "1"; then

# create conda-lock only environment to be used in this section.
# done with cloning base then installing conda lock to speed up dependency solving.
rm -rf $CYDIR/.conda-lock-env &&
conda create -y -p $CYDIR/.conda-lock-env --clone base &&
CONDA_LOCK_ENV_PATH=$CYDIR/.conda-lock-env
rm -rf $CONDA_LOCK_ENV_PATH &&
conda create -y -p $CONDA_LOCK_ENV_PATH --clone base &&
source $(conda info --base)/etc/profile.d/conda.sh &&
conda activate $CYDIR/.conda-lock-env &&
conda install -y -c conda-forge -p $CYDIR/.conda-lock-env $(grep "conda-lock" $CONDA_REQS/chipyard-base.yaml | sed 's/^ \+-//')
conda activate $CONDA_LOCK_ENV_PATH &&
conda install -y -c conda-forge -p $CONDA_LOCK_ENV_PATH $(grep "conda-lock" $CONDA_REQS/chipyard-base.yaml | sed 's/^ \+-//')
exit_if_last_command_failed

if [ "$USE_UNPINNED_DEPS" = true ]; then
# auto-gen the lockfiles
$CYDIR/scripts/generate-conda-lockfiles.sh
exit_if_last_command_failed
fi
echo "Using lockfile: $LOCKFILE"
echo "Using lockfile for conda: $LOCKFILE"

# use conda-lock to create env
conda-lock install --conda $(which conda) -p $CYDIR/.conda-env $LOCKFILE &&
if [ -z "$GLOBAL_ENV_NAME" ] ; then
CONDA_ENV_PATH=$CYDIR/.conda-env
CONDA_ENV_ARG="-p $CONDA_ENV_PATH"
CONDA_ENV_NAME=$CONDA_ENV_PATH
else
CONDA_ENV_ARG="-n $GLOBAL_ENV_NAME"
CONDA_ENV_NAME=$GLOBAL_ENV_NAME
fi
echo "Storing main conda environment in $CONDA_ENV_NAME"

conda-lock install --conda $(which conda) $CONDA_ENV_ARG $LOCKFILE &&
source $(conda info --base)/etc/profile.d/conda.sh &&
conda activate $CYDIR/.conda-env
conda activate $CONDA_ENV_NAME
exit_if_last_command_failed

# Conda Setup
Expand All @@ -191,7 +212,7 @@ END_CONDA_ACTIVATE

replace_content env.sh build-setup-conda "# line auto-generated by $0
$CONDA_ACTIVATE_PREAMBLE
conda activate $CYDIR/.conda-env
conda activate $CONDA_ENV_NAME
source $CYDIR/scripts/fix-open-files.sh"

fi
Expand Down Expand Up @@ -308,7 +329,7 @@ if run_step "10"; then
-i $PREFIX \
-v version-file \
-x $CYDIR/conda-reqs/circt.json \
-g null
-g $GITHUB_TOKEN
fi
exit_if_last_command_failed
fi
Expand Down

0 comments on commit 55aff23

Please sign in to comment.