forked from aklivity/zilla
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
116 additions
and
43 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
name: Reusable Workflow for running tests | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
example-dir: | ||
required: true | ||
description: Directory name for the example to test | ||
type: string | ||
zilla-image-tag: | ||
default: latest | ||
description: Zilla Image tag | ||
type: string | ||
zilla-image-artifact-name: | ||
default: zilla-image-artifact | ||
description: Artifact name for a Zilla Image | ||
type: string | ||
|
||
workflow_call: | ||
inputs: | ||
example-dir: | ||
required: true | ||
type: string | ||
zilla-image-tag: | ||
type: string | ||
zilla-image-artifact-name: | ||
type: string | ||
|
||
jobs: | ||
runner: | ||
runs-on: ubuntu-latest | ||
env: | ||
ZILLA_VERSION: ${{ inputs.zilla-image-tag }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: aklivity/zilla-examples | ||
ref: refs/heads/example-startup-compose # change to main | ||
sparse-checkout: ${{ inputs.example-dir }} | ||
|
||
- name: Cache Docker images. | ||
if: ${{ hashFiles(format('{0}/compose.yaml', inputs.example-dir)) != '' }} | ||
uses: ScribeMD/[email protected] | ||
with: | ||
key: docker-${{ runner.os }}-${{ inputs.example-dir }}-${{ hashFiles(format('{0}/compose.yaml', inputs.example-dir)) }} | ||
|
||
- name: Download artifact | ||
if: ${{ inputs.zilla-image-artifact-name != '' }} | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ inputs.zilla-image-artifact-name }} | ||
path: /tmp | ||
|
||
- name: Load image | ||
if: ${{ inputs.zilla-image-artifact-name != '' }} | ||
run: | | ||
docker load --input /tmp/${{ inputs.zilla-image-artifact-name }}.tar | ||
docker image ls -a | ||
- name: Setup | ||
run: ./startup.sh ${{ inputs.example-dir }} | ||
- name: Wait for Zilla to be healthy | ||
working-directory: ${{ inputs.example-dir }} | ||
run: timeout 60s sh -c 'until docker compose ps zilla --format "{{.Name}} {{.Health}}" | grep -q healthy; do echo "Waiting for container to be healthy..."; sleep 2; done' | ||
|
||
- name: Execute Test | ||
if: ${{ hashFiles(format('{0}/test.sh', inputs.example-dir)) != '' }} | ||
working-directory: ${{ inputs.example-dir }} | ||
run: | | ||
set -o pipefail | ||
./test.sh | tee $GITHUB_STEP_SUMMARY | ||
- name: Collect docker logs on failure | ||
if: failure() | ||
uses: jwalton/gh-docker-logs@v2 | ||
with: | ||
dest: "./logs" | ||
- name: Tar logs | ||
if: failure() | ||
run: tar cvzf ./logs.tgz ./logs | ||
- name: Upload logs to GitHub | ||
if: failure() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ inputs.example-dir }}_logs.tgz | ||
path: ./logs.tgz | ||
|
||
- name: Teardown | ||
if: always() && ${{ hashFiles(format('{0}/teardown.sh', inputs.example-dir)) != '' }} | ||
working-directory: ${{ inputs.example-dir }} | ||
run: ./teardown.sh | ||
|