Skip to content

Commit 740e5fb

Browse files
committed
Make it more resilient to flaky cache hits
1 parent 9f400c3 commit 740e5fb

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

action.yml

+17-16
Original file line numberDiff line numberDiff line change
@@ -40,29 +40,30 @@ runs:
4040
with:
4141
path: ~/.mecha_venv
4242
key: mecha-venv-${{ runner.os }}-${{ inputs.version }}
43-
- name: Install mecha
44-
if: steps.cached-mecha-venv.outputs.cache-hit != 'true'
45-
env:
46-
MECHA_VERSION: ${{ inputs.version }}
47-
run: |
48-
if [ ! -d ~/.mecha_venv ]; then
49-
python -m venv ~/.mecha_venv
50-
fi
51-
source ~/.mecha_venv/bin/activate
52-
if [ "$MECHA_VERSION" == "latest" ]; then
53-
pip install mecha
54-
else
55-
pip install "mecha==$MECHA_VERSION"
56-
fi
57-
shell: bash
5843
- name: Run mecha
5944
env:
45+
CACHE_HIT: ${{ steps.cached-mecha-venv.outputs.cache-hit }}
46+
MECHA_VERSION: ${{ inputs.version }}
6047
MECHA_SOURCE: ${{ inputs.source }}
6148
MECHA_MINECRAFT: ${{ inputs.minecraft }}
6249
MECHA_STATS: ${{ inputs.stats == 'true' && '--stats' || '' }}
6350
MECHA_LOG: ${{ inputs.log }}
6451
run: |
52+
if [ "$CACHE_HIT" != "true" ] || [ ! -f ~/.mecha_venv/bin/python ]; then
53+
rm -rf ~/.mecha_venv
54+
python -m venv ~/.mecha_venv
55+
56+
source ~/.mecha_venv/bin/activate
57+
58+
if [ "$MECHA_VERSION" == "latest" ]; then
59+
pip install mecha
60+
else
61+
pip install "mecha==$MECHA_VERSION"
62+
fi
63+
else
64+
source ~/.mecha_venv/bin/activate
65+
fi
66+
6567
shopt -s extglob
66-
source ~/.mecha_venv/bin/activate
6768
mecha $MECHA_SOURCE --minecraft "$MECHA_MINECRAFT" --log "$MECHA_LOG" $MECHA_STATS
6869
shell: bash

0 commit comments

Comments
 (0)