mirror of
https://code.forgejo.org/actions/cache.git
synced 2024-11-09 03:03:40 -05:00
Merge pull request #250 from actions/test-relative-path
Fix caching directories outside of the working directory (relative paths)
This commit is contained in:
commit
78809b91d7
7 changed files with 48 additions and 20 deletions
28
.github/workflows/workflow.yml
vendored
28
.github/workflows/workflow.yml
vendored
|
@ -51,23 +51,30 @@ jobs:
|
|||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||
fail-fast: false
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Generate files
|
||||
- name: Generate files in working directory
|
||||
shell: bash
|
||||
run: __tests__/create-cache-files.sh ${{ runner.os }}
|
||||
run: __tests__/create-cache-files.sh ${{ runner.os }} test-cache
|
||||
- name: Generate files outside working directory
|
||||
shell: bash
|
||||
run: __tests__/create-cache-files.sh ${{ runner.os }} ~/test-cache
|
||||
- name: Save cache
|
||||
uses: ./
|
||||
with:
|
||||
key: test-${{ runner.os }}-${{ github.run_id }}
|
||||
path: test-cache
|
||||
path: |
|
||||
test-cache
|
||||
~/test-cache
|
||||
test-restore:
|
||||
needs: test-save
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||
fail-fast: false
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
@ -76,10 +83,15 @@ jobs:
|
|||
uses: ./
|
||||
with:
|
||||
key: test-${{ runner.os }}-${{ github.run_id }}
|
||||
path: test-cache
|
||||
- name: Verify cache
|
||||
path: |
|
||||
test-cache
|
||||
~/test-cache
|
||||
- name: Verify cache files in working directory
|
||||
shell: bash
|
||||
run: __tests__/verify-cache-files.sh ${{ runner.os }}
|
||||
run: __tests__/verify-cache-files.sh ${{ runner.os }} test-cache
|
||||
- name: Verify cache files outside working directory
|
||||
shell: bash
|
||||
run: __tests__/verify-cache-files.sh ${{ runner.os }} ~/test-cache
|
||||
|
||||
# End to end with proxy
|
||||
test-proxy-save:
|
||||
|
@ -98,7 +110,7 @@ jobs:
|
|||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Generate files
|
||||
run: __tests__/create-cache-files.sh proxy
|
||||
run: __tests__/create-cache-files.sh proxy test-cache
|
||||
- name: Save cache
|
||||
uses: ./
|
||||
with:
|
||||
|
@ -126,4 +138,4 @@ jobs:
|
|||
key: test-proxy-${{ github.run_id }}
|
||||
path: test-cache
|
||||
- name: Verify cache
|
||||
run: __tests__/verify-cache-files.sh proxy
|
||||
run: __tests__/verify-cache-files.sh proxy test-cache
|
||||
|
|
|
@ -7,5 +7,11 @@ if [ -z "$prefix" ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
mkdir test-cache
|
||||
echo "$prefix $GITHUB_RUN_ID" > test-cache/test-file.txt
|
||||
path="$2"
|
||||
if [ -z "$path" ]; then
|
||||
echo "Must supply path argument"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p $path
|
||||
echo "$prefix $GITHUB_RUN_ID" > $path/test-file.txt
|
||||
|
|
|
@ -73,6 +73,7 @@ test("create tar", async () => {
|
|||
"-cz",
|
||||
"-f",
|
||||
CacheFilename,
|
||||
"-P",
|
||||
"-C",
|
||||
workspace,
|
||||
"--files-from",
|
||||
|
|
|
@ -7,6 +7,12 @@ if [ -z "$prefix" ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
path="$2"
|
||||
if [ -z "$path" ]; then
|
||||
echo "Must specify path argument"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Sanity check GITHUB_RUN_ID defined
|
||||
if [ -z "$GITHUB_RUN_ID" ]; then
|
||||
echo "GITHUB_RUN_ID not defined"
|
||||
|
@ -14,7 +20,7 @@ if [ -z "$GITHUB_RUN_ID" ]; then
|
|||
fi
|
||||
|
||||
# Verify file exists
|
||||
file="test-cache/test-file.txt"
|
||||
file="$path/test-file.txt"
|
||||
echo "Checking for $file"
|
||||
if [ ! -e $file ]; then
|
||||
echo "File does not exist"
|
||||
|
|
9
dist/restore/index.js
vendored
9
dist/restore/index.js
vendored
|
@ -2182,12 +2182,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = __importStar(__webpack_require__(470));
|
||||
const fs = __importStar(__webpack_require__(747));
|
||||
const crypto = __importStar(__webpack_require__(417));
|
||||
const http_client_1 = __webpack_require__(539);
|
||||
const auth_1 = __webpack_require__(226);
|
||||
const utils = __importStar(__webpack_require__(443));
|
||||
const crypto = __importStar(__webpack_require__(417));
|
||||
const fs = __importStar(__webpack_require__(747));
|
||||
const constants_1 = __webpack_require__(694);
|
||||
const utils = __importStar(__webpack_require__(443));
|
||||
const versionSalt = "1.0";
|
||||
function isSuccessStatusCode(statusCode) {
|
||||
if (!statusCode) {
|
||||
|
@ -3185,8 +3185,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = __importStar(__webpack_require__(470));
|
||||
const io = __importStar(__webpack_require__(1));
|
||||
const glob = __importStar(__webpack_require__(281));
|
||||
const io = __importStar(__webpack_require__(1));
|
||||
const fs = __importStar(__webpack_require__(747));
|
||||
const path = __importStar(__webpack_require__(622));
|
||||
const util = __importStar(__webpack_require__(669));
|
||||
|
@ -5016,6 +5016,7 @@ function createTar(archiveFolder, sourceDirectories) {
|
|||
"-cz",
|
||||
"-f",
|
||||
constants_1.CacheFilename,
|
||||
"-P",
|
||||
"-C",
|
||||
workingDirectory,
|
||||
"--files-from",
|
||||
|
|
9
dist/save/index.js
vendored
9
dist/save/index.js
vendored
|
@ -2182,12 +2182,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = __importStar(__webpack_require__(470));
|
||||
const fs = __importStar(__webpack_require__(747));
|
||||
const crypto = __importStar(__webpack_require__(417));
|
||||
const http_client_1 = __webpack_require__(539);
|
||||
const auth_1 = __webpack_require__(226);
|
||||
const utils = __importStar(__webpack_require__(443));
|
||||
const crypto = __importStar(__webpack_require__(417));
|
||||
const fs = __importStar(__webpack_require__(747));
|
||||
const constants_1 = __webpack_require__(694);
|
||||
const utils = __importStar(__webpack_require__(443));
|
||||
const versionSalt = "1.0";
|
||||
function isSuccessStatusCode(statusCode) {
|
||||
if (!statusCode) {
|
||||
|
@ -3185,8 +3185,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = __importStar(__webpack_require__(470));
|
||||
const io = __importStar(__webpack_require__(1));
|
||||
const glob = __importStar(__webpack_require__(281));
|
||||
const io = __importStar(__webpack_require__(1));
|
||||
const fs = __importStar(__webpack_require__(747));
|
||||
const path = __importStar(__webpack_require__(622));
|
||||
const util = __importStar(__webpack_require__(669));
|
||||
|
@ -4993,6 +4993,7 @@ function createTar(archiveFolder, sourceDirectories) {
|
|||
"-cz",
|
||||
"-f",
|
||||
constants_1.CacheFilename,
|
||||
"-P",
|
||||
"-C",
|
||||
workingDirectory,
|
||||
"--files-from",
|
||||
|
|
|
@ -59,6 +59,7 @@ export async function createTar(
|
|||
"-cz",
|
||||
"-f",
|
||||
CacheFilename,
|
||||
"-P",
|
||||
"-C",
|
||||
workingDirectory,
|
||||
"--files-from",
|
||||
|
|
Loading…
Reference in a new issue