end-to-end/actions/example-service/.forgejo/workflows/test.yml
Earl Warren be033071a4
All checks were successful
/ build (pull_request) Successful in 2m3s
/ packages (pull_request) Successful in 7m18s
/ actions (pull_request) Successful in 18m10s
/ actions-docs (map[branch:next forgejo:https://codeberg.org owner:forgejo-experimental version:7.0]) (pull_request) Has been skipped
/ actions-docs (map[forgejo:https://codeberg.org owner:forgejo version:1.21]) (pull_request) Has been skipped
/ upgrade and storage (pull_request) Successful in 12m21s
actions: services: cover the case when no container is specified
When the container for running the steps is specificied, it is setup
differently than when it is implicit. This test adds coverage for both
instead of running all examples with an explicitly specified container
image.
2024-03-24 10:51:02 +01:00

76 lines
2.1 KiB
YAML

on: [push]
jobs:
#
# No volume involved & the container is implicit
#
simple-no-container:
runs-on: docker
services:
pgsql:
image: code.forgejo.org/oci/postgres:15
env:
POSTGRES_DB: test
POSTGRES_PASSWORD: postgres
steps:
- run: |
apt-get update -qq
apt-get install -y -qq postgresql-client
PGPASSWORD=postgres psql -h pgsql -U postgres -c '\dt' test
#
# No volume involved & the container is explicit
#
simple:
runs-on: docker
container:
image: code.forgejo.org/oci/debian:bookworm
services:
pgsql:
image: code.forgejo.org/oci/postgres:15
env:
POSTGRES_DB: test
POSTGRES_PASSWORD: postgres
steps:
- run: |
apt-get update -qq
apt-get install -y -qq postgresql-client
PGPASSWORD=postgres psql -h pgsql -U postgres -c '\dt' test
#
# A --volume option will expose the volume from the docker host to the job
#
volume-on-step:
needs: [simple]
runs-on: docker
container:
image: code.forgejo.org/oci/debian:bookworm
options: "--volume /srv/example-service-volume-valid:/srv/example-service-volume-valid --volume /srv/example-service-volume-invalid:/srv/example-service-volume-invalid"
steps:
- run: |
test -f /srv/example-service-volume-valid
! test -f /srv/example-service-volume-invalid
#
# A --volume option will expose the volume from the docker host to the service
#
volume-on-service:
needs: [volume-on-step]
runs-on: docker
container:
image: code.forgejo.org/oci/debian:bookworm
options: "--volume /srv/example-service-volume-valid:/srv/example-service-volume-valid"
services:
myservice:
image: code.forgejo.org/oci/debian:bookworm
options: "--volume /srv/example-service-volume-valid:/srv/example-service-volume-valid"
cmd: ["bash", "-c", "echo -n SUCCESS > /srv/example-service-volume-valid ; sleep infinity"]
steps:
- run: |
set -x
f=/srv/example-service-volume-valid
test -f $f
test $(cat $f) = SUCCESS