actions: test cache/{restore,save}@v4 support
This commit is contained in:
parent
dca3641cf3
commit
8b3c0a55e7
5 changed files with 84 additions and 1 deletions
|
@ -105,7 +105,7 @@ function test_actions() {
|
||||||
done
|
done
|
||||||
fi
|
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
|
run actions_verify_example $example
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
51
actions/example-cache/.forgejo/workflows/test.yml
Normal file
51
actions/example-cache/.forgejo/workflows/test.yml
Normal file
|
@ -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
|
30
actions/example-cache/runner-config.yaml
Normal file
30
actions/example-cache/runner-config.yaml
Normal file
|
@ -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:
|
1
actions/example-cache/setup.sh
Executable file
1
actions/example-cache/setup.sh
Executable file
|
@ -0,0 +1 @@
|
||||||
|
FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload
|
1
actions/example-cache/teardown.sh
Executable file
1
actions/example-cache/teardown.sh
Executable file
|
@ -0,0 +1 @@
|
||||||
|
forgejo-runner.sh reload
|
Loading…
Add table
Reference in a new issue