Try abstracting more away into composite actions
This commit is contained in:
50
.github/actions/toolchain-build/action.yml
vendored
50
.github/actions/toolchain-build/action.yml
vendored
@@ -6,24 +6,42 @@ inputs:
|
||||
description: Which toolchain to build
|
||||
required: false
|
||||
default: 'riscv-tools'
|
||||
cache-key:
|
||||
description: Use this for caching
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- uses: actions/cache@v2
|
||||
id: toolchain-build-id
|
||||
with:
|
||||
path: ${{ inputs.tools-version }}-install
|
||||
key: ${{ inputs.cache-key }}
|
||||
- name: run build toolchain if not cached
|
||||
run: |
|
||||
if [[ "${{ steps.toolchain-build-id.outputs.cache-hit }}" != 'true' ]]; then
|
||||
echo "Cache miss on ${{ inputs.tools-version }}-install"
|
||||
./.github/scripts/build-toolchains.sh ${{ inputs.tools-version }}
|
||||
else
|
||||
echo "cache hit do not generate build ${{ inputs.tools-version }}"
|
||||
fi
|
||||
- name: Generate hashes
|
||||
run: .github/scripts/create-hash.sh
|
||||
shell: bash
|
||||
|
||||
- name: Generate keys
|
||||
id: genkey
|
||||
run: |
|
||||
echo "::set-output name=riscvtools-cache-key::riscv-tools-installed-${{ env.tools-cache-version }}-$(shasum riscv-tools.hash | cut -d' ' -f1)"
|
||||
echo "::set-output name=esptools-cache-key::esp-tools-installed-${{ env.tools-cache-version }}-$(shasum esp-tools.hash | cut -d' ' -f1)"
|
||||
shell: bash
|
||||
|
||||
# brute force way to swap between riscv/esp-tools caches
|
||||
- uses: actions/cache@v2
|
||||
id: toolchain-build-riscv-tools
|
||||
if: ${{ inputs.tools-version == "riscv-tools" }}
|
||||
with:
|
||||
path: ${{ inputs.tools-version }}-install
|
||||
key: ${{ steps.genkey.outputs.riscvtools-cache-key }}
|
||||
|
||||
- uses: actions/cache@v2
|
||||
id: toolchain-build-esp-tools
|
||||
if: ${{ inputs.tools-version == "esp-tools" }}
|
||||
with:
|
||||
path: ${{ inputs.tools-version }}-install
|
||||
key: ${{ steps.genkey.outputs.esptools-cache-key }}
|
||||
|
||||
- name: Build toolchain if not cached
|
||||
run: |
|
||||
if [[ "${{ steps.toolchain-build-riscv-tools.outputs.cache-hit }}" != 'true' || "${{ steps.toolchain-build-esp-tools.outputs.cache-hit }}" != 'true' ]]; then
|
||||
echo "Cache miss on ${{ inputs.tools-version }}-install. Build."
|
||||
./.github/scripts/build-toolchains.sh ${{ inputs.tools-version }}
|
||||
else
|
||||
echo "Cache hit do not rebuild toolchain ${{ inputs.tools-version }}."
|
||||
fi
|
||||
shell: bash
|
||||
|
||||
Reference in New Issue
Block a user