Skip to content

Commit 68ab78d

Browse files
authored
Merge pull request #36 from xmake-io/cache
Cache build and packages
2 parents ceb318e + cf24e61 commit 68ab78d

File tree

13 files changed

+845
-41
lines changed

13 files changed

+845
-41
lines changed

.github/workflows/test.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,20 @@ jobs:
1818

1919
steps:
2020
- uses: actions/checkout@v1
21-
- uses: xmake-io/github-action-setup-xmake@test
21+
- uses: xmake-io/github-action-setup-xmake@cache
2222
with:
2323
xmake-version: ${{ matrix.version }}
2424
actions-cache-folder: '.xmake-cache'
25+
actions-cache-key: ${{ matrix.version }}
26+
build-cache: true
27+
build-cache-key: ${{ matrix.version }}
28+
package-cache: true
29+
package-cache-key: ${{ matrix.version }}
30+
project-path: 'tests/sample'
2531

2632
- name: Run tests
2733
run: |
2834
xmake --version
29-
xmake create -P test
30-
xmake build -P test
31-
xmake run -P test
35+
cd tests/sample
36+
xmake -y -vD
37+
xmake run

README.md

Lines changed: 57 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,57 +11,106 @@ See [action.yml](./action.yml).
1111

1212
## Example
1313

14-
Use latest version:
14+
### Use latest version
1515

1616
```yml
1717
uses: xmake-io/github-action-setup-xmake@v1
1818
with:
1919
xmake-version: latest
2020
```
2121
22-
Use specified version:
22+
### Use specified version
2323
2424
```yml
2525
uses: xmake-io/github-action-setup-xmake@v1
2626
with:
2727
xmake-version: '2.5.3'
2828
```
2929
30-
Use specified branch:
30+
### Use specified branch
3131
3232
```yml
3333
uses: xmake-io/github-action-setup-xmake@v1
3434
with:
3535
xmake-version: branch@master
3636
```
3737
38-
Use semver:
38+
### Use semver
3939
4040
```yml
4141
uses: xmake-io/github-action-setup-xmake@v1
4242
with:
4343
xmake-version: '>=2.2.6 <=2.5.3'
4444
```
4545
46-
Use action cache:
46+
### Cache xmake
4747
4848
```yml
4949
uses: xmake-io/github-action-setup-xmake@v1
5050
with:
51-
xmake-version: '2.7.2'
51+
xmake-version: '2.9.7'
5252
actions-cache-folder: '.xmake-cache'
5353
```
5454
55-
Use action cache with cachekey:
55+
### Cache xmake with cachekey
5656
5757
```yml
5858
uses: xmake-io/github-action-setup-xmake@v1
5959
with:
60-
xmake-version: '2.7.2'
60+
xmake-version: '2.9.7'
6161
actions-cache-folder: '.xmake-cache'
6262
actions-cache-key: 'archlinux-ci'
6363
```
6464
65+
### Cache packages
66+
67+
```yml
68+
uses: xmake-io/github-action-setup-xmake@v1
69+
with:
70+
xmake-version: '2.9.7'
71+
package-cache: true
72+
package-cache-key: 'archlinux-ci'
73+
project-path: 'myproject' # we need to compute packages hashkey for project
74+
```
75+
76+
### Cache build
77+
78+
By default, xmake disables build cache when building on ci, so we need to enable it first.
79+
80+
```bash
81+
$ xmake f --policies=build.ccache:y
82+
```
83+
84+
And xmake v2.9.8 will enable it by default if action/build-cache is enabled.
85+
86+
```yml
87+
uses: xmake-io/github-action-setup-xmake@v1
88+
with:
89+
xmake-version: '2.9.7'
90+
build-cache: true
91+
build-cache-key: 'archlinux-ci'
92+
```
93+
94+
Cache build with the specific project path.
95+
96+
```yml
97+
uses: xmake-io/github-action-setup-xmake@v1
98+
with:
99+
xmake-version: '2.9.7'
100+
build-cache: true
101+
project-path: 'myproject' # we can get the build cache path from project.
102+
```
103+
104+
Cache build with the specific build path.
105+
106+
```yml
107+
uses: xmake-io/github-action-setup-xmake@v1
108+
with:
109+
xmake-version: '2.9.7'
110+
build-cache: true
111+
build-cache-path: 'build/.build_cache'
112+
```
113+
65114
## Contributing
66115
67116
### Prepare development environment

action.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,26 @@ inputs:
1616
actions-cache-key:
1717
description: The actions cache key.
1818
default: ''
19+
package-cache:
20+
description: Enable package cache.
21+
default: false
22+
package-cache-key:
23+
description: The packages cache key.
24+
default: ''
25+
project-path:
26+
description: The project root path.
27+
default: ''
28+
build-cache:
29+
description: Enable build cache.
30+
default: false
31+
build-cache-path:
32+
description: The build cache path.
33+
default: ''
34+
build-cache-key:
35+
description: The build cache key.
36+
default: ''
37+
1938
runs:
2039
using: 'node20'
2140
main: 'dist/index.js'
41+
post: 'dist/index.js'

0 commit comments

Comments
 (0)