|
36 | 36 | env:
|
37 | 37 | GITHUB_ACTOR: ${{ github.actor }}
|
38 | 38 | GITHUB_TOKEN: ${{ github.token }}
|
| 39 | + |
| 40 | + - name: Save Docker image |
| 41 | + if: success() |
| 42 | + run: | |
| 43 | + mkdir -p ~/docker-cache |
| 44 | + docker save -o ~/docker-cache/docker.tar $(docker images --format "{{.Repository}}" | grep "zilla") |
| 45 | +
|
| 46 | + - name: Cache Docker image |
| 47 | + uses: actions/cache@v4 |
| 48 | + if: success() |
| 49 | + with: |
| 50 | + path: ~/docker-cache/docker.tar |
| 51 | + key: docker-${{ runner.os }}-zilla-develop-SNAPSHOT |
| 52 | + |
39 | 53 | - name: Conditional Artifact Upload
|
40 | 54 | uses: actions/upload-artifact@v4
|
41 | 55 | if: failure()
|
|
46 | 60 | **/target/surefire-reports/
|
47 | 61 | **/target/zilla-itests/
|
48 | 62 | **/target/failsafe-reports/
|
| 63 | +
|
| 64 | + setup-examples: |
| 65 | + runs-on: ubuntu-latest |
| 66 | + needs: |
| 67 | + - build |
| 68 | + outputs: |
| 69 | + all_directories: ${{ steps.all-files.outputs.folders_no_base_path }} |
| 70 | + steps: |
| 71 | + - uses: actions/checkout@v4 |
| 72 | + with: |
| 73 | + fetch-depth: 0 |
| 74 | + |
| 75 | + - name: Get examples dirs |
| 76 | + id: all-files |
| 77 | + uses: Drafteame/list-folders-action@main |
| 78 | + with: |
| 79 | + paths: | |
| 80 | + examples |
| 81 | + omit: | |
| 82 | + ^\.github$ |
| 83 | + ^\.assets$ |
| 84 | + ^\.git$ |
| 85 | + ^\.vscode$ |
| 86 | +
|
| 87 | + testing: |
| 88 | + strategy: |
| 89 | + matrix: |
| 90 | + dir: ${{ fromJson(needs.setup-examples.outputs.all_directories) }} |
| 91 | + fail-fast: false |
| 92 | + needs: |
| 93 | + - setup-examples |
| 94 | + runs-on: ubuntu-latest |
| 95 | + env: |
| 96 | + ZILLA_VERSION: develop-SNAPSHOT |
| 97 | + steps: |
| 98 | + - name: Checkout |
| 99 | + uses: actions/checkout@v4 |
| 100 | + with: |
| 101 | + sparse-checkout: examples/${{ matrix.dir }} |
| 102 | + |
| 103 | + - name: Restore cached Docker images |
| 104 | + uses: actions/cache@v4 |
| 105 | + with: |
| 106 | + path: ~/docker-cache/docker.tar |
| 107 | + key: docker-${{ runner.os }}-zilla-develop-SNAPSHOT |
| 108 | + |
| 109 | + - name: Load cached Docker image |
| 110 | + run: | |
| 111 | + docker load -i ~/docker-cache/docker.tar |
| 112 | +
|
| 113 | + - name: Cache Docker images |
| 114 | + if: ${{ hashFiles(format('examples/{0}/compose.yaml', matrix.dir)) != '' }} |
| 115 | + |
| 116 | + with: |
| 117 | + key: docker-${{ runner.os }}-${{ matrix.dir }}-${{ hashFiles(format('examples/{0}/compose.yaml', matrix.dir)) }} |
| 118 | + |
| 119 | + - name: Start Zilla and wait for it to be healthy |
| 120 | + working-directory: examples/${{ matrix.dir }} |
| 121 | + run: docker compose up -d --wait |
| 122 | + |
| 123 | + - name: Execute Test |
| 124 | + working-directory: examples/${{ matrix.dir }} |
| 125 | + run: | |
| 126 | + set -o pipefail |
| 127 | + ./.github/test.sh | tee $GITHUB_STEP_SUMMARY |
| 128 | +
|
| 129 | + - name: Collect docker logs on failure |
| 130 | + if: failure() |
| 131 | + uses: jwalton/gh-docker-logs@v2 |
| 132 | + with: |
| 133 | + dest: "./logs" |
| 134 | + - name: Tar logs |
| 135 | + if: failure() |
| 136 | + run: tar cvzf ./logs.tgz ./logs |
| 137 | + - name: Upload logs to GitHub |
| 138 | + if: failure() |
| 139 | + uses: actions/upload-artifact@v4 |
| 140 | + with: |
| 141 | + name: ${{ matrix.dir }}_logs.tgz |
| 142 | + path: ./logs.tgz |
| 143 | + |
| 144 | + - name: Teardown |
| 145 | + if: always() && ${{ hashFiles(format('examples/{0}/teardown.sh', matrix.dir)) != '' }} |
| 146 | + working-directory: examples/${{ matrix.dir }} |
| 147 | + run: docker compose down --remove-orphans |
0 commit comments