-
Notifications
You must be signed in to change notification settings - Fork 30
119 lines (117 loc) · 4.24 KB
/
test-diff.yaml
File metadata and controls
119 lines (117 loc) · 4.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: diff
on:
pull_request:
push:
jobs:
oasdiff_diff:
runs-on: ubuntu-latest
name: Test diff action
steps:
- name: checkout
uses: actions/checkout@v6
- name: Running diff action
id: test_ete
uses: ./diff
with:
base: https://raw.githubusercontent.com/oasdiff/oasdiff/main/data/openapi-test1.yaml
revision: https://raw.githubusercontent.com/oasdiff/oasdiff/main/data/openapi-test3.yaml
format: 'text'
output-to-file: 'diff.txt'
- name: Test diff action output to file
run: |
if [ ! -s diff.txt ]; then
echo "Diff file doesn't exist or is empty"
exit 1
fi
oasdiff_diff_exclude_elements:
runs-on: ubuntu-latest
name: Test diff action with exclude-elements option
steps:
- name: checkout
uses: actions/checkout@v6
- name: Running diff action with exclude-elements option
id: test_exclude_elements
uses: ./diff
with:
base: 'specs/base.yaml'
revision: 'specs/base-exclude-elements.yaml'
format: 'text'
exclude-elements: 'description,title,summary'
- name: Test diff action output
run: |
delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-')
output=$(cat <<-$delimiter
${{ steps.test_exclude_elements.outputs.diff }}
$delimiter
)
if [ "$output" != "No changes" ]; then
echo "Expected output 'No changes' but got '$output'" >&2
exit 1
fi
oasdiff_diff_composed:
runs-on: ubuntu-latest
name: Test diff action with composed option
steps:
- name: checkout
uses: actions/checkout@v6
- name: Running diff action with composed option
id: test_composed
uses: ./diff
with:
base: 'specs/glob/base/*.yaml'
revision: 'specs/glob/revision/*.yaml'
format: 'text'
composed: true
- name: Test diff action output
run: |
delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-')
output=$(cat <<-$delimiter
${{ steps.test_composed.outputs.diff }}
$delimiter
)
if [[ ! "$output" =~ "Deleted Endpoints: 1" ]]; then
echo "Expected 'Deleted Endpoints: 1' to be modified in diff, instead got '$output'" >&2
exit 1
fi
oasdiff_diff_yaml_config_exclude_elements:
runs-on: ubuntu-latest
name: Test diff action picks up exclude-elements from .oasdiff.yaml
steps:
- name: checkout
uses: actions/checkout@v6
- name: Drop .oasdiff.yaml at repo root
run: |
cat > .oasdiff.yaml <<EOF
exclude-elements:
- description
- title
- summary
format: text
EOF
- name: Running diff action without exclude-elements input
id: test_yaml_exclude_elements
uses: ./diff
with:
base: 'specs/base.yaml'
revision: 'specs/base-exclude-elements.yaml'
- name: Assert diff is empty thanks to exclude-elements from .oasdiff.yaml
run: |
delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-')
output=$(cat <<-$delimiter
${{ steps.test_yaml_exclude_elements.outputs.diff }}
$delimiter
)
if [ "$output" != "No changes" ]; then
echo "Expected 'No changes' (exclude-elements from .oasdiff.yaml should filter description/title/summary) but got '$output'" >&2
exit 1
fi
# ---------------------------------------------------------------------
# pr-comment entrypoint: oasdiff exit-code tolerance.
#
# The pr-comment script wraps the oasdiff changelog invocation so a
# non-zero exit (e.g. fail-on triggered from .oasdiff.yaml) does not
# abort the script under set -e. Real failures (no output) still
# abort. These two jobs run pr-comment/entrypoint.sh directly with a
# stubbed oasdiff on PATH so we don't need a Docker image, an
# oasdiff-token, or a reachable oasdiff-service.
# ---------------------------------------------------------------------