Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test

on:
push:
workflow_dispatch:

jobs:
smoke-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# The datacontract container runs as a non-root user and writes the JUnit
# report into the workspace, see README.
- name: Make workspace writable for datacontract container
run: chmod -R a+rwX "$GITHUB_WORKSPACE"
- name: Run action against local test contract
uses: ./
with:
location: tests/datacontract.yaml
server: production
junit-test-report: TEST-datacontract.xml
- name: Assert JUnit report was written
run: |
test -s TEST-datacontract.xml
grep -q 'failures="0"' TEST-datacontract.xml
cat TEST-datacontract.xml
23 changes: 14 additions & 9 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,18 @@ inputs:
runs:
using: 'docker'
image: 'docker://datacontract/cli:latest'
entrypoint: /bin/sh
# The image has no shell, so the CLI is invoked directly. The runner passes empty
# args as literal "" (it does not drop them) and the CLI rejects an empty --publish
# value, so the publish option is a single `--publish=<url>` arg that degrades to
# `--no-logs` (the CLI's default behavior anyway) when the input is unset.
entrypoint: datacontract
args:
- -c
- >-
datacontract test
--server '${{ inputs.server }}'
--output-format junit
--output '${{ inputs.junit-test-report }}'
${{ inputs.publish != '' && format('--publish ''{0}''', inputs.publish) || '' }}
'${{ inputs.location }}'
- test
- --server
- ${{ inputs.server }}
- --output-format
- junit
- --output
- ${{ inputs.junit-test-report }}
- ${{ inputs.publish != '' && format('--publish={0}', inputs.publish) || '--no-logs' }}
- ${{ inputs.location }}
4 changes: 4 additions & 0 deletions tests/data/orders.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
order_id,amount
1,10.50
2,20.00
3,7.25
20 changes: 20 additions & 0 deletions tests/datacontract.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
dataContractSpecification: 1.1.0
id: datacontract-action-smoke-test
info:
title: Smoke test contract for the GitHub Action
version: 1.0.0
servers:
production:
type: local
path: tests/data/orders.csv
format: csv
models:
orders:
type: table
fields:
order_id:
type: string
required: true
unique: true
amount:
type: decimal
Loading