Use conda + Update initial setup docs

This commit is contained in:
abejgonzalez
2022-04-28 15:10:46 -07:00
committed by Abraham Gonzalez
parent 684a02a10f
commit 1de35a6af4
46 changed files with 742 additions and 841 deletions

View File

@@ -0,0 +1,28 @@
name: cleanup-conda
description: 'Remove extra conda environments'
runs:
using: "composite"
steps:
- name: Remove extra conda environments
run: |
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."
else
echo "Removing $CONDA_REMOVE_NAMES conda environments."
for env in $CONDA_REMOVE_NAMES; do
conda env remove -n $env
done
fi
conda env list | awk '{print $1}' | tail -n +4 | while read envname; do
ENV_DATE=$(echo $envname | sed "s/cy-[[:digit:]]\+-\(.*\)-\(riscv\|esp\)-tools/\1/")
NUM_DIFF=$(( ( $(date +%s) - $(date --date="$ENV_DATE" +%s) )/(60*60*24) ))
if (( $NUM_DIFF > 7 )); then
echo "Removing $envname since it is $NUM_DIFF days old."
conda env remove -n $envname
else
echo "Skipping removal of $envname since it is $NUM_DIFF days old."
fi
done
shell: bash -leo pipefail {0}

View File

@@ -0,0 +1,18 @@
name: create-conda-env
description: 'Create conda environments if they dont exist'
runs:
using: "composite"
steps:
- name: Create conda environments
run: |
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"
conda env create -f ./scripts/conda-requirements.yaml -n ${{ env.conda-env-name-no-time }}-$(date --date "${{ env.workflow-timestamp }}" +%Y%m%d)-riscv-tools
conda install -n ${{ env.conda-env-name-no-time }}-$(date --date "${{ env.workflow-timestamp }}" +%Y%m%d)-riscv-tools -c ucb-bar -y riscv-tools
conda env create -f ./scripts/conda-requirements.yaml -n ${{ env.conda-env-name-no-time }}-$(date --date "${{ env.workflow-timestamp }}" +%Y%m%d)-esp-tools
conda install -n ${{ env.conda-env-name-no-time }}-$(date --date "${{ env.workflow-timestamp }}" +%Y%m%d)-esp-tools -c ucb-bar -y esp-tools
fi
shell: bash -leo pipefail {0}

View File

@@ -0,0 +1,15 @@
name: git-workaround
description: 'Workaround https://github.com/actions/checkout/issues/766'
runs:
using: "composite"
steps:
- name: Workaround
run: |
if git config --global -l | grep -q "safe.directory=$GITHUB_WORKSPACE"; then
echo "Skip adding safe directory"
else
echo "Add $GITHUB_WORKSPACE to global git config"
git config --global --add safe.directory "$GITHUB_WORKSPACE"
fi
shell: bash -leo pipefail {0}

View File

@@ -13,28 +13,30 @@ inputs:
description: type of build
required: false
default: "sim"
toolchain:
description: toolchain to use
required: false
default: "riscv-tools"
runs:
using: "composite"
steps:
- name: Build RISC-V toolchains
uses: ./.github/actions/toolchain-build
- uses: actions/cache@v2
- uses: actions/cache@v3
id: rtl-build-id
with:
path: |
sims/verilator
sims/firesim/sim
generators/gemmini/software/gemmini-rocc-tests
key: ${{ inputs.group-key }}-${{ github.ref }}-${{ github.sha }}
key: ${{ inputs.group-key }}-${{ github.sha }}
- name: Run RTL build if not cached
run: |
conda activate ${{ env.conda-env-name-no-time }}-$(date --date "${{ env.workflow-timestamp }}" +%Y%m%d)-${{ inputs.toolchain }}
if [[ "${{ steps.rtl-build-id.outputs.cache-hit }}" != 'true' ]]; then
echo "Cache miss on ${{ inputs.group-key }}-${{ github.ref }}-${{ github.sha }}"
echo "Cache miss on ${{ inputs.group-key }}-${{ github.sha }}"
./.github/scripts/${{ inputs.build-script }} ${{ inputs.group-key }} ${{ inputs.build-type }}
else
echo "Cache hit do not rebuild RTL for ${{ inputs.group-key }}"
fi
shell: bash
shell: bash -leo pipefail {0}

View File

@@ -12,20 +12,29 @@ inputs:
description: rtl build script to use
required: false
default: "run-tests.sh"
toolchain:
description: toolchain to use
required: false
default: "riscv-tools"
runs:
using: "composite"
steps:
- name: Init submodules (since only the RTL is cached)
run: ./scripts/init-submodules-no-riscv-tools.sh --skip-validate
shell: bash
run: |
conda activate ${{ env.conda-env-name-no-time }}-$(date --date "${{ env.workflow-timestamp }}" +%Y%m%d)-${{ inputs.toolchain }}
./scripts/init-submodules-no-riscv-tools.sh --skip-validate
shell: bash -leo pipefail {0}
# Note: You shouldn't need the other inputs since it shouldn't build RTL from scratch
- name: Build RTL
uses: ./.github/actions/prepare-rtl
with:
group-key: ${{ inputs.group-key }}
toolchain: ${{ inputs.toolchain }}
- name: Run RTL tests
run: ./.github/scripts/${{ inputs.run-script }} ${{ inputs.project-key }}
shell: bash
run: |
conda activate ${{ env.conda-env-name-no-time }}-$(date --date "${{ env.workflow-timestamp }}" +%Y%m%d)-${{ inputs.toolchain }}
./.github/scripts/${{ inputs.run-script }} ${{ inputs.project-key }}
shell: bash -leo pipefail {0}

View File

@@ -1,51 +0,0 @@
name: toolchain-build
description: 'Build/cache both toolchains'
runs:
using: "composite"
steps:
- name: Generate hashes
run: .github/scripts/create-hash.sh
shell: bash
# since "hashFiles" function differs on self-hosted vs GH-A machines
# make sure to cache the GH-A hashFiles result so that self-hosted can use it
- run: |
echo "${{ hashFiles('**/riscv-tools.hash') }}" > riscv-tools.hashFilesOutput
echo "${{ hashFiles('**/esp-tools.hash') }}" > esp-tools.hashFilesOutput
shell: bash
- name: Cache hashFiles outputs
uses: actions/cache@v2
with:
path: |
riscv-tools.hashFilesOutput
esp-tools.hashFilesOutput
key: hashFiles-${{ github.sha }}
- name: Generate cache keys based off hashFiles output
id: genkey
run: |
echo "::set-output name=riscv-tools-cache-key::$(cat riscv-tools.hashFilesOutput)"
echo "::set-output name=esp-tools-cache-key::$(cat esp-tools.hashFilesOutput)"
shell: bash
- name: Cache riscv-tools
uses: actions/cache@v2
with:
path: riscv-tools-install
key: riscv-tools-installed-${{ env.tools-cache-version }}-${{ steps.genkey.outputs.riscv-tools-cache-key }}
- name: Cache esp-tools
uses: actions/cache@v2
with:
path: esp-tools-install
key: esp-tools-installed-${{ env.tools-cache-version }}-${{ steps.genkey.outputs.esp-tools-cache-key }}
- name: Build RISC-V toolchain if not cached
run: ./.github/scripts/build-toolchains.sh riscv-tools
shell: bash
- name: Build ESP RISC-V toolchain if not cached
run: ./.github/scripts/build-toolchains.sh esp-tools
shell: bash