diff --git a/actions/actions.sh b/actions/actions.sh index ac114de..e201d96 100755 --- a/actions/actions.sh +++ b/actions/actions.sh @@ -3,6 +3,8 @@ ACTIONS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +RUNNER_VERSION=v3.5.0 + function actions_verify_example() { local example=$1 @@ -68,7 +70,7 @@ function actions_setup() { actions_cleanup_example_volume export FORGEJO_RUNNER_CONFIG=$ACTIONS_DIR/runner-config.yaml - forgejo-runner.sh setup '' '' http://${HOST_PORT} + forgejo-runner.sh setup '' $RUNNER_VERSION http://${HOST_PORT} } function actions_teardown() { @@ -103,7 +105,7 @@ function test_actions() { done fi - for example in echo checkout service container expression local-action docker-action if if-fail push tag push-cancel artifacts pull-request context ; do + for example in echo cache checkout service container expression local-action docker-action if if-fail push tag push-cancel artifacts pull-request context ; do run actions_verify_example $example done diff --git a/actions/example-cache/.forgejo/workflows/test.yml b/actions/example-cache/.forgejo/workflows/test.yml new file mode 100644 index 0000000..ab37b75 --- /dev/null +++ b/actions/example-cache/.forgejo/workflows/test.yml @@ -0,0 +1,51 @@ +on: [push] + +jobs: + build: + runs-on: docker + container: + image: code.forgejo.org/oci/node:20-bookworm + steps: + - name: cache restore + id: cachestep1 + uses: https://code.forgejo.org/actions/cache/restore@v4 + with: + path: | + /usr/local/bin/something + key: cachekey + + - name: cache hit + run: | + set -x + test "${{ steps.cachestep1.outputs.cache-hit }}" != true + + - name: create something + run: echo SOMETHING > /usr/local/bin/something + + - name: cache save + uses: https://code.forgejo.org/actions/cache/save@v4 + with: + path: | + /usr/local/bin/something + key: ${{ steps.cachestep1.outputs.cache-primary-key }} + + - name: remove something + run: rm /usr/local/bin/something + + - name: cache restore + id: cachestep2 + uses: https://code.forgejo.org/actions/cache/restore@v4 + with: + path: | + /usr/local/bin/something + key: cachekey + + - name: verify something + run: | + set -x + test SOMETHING = $(cat /usr/local/bin/something) + + - name: cache hit + run: | + set -x + test "${{ steps.cachestep2.outputs.cache-hit }}" = true diff --git a/actions/example-cache/runner-config.yaml b/actions/example-cache/runner-config.yaml new file mode 100644 index 0000000..9b342f1 --- /dev/null +++ b/actions/example-cache/runner-config.yaml @@ -0,0 +1,30 @@ + +log: + level: info + +runner: + file: .runner + capacity: 1 + env_file: .env + timeout: 3h + insecure: false + fetch_timeout: 5s + fetch_interval: 2s + labels: ["docker:docker://code.forgejo.org/oci/node:20-bookworm"] + +cache: + enabled: true + dir: "/srv/example/cache" + host: "" + port: 0 + +container: + network: "bridge" + privileged: false + options: + workdir_parent: + valid_volumes: ["/srv/example"] + docker_host: "" + +host: + workdir_parent: diff --git a/actions/example-cache/setup.sh b/actions/example-cache/setup.sh new file mode 100755 index 0000000..9c1f5ad --- /dev/null +++ b/actions/example-cache/setup.sh @@ -0,0 +1 @@ +FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload diff --git a/actions/example-cache/teardown.sh b/actions/example-cache/teardown.sh new file mode 100755 index 0000000..b410c51 --- /dev/null +++ b/actions/example-cache/teardown.sh @@ -0,0 +1 @@ +forgejo-runner.sh reload