Skip to content

Cache build and packages #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading