Skip to content

Commit

Permalink
Merge pull request #36 from xmake-io/cache
Browse files Browse the repository at this point in the history
Cache build and packages
  • Loading branch information
waruqi authored Jan 15, 2025
2 parents ceb318e + cf24e61 commit 68ab78d
Show file tree
Hide file tree
Showing 13 changed files with 845 additions and 41 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,20 @@ jobs:

steps:
- uses: actions/checkout@v1
- uses: xmake-io/github-action-setup-xmake@test
- uses: xmake-io/github-action-setup-xmake@cache
with:
xmake-version: ${{ matrix.version }}
actions-cache-folder: '.xmake-cache'
actions-cache-key: ${{ matrix.version }}
build-cache: true
build-cache-key: ${{ matrix.version }}
package-cache: true
package-cache-key: ${{ matrix.version }}
project-path: 'tests/sample'

- name: Run tests
run: |
xmake --version
xmake create -P test
xmake build -P test
xmake run -P test
cd tests/sample
xmake -y -vD
xmake run
65 changes: 57 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,57 +11,106 @@ See [action.yml](./action.yml).

## Example

Use latest version:
### Use latest version

```yml
uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: latest
```
Use specified version:
### Use specified version
```yml
uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: '2.5.3'
```
Use specified branch:
### Use specified branch
```yml
uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: branch@master
```
Use semver:
### Use semver
```yml
uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: '>=2.2.6 <=2.5.3'
```
Use action cache:
### Cache xmake
```yml
uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: '2.7.2'
xmake-version: '2.9.7'
actions-cache-folder: '.xmake-cache'
```
Use action cache with cachekey:
### Cache xmake with cachekey
```yml
uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: '2.7.2'
xmake-version: '2.9.7'
actions-cache-folder: '.xmake-cache'
actions-cache-key: 'archlinux-ci'
```
### Cache packages
```yml
uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: '2.9.7'
package-cache: true
package-cache-key: 'archlinux-ci'
project-path: 'myproject' # we need to compute packages hashkey for project
```
### Cache build
By default, xmake disables build cache when building on ci, so we need to enable it first.
```bash
$ xmake f --policies=build.ccache:y
```

And xmake v2.9.8 will enable it by default if action/build-cache is enabled.

```yml
uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: '2.9.7'
build-cache: true
build-cache-key: 'archlinux-ci'
```
Cache build with the specific project path.
```yml
uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: '2.9.7'
build-cache: true
project-path: 'myproject' # we can get the build cache path from project.
```
Cache build with the specific build path.
```yml
uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: '2.9.7'
build-cache: true
build-cache-path: 'build/.build_cache'
```
## Contributing
### Prepare development environment
Expand Down
20 changes: 20 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,26 @@ inputs:
actions-cache-key:
description: The actions cache key.
default: ''
package-cache:
description: Enable package cache.
default: false
package-cache-key:
description: The packages cache key.
default: ''
project-path:
description: The project root path.
default: ''
build-cache:
description: Enable build cache.
default: false
build-cache-path:
description: The build cache path.
default: ''
build-cache-key:
description: The build cache key.
default: ''

runs:
using: 'node20'
main: 'dist/index.js'
post: 'dist/index.js'
Loading

0 comments on commit 68ab78d

Please sign in to comment.