|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 2 | +# contributor license agreements. See the NOTICE file distributed with |
| 3 | +# this work for additional information regarding copyright ownership. |
| 4 | +# The ASF licenses this file to You under the Apache License, Version 2.0 |
| 5 | +# (the "License"); you may not use this file except in compliance with |
| 6 | +# the License. You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +name: "Docker Tests using Distribution Image" |
| 17 | +on: |
| 18 | + workflow_call: |
| 19 | + |
| 20 | +jobs: |
| 21 | + run-docker-tests: |
| 22 | + name: Run Docker tests |
| 23 | + runs-on: ubuntu-latest |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v4 |
| 26 | + - name: Set Docker image env var |
| 27 | + run: echo "DRUID_DIST_IMAGE_NAME=apache/druid:docker-tests" >> $GITHUB_ENV |
| 28 | + - name: Build the Docker image |
| 29 | + run: DOCKER_BUILDKIT=1 docker build -t $DRUID_DIST_IMAGE_NAME -f distribution/docker/Dockerfile . |
| 30 | + - name: Save Docker image to archive |
| 31 | + run: | |
| 32 | + echo "Saving image $DRUID_DIST_IMAGE_NAME in archive druid-dist-container.tar.gz" |
| 33 | + docker save "$DRUID_DIST_IMAGE_NAME" | gzip > druid-dist-container.tar.gz |
| 34 | + - name: Stop and remove Druid Docker containers |
| 35 | + run: | |
| 36 | + echo "Force stopping all Druid containers and pruning" |
| 37 | + docker ps -aq --filter "ancestor=apache/druid" | xargs -r docker rm -f |
| 38 | + docker system prune -af --volumes |
| 39 | + - name: Load Docker image |
| 40 | + run: | |
| 41 | + docker load --input druid-dist-container.tar.gz |
| 42 | + docker images |
| 43 | + - name: Setup Java |
| 44 | + uses: actions/setup-java@v4 |
| 45 | + with: |
| 46 | + distribution: 'zulu' |
| 47 | + java-version: 17 |
| 48 | + cache: 'maven' |
| 49 | + - name: Run Docker tests |
| 50 | + id: run-it |
| 51 | + run: .github/scripts/run_docker-tests |
| 52 | + timeout-minutes: 60 |
| 53 | + |
| 54 | + - name: Collect docker logs on failure |
| 55 | + if: ${{ failure() && steps.run-it.conclusion == 'failure' }} |
| 56 | + run: | |
| 57 | + mkdir docker-logs |
| 58 | + for c in $(docker ps -a --format="{{.Names}}") |
| 59 | + do |
| 60 | + docker logs $c > ./docker-logs/$c.log |
| 61 | + done |
| 62 | +
|
| 63 | + - name: Tar docker logs |
| 64 | + if: ${{ failure() && steps.run-it.conclusion == 'failure' }} |
| 65 | + run: tar cvzf ./docker-logs.tgz ./docker-logs |
| 66 | + |
| 67 | + - name: Upload docker logs to GitHub |
| 68 | + if: ${{ failure() && steps.run-it.conclusion == 'failure' }} |
| 69 | + uses: actions/upload-artifact@v4 |
| 70 | + with: |
| 71 | + name: failure-docker-logs |
| 72 | + path: docker-logs.tgz |
| 73 | + |
| 74 | + - name: Collect surefire reports on failure |
| 75 | + if: ${{ failure() && steps.run-it.conclusion == 'failure' }} |
| 76 | + run: | |
| 77 | + tar cvzf ./surefire-logs.tgz ./embedded-tests/target/surefire-reports |
| 78 | +
|
| 79 | + - name: Upload surefire reports to GitHub |
| 80 | + if: ${{ failure() && steps.run-it.conclusion == 'failure' }} |
| 81 | + uses: actions/upload-artifact@v4 |
| 82 | + with: |
| 83 | + name: failure-surefire-logs |
| 84 | + path: surefire-logs.tgz |
0 commit comments