mirror of
https://github.com/crazy-max/diun.git
synced 2026-01-05 12:25:34 +01:00
Add e2e tests (#471)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
17
.github/workflows/build.yml
vendored
17
.github/workflows/build.yml
vendored
@@ -39,6 +39,10 @@ jobs:
|
||||
uses: docker/bake-action@v1
|
||||
with:
|
||||
targets: validate
|
||||
pull: true
|
||||
set: |
|
||||
*.cache-from=type=gha,scope=diun-validate
|
||||
*.cache-to=type=gha,scope=diun-validate,mode=max
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -56,6 +60,10 @@ jobs:
|
||||
uses: docker/bake-action@v1
|
||||
with:
|
||||
targets: test
|
||||
pull: true
|
||||
set: |
|
||||
*.cache-from=type=gha,scope=diun-test
|
||||
*.cache-to=type=gha,scope=diun-test,mode=max
|
||||
-
|
||||
name: Upload coverage
|
||||
uses: codecov/codecov-action@v2
|
||||
@@ -117,6 +125,10 @@ jobs:
|
||||
uses: docker/bake-action@v1
|
||||
with:
|
||||
targets: artifact-all
|
||||
pull: true
|
||||
set: |
|
||||
*.cache-from=type=gha,scope=diun-artifact
|
||||
*.cache-to=type=gha,scope=diun-artifact,mode=max
|
||||
-
|
||||
name: Move artifacts
|
||||
run: |
|
||||
@@ -136,7 +148,12 @@ jobs:
|
||||
./docker-bake.hcl
|
||||
${{ steps.meta.outputs.bake-file }}
|
||||
targets: image-all
|
||||
pull: true
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
set: |
|
||||
*.cache-from=type=gha,scope=diun-artifact
|
||||
*.cache-from=type=gha,scope=diun-image
|
||||
*.cache-to=type=gha,scope=diun-image,mode=max
|
||||
-
|
||||
name: GitHub Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
|
||||
1
.github/workflows/docs.yml
vendored
1
.github/workflows/docs.yml
vendored
@@ -36,6 +36,7 @@ jobs:
|
||||
uses: docker/bake-action@v1
|
||||
with:
|
||||
targets: docs
|
||||
pull: true
|
||||
-
|
||||
name: Check GitHub Pages status
|
||||
uses: crazy-max/ghaction-github-status@v2
|
||||
|
||||
107
.github/workflows/e2e.yml
vendored
Normal file
107
.github/workflows/e2e.yml
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
name: e2e
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'v*'
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
pull_request:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'v*'
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
|
||||
env:
|
||||
BUILD_TAG: 'crazymax/diun:local'
|
||||
CONTAINER_NAME: 'diun'
|
||||
RUNNING_TIMEOUT: '240'
|
||||
RUNNING_LOG_CHECK: 'Next run in'
|
||||
|
||||
jobs:
|
||||
e2e:
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
redis:
|
||||
image: redis:6.2.3-alpine
|
||||
cloudflared:
|
||||
image: crazymax/cloudflared:latest
|
||||
options: >-
|
||||
--label "diun.enable=true"
|
||||
--label "diun.watch_repo=true"
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- folder: docker1
|
||||
loglevel: debug
|
||||
- folder: docker2
|
||||
loglevel: info
|
||||
- folder: docker3
|
||||
loglevel: info
|
||||
- folder: dockerfile1
|
||||
loglevel: debug
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
-
|
||||
name: Build
|
||||
uses: docker/bake-action@v1
|
||||
with:
|
||||
targets: image-local
|
||||
pull: true
|
||||
set: |
|
||||
*.cache-from=type=gha,scope=diun-image
|
||||
*.cache-from=type=gha,scope=diun-e2e-${{ matrix.folder }}
|
||||
*.cache-to=type=gha,scope=diun-e2e-${{ matrix.folder }},mode=max
|
||||
-
|
||||
name: Start container
|
||||
run: |
|
||||
volFlags="-v $(pwd)/test/${{ matrix.folder }}/diun.yml:/diun.yml:ro"
|
||||
volFlags="-v /var/run/docker.sock:/var/run/docker.sock ${volFlags}"
|
||||
if [ -d "$(pwd)/test/${{ matrix.folder }}/mount" ]; then
|
||||
volFlags="-v $(pwd)/test/${{ matrix.folder }}/mount:/mount ${volFlags}"
|
||||
fi
|
||||
docker run -d --name ${{ env.CONTAINER_NAME }} ${volFlags} \
|
||||
-e "TZ=Europe/Paris" \
|
||||
-e "LOG_LEVEL=${{ matrix.loglevel }}" \
|
||||
${{ env.BUILD_TAG }}
|
||||
-
|
||||
name: Test run
|
||||
run: |
|
||||
TIMEOUT=$((SECONDS + ${{ env.RUNNING_TIMEOUT }}))
|
||||
while read LOGLINE; do
|
||||
echo ${LOGLINE}
|
||||
if [[ ${LOGLINE} == *"${{ env.RUNNING_LOG_CHECK }}"* ]]; then
|
||||
echo "🎉 Container up!"
|
||||
break
|
||||
fi
|
||||
if [[ $SECONDS -gt ${TIMEOUT} ]]; then
|
||||
>&2 echo "❌ Failed to run ${{ env.CONTAINER_NAME }} container"
|
||||
exit 1
|
||||
fi
|
||||
done < <(docker logs -f ${{ env.CONTAINER_NAME }} 2>&1)
|
||||
|
||||
CONTAINER_STATUS=$(docker container inspect --format "{{.State.Status}}" ${{ env.CONTAINER_NAME }})
|
||||
if [[ ${CONTAINER_STATUS} != "running" ]]; then
|
||||
>&2 echo "❌ Container ${{ env.CONTAINER_NAME }} returned status '$CONTAINER_STATUS'"
|
||||
exit 1
|
||||
fi
|
||||
-
|
||||
name: List images in db
|
||||
run: |
|
||||
docker exec -t ${{ env.CONTAINER_NAME }} diun image list
|
||||
-
|
||||
name: Container logs
|
||||
if: always()
|
||||
run: |
|
||||
docker logs ${{ env.CONTAINER_NAME }}
|
||||
docker rm -f ${{ env.CONTAINER_NAME }} > /dev/null 2>&1 || true
|
||||
Reference in New Issue
Block a user