Add caching of the installed cross binary
This commit is contained in:
parent
dd8fb2fac4
commit
b1e766fe8f
@ -1,3 +1,9 @@
|
||||
## 0.0.8
|
||||
|
||||
- For builds that need the `cross` binary, this binary is now cached. A cache
|
||||
hit saves about 20 seconds in my tests. Suggested by @timon-schelling. GH
|
||||
#4.
|
||||
|
||||
## 0.0.7 - 2023-04-21
|
||||
|
||||
- The toolchain argument was (probably) not being respected with cross builds,
|
||||
|
||||
27
action.yml
27
action.yml
@ -44,16 +44,37 @@ runs:
|
||||
with:
|
||||
targets: ${{ inputs.target }}
|
||||
toolchain: ${{ inputs.toolchain }}
|
||||
- name: Determine latest cross version
|
||||
id: determine-latest-cross-version
|
||||
shell: bash
|
||||
run: determine-latest-cross-version.sh
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
|
||||
if: ${{ steps.determine-cross-compile.outputs.needs-cross == 'true' }}
|
||||
# We need to accesss this in both this YAML config and shell scripts. It
|
||||
# doesn't seem like using ${{ env.RUNNER_TEMP }} works in the YAML config.
|
||||
- name: Set directory for installing cross
|
||||
id: set-cross-dir
|
||||
shell: bash
|
||||
run: set-cross-dir.sh
|
||||
if: ${{ steps.determine-cross-compile.outputs.needs-cross == 'true' }}
|
||||
- name: Cache cross
|
||||
id: cache-cross
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ steps.set-cross-dir.outputs.cross-dir }}/cross
|
||||
key: ${{ runner.os }}-${{ steps.determine-latest-cross-version.outputs.cross-version }}
|
||||
if: ${{ steps.determine-cross-compile.outputs.needs-cross == 'true' }}
|
||||
- name: Install cross if cross-compiling (*nix)
|
||||
shell: bash
|
||||
run: install-cross-nix.sh
|
||||
if: ${{ steps.determine-cross-compile.outputs.needs-cross == 'true' }}
|
||||
run: install-cross-nix.sh ${{ steps.set-cross-dir.outputs.cross-dir }}
|
||||
if: ${{ steps.determine-cross-compile.outputs.needs-cross == 'true' && steps.cache-cross.outputs.cache-hit != 'true' }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
|
||||
- name: Set build command
|
||||
id: set-build-command
|
||||
shell: bash
|
||||
run: set-build-command.sh
|
||||
run: set-build-command.sh ${{ steps.set-cross-dir.outputs.cross-dir }}
|
||||
- name: Run tests (*nix)
|
||||
shell: bash
|
||||
run: |
|
||||
|
||||
11
determine-latest-cross-version.sh
Executable file
11
determine-latest-cross-version.sh
Executable file
@ -0,0 +1,11 @@
|
||||
set -e
|
||||
set -x
|
||||
set -o pipefail
|
||||
|
||||
JSON=$( curl \
|
||||
--request GET \
|
||||
--header "Authorization: Bearer $GITHUB_TOKEN" \
|
||||
https://api.github.com/repos/cross-rs/cross/releases/latest )
|
||||
VERSION=$( echo "$JSON" | jq -r ".tag_name")
|
||||
|
||||
echo "cross-version=$VERSION" >> $GITHUB_OUTPUT
|
||||
@ -1,7 +1,9 @@
|
||||
set -e
|
||||
set -x
|
||||
set -o pipefail
|
||||
|
||||
cd "$RUNNER_TEMP"
|
||||
CROSS_DIR="$1"
|
||||
cd "$CROSS_DIR"
|
||||
export TARGET=.
|
||||
curl --silent --location \
|
||||
https://raw.githubusercontent.com/houseabsolute/ubi/master/bootstrap/bootstrap-ubi.sh |
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
set -e
|
||||
set -x
|
||||
|
||||
if [ -f "$RUNNER_TEMP/cross" ]; then
|
||||
echo "build-command=$RUNNER_TEMP/cross" >> $GITHUB_OUTPUT
|
||||
CROSS_DIR="$1"
|
||||
if [ -f "$CROSS_DIR/cross" ]; then
|
||||
echo "build-command=$CROSS_DIR/cross" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "build-command=cargo" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
4
set-cross-dir.sh
Executable file
4
set-cross-dir.sh
Executable file
@ -0,0 +1,4 @@
|
||||
set -e
|
||||
set -x
|
||||
|
||||
echo "cross-dir=$RUNNER_TEMP" >> $GITHUB_OUTPUT
|
||||
Loading…
x
Reference in New Issue
Block a user