forked from actions/setup-java
-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (113 loc) · 3.36 KB
/
Copy pathwarp-cache-e2e.yml
File metadata and controls
124 lines (113 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: warp-cache-e2e
on:
pull_request:
paths-ignore:
- '**.md'
push:
branches:
- main
paths-ignore:
- '**.md'
workflow_dispatch:
permissions:
contents: read
jobs:
save:
name: save (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
[
warp-ubuntu-latest-x64-2x,
warp-windows-2022-x64-4x,
warp-macos-15-arm64-6x
]
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
# The cache key is derived from this file's hash, so a per-run value
# guarantees a fresh key and a genuine miss -> save -> hit round trip.
- name: Write run-unique pom
shell: bash
env:
RUN_ID: ${{ github.run_id }}
RUN_ATTEMPT: ${{ github.run_attempt }}
run: |
mkdir -p warp-fixture
printf '<project><!-- warp-cache-e2e %s-%s --></project>\n' \
"$RUN_ID" "$RUN_ATTEMPT" > warp-fixture/pom.xml
- name: Setup Java
id: setup
uses: ./
with:
distribution: temurin
java-version: '21'
cache: maven
cache-dependency-path: warp-fixture/pom.xml
- name: Assert cache miss on a fresh key
shell: bash
env:
PRIMARY_KEY: ${{ steps.setup.outputs.cache-primary-key }}
CACHE_HIT: ${{ steps.setup.outputs.cache-hit }}
run: |
echo "primary-key: $PRIMARY_KEY"
if [ "$CACHE_HIT" != "false" ]; then
echo "expected a miss on a run-unique key, got cache-hit=$CACHE_HIT"
exit 1
fi
# Give the post step real bytes to upload without a full maven resolve.
- name: Populate the maven repository
shell: bash
env:
RUN_ID: ${{ github.run_id }}
run: |
mkdir -p "$HOME/.m2/repository"
echo "warp-cache-e2e $RUN_ID" > "$HOME/.m2/repository/warp-e2e.txt"
restore:
name: restore (${{ matrix.os }})
needs: save
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
[
warp-ubuntu-latest-x64-2x,
warp-windows-2022-x64-4x,
warp-macos-15-arm64-6x
]
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: Write the same run-unique pom
shell: bash
env:
RUN_ID: ${{ github.run_id }}
RUN_ATTEMPT: ${{ github.run_attempt }}
run: |
mkdir -p warp-fixture
printf '<project><!-- warp-cache-e2e %s-%s --></project>\n' \
"$RUN_ID" "$RUN_ATTEMPT" > warp-fixture/pom.xml
- name: Setup Java
id: setup
uses: ./
with:
distribution: temurin
java-version: '21'
cache: maven
cache-dependency-path: warp-fixture/pom.xml
- name: Assert the cache saved by the save job was restored
shell: bash
env:
CACHE_HIT: ${{ steps.setup.outputs.cache-hit }}
run: |
if [ "$CACHE_HIT" != "true" ]; then
echo "expected an exact-key hit on the cache saved by the save job"
exit 1
fi
test -f "$HOME/.m2/repository/warp-e2e.txt"
echo "restored marker: $(cat "$HOME/.m2/repository/warp-e2e.txt")"