Skip to content

Commit 2e8d136

Browse files
authored
Merge pull request #3 from datacontract/fix/shell-less-image
Invoke the CLI directly instead of through a shell
2 parents 057912d + a833cc5 commit 2e8d136

4 files changed

Lines changed: 64 additions & 9 deletions

File tree

‎.github/workflows/test.yml‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
workflow_dispatch:
6+
7+
jobs:
8+
smoke-test:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
# The datacontract container runs as a non-root user and writes the JUnit
13+
# report into the workspace, see README.
14+
- name: Make workspace writable for datacontract container
15+
run: chmod -R a+rwX "$GITHUB_WORKSPACE"
16+
- name: Run action against local test contract
17+
uses: ./
18+
with:
19+
location: tests/datacontract.yaml
20+
server: production
21+
junit-test-report: TEST-datacontract.xml
22+
- name: Assert JUnit report was written
23+
run: |
24+
test -s TEST-datacontract.xml
25+
grep -q 'failures="0"' TEST-datacontract.xml
26+
cat TEST-datacontract.xml

‎action.yml‎

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,18 @@ inputs:
2020
runs:
2121
using: 'docker'
2222
image: 'docker://datacontract/cli:latest'
23-
entrypoint: /bin/sh
23+
# The image has no shell, so the CLI is invoked directly. The runner passes empty
24+
# args as literal "" (it does not drop them) and the CLI rejects an empty --publish
25+
# value, so the publish option is a single `--publish=<url>` arg that degrades to
26+
# `--no-logs` (the CLI's default behavior anyway) when the input is unset.
27+
entrypoint: datacontract
2428
args:
25-
- -c
26-
- >-
27-
datacontract test
28-
--server '${{ inputs.server }}'
29-
--output-format junit
30-
--output '${{ inputs.junit-test-report }}'
31-
${{ inputs.publish != '' && format('--publish ''{0}''', inputs.publish) || '' }}
32-
'${{ inputs.location }}'
29+
- test
30+
- --server
31+
- ${{ inputs.server }}
32+
- --output-format
33+
- junit
34+
- --output
35+
- ${{ inputs.junit-test-report }}
36+
- ${{ inputs.publish != '' && format('--publish={0}', inputs.publish) || '--no-logs' }}
37+
- ${{ inputs.location }}

‎tests/data/orders.csv‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
order_id,amount
2+
1,10.50
3+
2,20.00
4+
3,7.25

‎tests/datacontract.yaml‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
dataContractSpecification: 1.1.0
2+
id: datacontract-action-smoke-test
3+
info:
4+
title: Smoke test contract for the GitHub Action
5+
version: 1.0.0
6+
servers:
7+
production:
8+
type: local
9+
path: tests/data/orders.csv
10+
format: csv
11+
models:
12+
orders:
13+
type: table
14+
fields:
15+
order_id:
16+
type: string
17+
required: true
18+
unique: true
19+
amount:
20+
type: decimal

0 commit comments

Comments
 (0)