mirror of
https://github.com/graycoreio/github-actions-magento2.git
synced 2026-06-08 19:46:41 +00:00
feat(cache-magento): include runner.os in the cache key (#245)
Composer's download cache contains platform-specific binaries and extracted archives that aren't safe to share across operating systems. Add the runner OS as a key segment so a Linux job won't restore a macOS-built cache (or vice versa).
This commit is contained in:
@@ -37,6 +37,7 @@ runs:
|
|||||||
run: |
|
run: |
|
||||||
bash "${{ github.action_path }}/compute-cache-keys.sh" \
|
bash "${{ github.action_path }}/compute-cache-keys.sh" \
|
||||||
"${{ inputs.composer_cache_key }}" \
|
"${{ inputs.composer_cache_key }}" \
|
||||||
|
"${{ runner.os }}" \
|
||||||
"${{ steps.cache-magento-get-php-version.outputs.version }}" \
|
"${{ steps.cache-magento-get-php-version.outputs.version }}" \
|
||||||
"${{ steps.cache-magento-get-composer-version.outputs.version }}" \
|
"${{ steps.cache-magento-get-composer-version.outputs.version }}" \
|
||||||
>> $GITHUB_OUTPUT
|
>> $GITHUB_OUTPUT
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Args: composer_cache_key php_version composer_version
|
# Args: composer_cache_key os php_version composer_version
|
||||||
COMPOSER_CACHE_KEY="$1"
|
COMPOSER_CACHE_KEY="$1"
|
||||||
PHP_VERSION="$2"
|
OS="$2"
|
||||||
COMPOSER_VERSION="$3"
|
PHP_VERSION="$3"
|
||||||
|
COMPOSER_VERSION="$4"
|
||||||
|
|
||||||
echo "download-key=composer | v5.8 | ${COMPOSER_CACHE_KEY} | ${COMPOSER_VERSION} | ${PHP_VERSION}"
|
echo "download-key=composer | v5.8 | ${OS} | ${COMPOSER_CACHE_KEY} | ${COMPOSER_VERSION} | ${PHP_VERSION}"
|
||||||
|
|||||||
+12
-6
@@ -22,16 +22,22 @@ field() {
|
|||||||
echo "$1" | grep "^${2}=" | cut -d= -f2-
|
echo "$1" | grep "^${2}=" | cut -d= -f2-
|
||||||
}
|
}
|
||||||
|
|
||||||
# Default cache key
|
# Default cache key (Linux)
|
||||||
OUT=$(bash "$SCRIPT" "_mageos" "8.3.0" "2.2.6")
|
OUT=$(bash "$SCRIPT" "_mageos" "Linux" "8.3.0" "2.2.6")
|
||||||
assert_eq "default: download-key" \
|
assert_eq "linux: download-key" \
|
||||||
"composer | v5.8 | _mageos | 2.2.6 | 8.3.0" \
|
"composer | v5.8 | Linux | _mageos | 2.2.6 | 8.3.0" \
|
||||||
|
"$(field "$OUT" download-key)"
|
||||||
|
|
||||||
|
# OS segment differentiates macOS from Linux
|
||||||
|
OUT=$(bash "$SCRIPT" "_mageos" "macOS" "8.3.0" "2.2.6")
|
||||||
|
assert_eq "macos: download-key" \
|
||||||
|
"composer | v5.8 | macOS | _mageos | 2.2.6 | 8.3.0" \
|
||||||
"$(field "$OUT" download-key)"
|
"$(field "$OUT" download-key)"
|
||||||
|
|
||||||
# Custom composer_cache_key
|
# Custom composer_cache_key
|
||||||
OUT=$(bash "$SCRIPT" "custom-v2" "8.1.5" "2.4.2")
|
OUT=$(bash "$SCRIPT" "custom-v2" "Linux" "8.1.5" "2.4.2")
|
||||||
assert_eq "custom key: download-key" \
|
assert_eq "custom key: download-key" \
|
||||||
"composer | v5.8 | custom-v2 | 2.4.2 | 8.1.5" \
|
"composer | v5.8 | Linux | custom-v2 | 2.4.2 | 8.1.5" \
|
||||||
"$(field "$OUT" download-key)"
|
"$(field "$OUT" download-key)"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
Reference in New Issue
Block a user