Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
brokenpip3 committed Sep 26, 2024
1 parent 662bab2 commit cb3c9e6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
28 changes: 21 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This GitHub Action installs [Bats](https://github.com/bats-core/bats-core) and t
* [bats-file](https://github.com/bats-core/bats-file)

The action can be also instructed to select which libraries to install.
While Linux is fully supported, windows and macos runners should work as well.
While Linux is fully supported, windows and macos runners should work as well, check the [specific](#windows-and-macos-support) readme part.

## How to use it

Expand All @@ -24,7 +24,7 @@ jobs:
uses: actions/checkout@v2
- name: Setup Bats and bats libs
id: setup-bats
uses: bats-core/bats-action@2.0.0
uses: bats-core/bats-action@3.0.0
- name: My test
shell: bash
env:
Expand All @@ -36,7 +36,7 @@ jobs:
By default the action will pass the `BATS_LIB_PATH` value as output `lib-path`.
You can use it like the below example and load the libraries in your tests with:

``bash
```bash
_tests_helper() {
export BATS_LIB_PATH=${BATS_LIB_PATH:-"/usr/lib"}
bats_load_library bats-support
Expand All @@ -48,7 +48,7 @@ _tests_helper() {

## Libraries Path

For each of the Bats libraries, you can choose to install them in the default location (`/usr/lib/bats-<lib-name>`) or specify a custom path.
For each of the Bats libraries, you can choose to install them in the default location (`/usr/lib/bats-<lib-name>` for linux) or specify a custom path.

For example, if you want to install `bats-support` in the `./test/bats-support` directory, you can configure it as follows:

Expand All @@ -66,14 +66,15 @@ For example, if you want to install `bats-support` in the `./test/bats-support`
## About Caching

The caching mechanism for the `bats binary` is always available. However, the caching for the `bats libraries` is dependent on the location of each library path. If a library is located within the $HOME directory, caching is supported. Conversely, if a library is located outside the $HOME directory (which is the default location per each library), caching is not supported. This is due to a known limitation with sudo and the cache action, as detailed in this GitHub issue: https://github.com/actions/toolkit/issues/946.
**If you want to cache the libraries you must install them inside HOME directory**
For instance:

**If you want to cache bats libraries you must install them inside HOME directory**.
For instance this is an example that will use the github workspace handle (works for linux/win/mac):

```yaml
[...]
- name: Setup Bats and bats libs
id: setup-bats
uses: bats-core/bats-action@2.0.0
uses: bats-core/bats-action@3.0.0
with:
support-path: "${{ github.workspace }}/tests/bats-support"
assert-path: "${{ github.workspace }}/tests/bats-assert"
Expand All @@ -82,6 +83,17 @@ For instance:
[...]
```

## Windows and macos support

* Macos is fully supported for both default path and custom home path, just be aware that under `/usr` only `/usr/local/` is writable,
the rest is read only (you may consider to use an home path leverage the cache).
* default libraries installation: `/usr/local/lib`
* default temp directory (for dev testing): `/tmp`
* Windows is fully supported as well, however they may be some hiccup around the libraries installation in another drive that is not `C:`.
Please report any issue.
* default libraries installation: `/c/Users/runneradmin`
* default temp directory (for dev testing): `$HOME/AppData/Local/Temp`

## Inputs

| Key | Default | Required | Description |
Expand Down Expand Up @@ -114,3 +126,5 @@ For instance:
| assert-installed | True/False if bats-assert has been installed |
| detik-installed | True/False if bats-detik has been installed |
| file-installed | True/False if bats-file has been installed |
| lib-path | Bats lib path to use to load the libraries |
| tmp-path | Temporary path with each library tests |
2 changes: 1 addition & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ outputs:
description: "Bats lib path to use to load the libraries"
value: ${{ steps.libpath.outputs.libpath }}
tmp-path:
description: "Bats lib path to use to load the libraries"
description: "Temporary path with each library tests"
value: ${{ steps.set-paths.outputs.tmp-path }}

runs:
Expand Down

0 comments on commit cb3c9e6

Please sign in to comment.