Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail steps/tests/suites when expressions throw exceptions #15

Merged
merged 9 commits into from
Oct 8, 2024
8 changes: 4 additions & 4 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

- name: Setup Fixtures
run: |
docker-compose -f examples/docker-compose.yaml up -d
docker compose -f examples/docker-compose.yaml up -d

- name: Run Intro Examples
run: |
Expand All @@ -50,7 +50,7 @@ jobs:
-v $(pwd)/examples:/app/examples \
dctest --results-file /app/examples/results.json examples /app/examples/00-intro.yaml \
|| true
jq --exit-status '[.pass == 4, .fail == 0] | all' examples/results.json
jq --exit-status '[.pass == 5, .fail == 0] | all' examples/results.json

- name: Run Intro + Fail Examples with --continue-on-error
run: |
Expand All @@ -61,7 +61,7 @@ jobs:
-v $(pwd)/examples:/app/examples \
dctest --continue-on-error --results-file /app/examples/results.json examples /app/examples/00-intro.yaml /app/examples/01-fails.yaml \
|| true
jq --exit-status '[.pass == 5, .fail == 3] | all' examples/results.json
jq --exit-status '[.pass == 6, .fail == 4] | all' examples/results.json

- name: Run Dependency Examples
run: |
Expand All @@ -78,4 +78,4 @@ jobs:
- name: Setup Fixtures
if: always()
run: |
docker-compose -f examples/docker-compose.yaml down -t 1 --remove-orphans
docker compose -f examples/docker-compose.yaml down -t 1 --remove-orphans
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16 as build
FROM node:16 AS build

RUN apt-get -y update && \
apt-get -y install default-jdk-headless
Expand All @@ -20,7 +20,7 @@ RUN cd /app && \
chmod +x build/*.js


FROM node:16-slim as run
FROM node:16-slim AS run

COPY --from=build /app/ /app/
ADD schema.yaml /app/
Expand Down
19 changes: 18 additions & 1 deletion examples/00-intro.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ tests:
FOO: bar
run: |
[ "${FOO}" == "bar" ]
repeat: { retries: 3, interval: '1s' }
- exec: node1
if: success()
run: echo "This will be run!"
Expand Down Expand Up @@ -69,3 +68,21 @@ tests:
expect:
- step.stdout != "2"
- step.stdout == "3"

repeat:
name: Repeat test
steps:
- exec: node1
run: rm -f repeat-test-file
- exec: node1
repeat: { retries: 2, interval: '1s' }
run: |
if [ ! -f repeat-test-file ]; then
touch repeat-test-file
else
echo -n 'Repeated successfully'
fi
expect:
- step.stdout == "Repeated successfully"
- exec: node1
run: rm -f repeat-test-file
8 changes: 8 additions & 0 deletions examples/01-fails.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,11 @@ tests:
steps:
- exec: node2
run: /bin/true

fail-expressions:
name: Test thrown exception in expressions
steps:
- exec: node1
env:
FOO: ${{ throw("Intentional Failure") }}
run: /bin/true
6 changes: 3 additions & 3 deletions schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ additionalProperties: false
required: []
properties:
env: { "$ref": "#/$defs/env" }
name: { type: string }
name: { type: string, expression: InterpolatedText }
tests:
type: object
additionalProperties:
Expand All @@ -22,7 +22,7 @@ properties:
required: []
properties:
env: { "$ref": "#/$defs/env" }
name: { type: string }
name: { type: string, expression: InterpolatedText }
depends:
oneOf:
- type: string
Expand All @@ -44,7 +44,7 @@ properties:
oneOf:
- { type: string, expression: Expression }
- { type: array, items: { type: string, expression: Expression } }
name: { type: string }
name: { type: string, expression: InterpolatedText }
if: { type: string, expression: Expression, default: "success()" }
index: { type: integer }
run:
Expand Down
Loading