diff --git a/actions/actions.sh b/actions/actions.sh index 0b505080..bb21e8a1 100755 --- a/actions/actions.sh +++ b/actions/actions.sh @@ -147,6 +147,10 @@ function test_actions() { run actions_verify_example $example done + if dpkg --compare-versions $runner_version ge 6.3.0; then + run actions_verify_example cache-proxy + fi + if dpkg --compare-versions $version lt 7.1; then for example in cron; do run actions_verify_example $example diff --git a/actions/example-cache-proxy/getter/.forgejo/workflows/get.yml b/actions/example-cache-proxy/getter/.forgejo/workflows/get.yml new file mode 100644 index 00000000..33c5f4af --- /dev/null +++ b/actions/example-cache-proxy/getter/.forgejo/workflows/get.yml @@ -0,0 +1,25 @@ +on: [push] + +jobs: + build: + runs-on: docker + container: + image: code.forgejo.org/oci/node:20-bookworm + steps: + - name: cache restore + id: cachestep + uses: https://code.forgejo.org/actions/cache/restore@v4 + with: + path: | + /usr/local/bin/something + key: thecoolsecretcachekey + + - name: verify something + run: | + set -x + test SOMETHING = $(cat /usr/local/bin/something) + + - name: cache hit + run: | + set -x + test "${{ steps.cachestep.outputs.cache-hit }}" = true diff --git a/actions/example-cache-proxy/run.sh b/actions/example-cache-proxy/run.sh new file mode 100644 index 00000000..a4b15599 --- /dev/null +++ b/actions/example-cache-proxy/run.sh @@ -0,0 +1,22 @@ +source $EXAMPLE_DIR/../../lib/lib.sh + +api=$url/api/v1 +repostorer=root/example-cache-proxy-storer +repogetter=root/example-cache-proxy-getter + +function main() { + forgejo-curl.sh api_json -X DELETE $api/repos/$repostorer >&/dev/null || true + forgejo-curl.sh api_json -X DELETE $api/repos/$repogetter >&/dev/null || true + + forgejo-test-helper.sh push_workflow actions/example-$example/storer $url root example-$example-storer setup-forgejo $token + local shastorer=$(forgejo-test-helper.sh branch_tip $url $repostorer main) + + forgejo-test-helper.sh wait_success $url $repostorer $shastorer + + forgejo-test-helper.sh push_workflow actions/example-$example/getter $url root example-$example-getter setup-forgejo $token + local shagetter=$(forgejo-test-helper.sh branch_tip $url $repogetter main) + + forgejo-test-helper.sh wait_failure $url $repogetter $shagetter +} + +main diff --git a/actions/example-cache-proxy/runner-config.yaml b/actions/example-cache-proxy/runner-config.yaml new file mode 100644 index 00000000..851c2c2a --- /dev/null +++ b/actions/example-cache-proxy/runner-config.yaml @@ -0,0 +1,29 @@ +log: + level: debug + +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-proxy/setup.sh b/actions/example-cache-proxy/setup.sh new file mode 100755 index 00000000..9c1f5adf --- /dev/null +++ b/actions/example-cache-proxy/setup.sh @@ -0,0 +1 @@ +FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload diff --git a/actions/example-cache-proxy/storer/.forgejo/workflows/store.yml b/actions/example-cache-proxy/storer/.forgejo/workflows/store.yml new file mode 100644 index 00000000..525334af --- /dev/null +++ b/actions/example-cache-proxy/storer/.forgejo/workflows/store.yml @@ -0,0 +1,17 @@ +on: [push] + +jobs: + build: + runs-on: docker + container: + image: code.forgejo.org/oci/node:20-bookworm + steps: + - 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: thecoolsecretcachekey diff --git a/actions/example-cache-proxy/teardown.sh b/actions/example-cache-proxy/teardown.sh new file mode 100755 index 00000000..b410c513 --- /dev/null +++ b/actions/example-cache-proxy/teardown.sh @@ -0,0 +1 @@ +forgejo-runner.sh reload