Skip to content

Commit 4a04711

Browse files
authoredDec 13, 2024··
Merge pull request #6 from adrianriobo/fix-4
feat: added cache for binary and bundle to speed up action
2 parents 9b79f84 + cda12de commit 4a04711

File tree

1 file changed

+41
-6
lines changed

1 file changed

+41
-6
lines changed
 

‎action.yml

+41-6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ inputs:
1818
disk:
1919
description: 'disk size consumed by crc instance'
2020
required: false
21+
cache:
22+
description: 'enable cache to speed up cluster starts: true or false (default true). '
23+
default: 'true'
2124
runs:
2225
using: 'composite'
2326
steps:
@@ -27,6 +30,28 @@ runs:
2730
run: |
2831
echo "::error title=⛔ error hint::Support Linux Only"
2932
exit 1
33+
34+
- name: Set CRC versions
35+
if: ${{ inputs.cache == 'true' }}
36+
shell: bash
37+
run: |
38+
curl -LO https://mirror.openshift.com/pub/openshift-v4/clients/crc/latest/release-info.json
39+
echo "crc_version=$(jq -r '.version.crcVersion' release-info.json)" >> "$GITHUB_ENV"
40+
41+
- name: Cache for crc binary
42+
if: ${{ inputs.cache == 'true' }}
43+
uses: actions/cache@v4
44+
with:
45+
path: installer
46+
key: installer-${{ env.crc_version}}-${{ runner.arch }}
47+
48+
- name: Cache for bundle
49+
if: ${{ inputs.cache == 'true' }}
50+
uses: actions/cache@v4
51+
with:
52+
path: ~/.crc/cache
53+
key: bundle-${{ inputs.preset}}-${{ env.crc_version }}-${{ runner.arch }}
54+
3055
- name: Download CRC
3156
shell: bash
3257
run: |
@@ -36,20 +61,26 @@ runs:
3661
CRC_ARCH="amd64"
3762
fi
3863
URL="https://mirror.openshift.com/pub/openshift-v4/clients/crc/latest/crc-linux-${CRC_ARCH}.tar.xz"
39-
echo "Downloading $URL"
40-
curl -H user-agent:crc-github-action -L "$URL" -o crc-linux.tar.xz --max-time 300 --fail
41-
SHA256SUM=$(curl -H user-agent:crc-github-action -L "${URL}".sha256 --fail)
42-
echo "Expected sha256: $SHA256SUM"
43-
echo "Actual sha256: $(sha256sum crc-linux.tar.xz)"
44-
echo "$SHA256SUM crc-linux.tar.xz" | sha256sum -c
64+
mkdir -p installer
65+
pushd installer
66+
if [ ! -f crc-linux.tar.xz ]; then
67+
echo "Downloading $URL"
68+
curl -H user-agent:crc-github-action -L "$URL" -o crc-linux.tar.xz --max-time 300 --fail
69+
SHA256SUM=$(curl -H user-agent:crc-github-action -L "${URL}".sha256 --fail)
70+
echo "Expected sha256: $SHA256SUM"
71+
echo "Actual sha256: $(sha256sum crc-linux.tar.xz)"
72+
echo "$SHA256SUM crc-linux.tar.xz" | sha256sum -c
73+
fi
4574
tar -C /tmp -xvf crc-linux.tar.xz
4675
sudo mv /tmp/crc-linux-*-amd64/crc /usr/bin
76+
4777
- name: Install required virtualization software
4878
shell: bash
4979
run: |
5080
sudo apt-get update
5181
sudo apt install qemu-kvm libvirt-daemon libvirt-daemon-system
5282
sudo usermod -a -G libvirt $USER
83+
5384
- name: Remove unwanted stuff to free up disk image
5485
shell: bash
5586
run: |
@@ -63,6 +94,7 @@ runs:
6394

6495
sudo swapoff -a
6596
sudo rm -f /mnt/swapfile
97+
6698
- name: Set the crc config
6799
shell: bash
68100
env:
@@ -85,15 +117,18 @@ runs:
85117
echo "Using disk: ${{ inputs['disk'] }}"
86118
crc config set disk-size ${{ inputs['disk'] }}
87119
fi
120+
88121
- name: Setup and Start the crc
89122
shell: bash
90123
run: |
91124
sudo -su $USER crc setup
92125
sudo -su $USER crc start
93126
sleep 60
127+
94128
- name: Copy OpenShift client
95129
shell: bash
96130
run: sudo cp /home/$USER/.crc/bin/oc/oc /usr/bin/
131+
97132
- name: Copy the kubeconfig file to required location
98133
shell: bash
99134
run: |

0 commit comments

Comments
 (0)
Please sign in to comment.