Adding test to test.yml github action #43
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test cronned-rclone | |
on: | |
push: | |
pull_request: | |
branches: [ master ] | |
env: | |
DOCKER_IMAGE_TAG: adnanjaw/cronned-rclone:test | |
jobs: | |
docker-image-test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set Up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build And Export Testing Image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
load: true | |
push: false | |
tags: '${{ env.DOCKER_IMAGE_TAG }}' | |
- name: Test Ofelia (with config mount) | |
run: | | |
# Create a dummy ofelia config file for testing | |
echo '[job-exec "example"]' > ofelia.ini | |
echo 'schedule = "@every 10s"' >> ofelia.ini | |
echo 'command = "/bin/echo Hello Ofelia"' >> ofelia.ini | |
# Run the container in detached mode | |
docker run --name cronned-rclone \ | |
-v /var/run/docker.sock:/var/run/docker.sock:ro \ | |
-v $PWD/ofelia.ini:/config/ofelia.ini \ | |
-d ${{ env.DOCKER_IMAGE_TAG }} daemon --config=/config/ofelia.ini | |
# Wait for 10 seconds | |
sleep 10 | |
# Check logs for "Hello Ofelia" | |
if docker logs cronned-rclone | grep -q "Hello Ofelia"; then | |
echo "Output found: Hello Ofelia" | |
else | |
echo "Expected output not found" | |
docker logs cronned-rclone # Print logs for debugging | |
exit 1 # Fail the job | |
fi | |
- name: Test Ofelia (with labels) | |
run: | | |
# Run the container in detached mode | |
docker run --name cronned-rclone \ | |
-v /var/run/docker.sock:/var/run/docker.sock:ro \ | |
-v ${PWD}/rclone/rclone.conf:/config/rclone/rclone.conf \ | |
-v ${PWD}/rclone/logs:/logs \ | |
-v ${PWD}/rclone/data:/data \ | |
-v ${PWD}/test.txt:/tmp/test.txt \ | |
--label ofelia.enabled=true \ | |
--label ofelia.job-local.example.schedule="@every 2s" \ | |
--label ofelia.job-local.example.command="/bin/echo 'Hello Ofelia'" \ | |
-d ${{ env.DOCKER_IMAGE_TAG }} daemon --docker | |
# Wait for 3 seconds | |
sleep 10 | |
# Check logs for "Hello Ofelia" | |
if docker logs cronned-rclone | grep -q "Hello Ofelia"; then | |
echo "Output found: Hello Ofelia" | |
else | |
echo "Expected output not found" | |
docker logs cronned-rclone # Print logs for debugging | |
exit 1 # Fail the job | |
fi | |