1+ name : PR testing of CLI action
2+
3+ on :
4+ pull_request :
5+ types : [ opened, synchronize, reopened, ready_for_review ]
6+
7+ jobs :
8+ test-defaults :
9+ runs-on : ubuntu-latest
10+ steps :
11+ - uses : actions/checkout@v4
12+ - name : Test GitHub Action
13+ uses : ./
14+ with :
15+ filepath : test/asyncapi.yml
16+ - name : Assert GitHub Action
17+ run : |
18+ echo "Listing all files"
19+ ls -R
20+ echo "Asserting GitHub Action"
21+ if [ -f "./output/asyncapi.md" ]; then
22+ echo "Files exist"
23+ else
24+ echo "Files do not exist:- ./output/asyncapi.md"
25+ echo "Action failed"
26+ exit 1
27+ fi
28+
29+ test-validate-success :
30+ runs-on : ubuntu-latest
31+ steps :
32+ - uses : actions/checkout@v4
33+ - name : Test GitHub Action
34+ uses : ./
35+ with :
36+ filepath : test/asyncapi.yml
37+ command : validate
38+
39+ test-custom-command :
40+ runs-on : ubuntu-latest
41+ steps :
42+ - uses : actions/checkout@v4
43+ - name : Test GitHub Action
44+ uses : ./
45+ with :
46+ # Custom command to generate models
47+ # Note: You can use command itself to generate models, but this is just an example for testing custom commands
48+ custom_command : " generate models typescript ./test/asyncapi.yml -o ./output"
49+ - name : Assert GitHub Action
50+ run : |
51+ echo "Listing all files"
52+ ls -R
53+ echo "Asserting GitHub Action"
54+ if [ -f "./output/AnonymousSchema_1.ts" ]; then
55+ echo "Models have been generated"
56+ else
57+ echo "Models have not been generated"
58+ echo "Action failed"
59+ exit 1
60+ fi
61+
62+ test-custom-output :
63+ runs-on : ubuntu-latest
64+ steps :
65+ - uses : actions/checkout@v4
66+ - name : Test GitHub Action
67+ uses : ./
68+ with :
69+ filepath : test/asyncapi.yml
70+ output : custom-output
71+ - name : Assert GitHub Action
72+ run : |
73+ echo "Listing all files"
74+ ls -R
75+ echo "Asserting GitHub Action"
76+ if [ -f "./custom-output/asyncapi.md" ]; then
77+ echo "Files exist"
78+ else
79+ echo "Files do not exist:- ./custom-output/asyncapi.md"
80+ echo "Action failed"
81+ exit 1
82+ fi
83+
84+ test-file-not-found :
85+ runs-on : ubuntu-latest
86+ steps :
87+ - uses : actions/checkout@v4
88+ - name : Test GitHub Action
89+ id : test
90+ uses : ./
91+ with :
92+ filepath : non_existent_file.yml
93+ continue-on-error : true
94+ - name : Check for failure
95+ run : |
96+ if [ "${{ steps.test.outcome }}" == "success" ]; then
97+ echo "Test Failure: non_existent_file.yml should throw an error but did not"
98+ exit 1
99+ else
100+ echo "Test Success: non_existent_file.yml threw an error as expected"
101+ fi
102+
103+ test-invalid-input :
104+ runs-on : ubuntu-latest
105+ steps :
106+ - uses : actions/checkout@v4
107+ - name : Test GitHub Action
108+ id : test
109+ uses : ./
110+ with :
111+ filepath : test/asyncapi.yml
112+ command : generate # No template or language specified
113+ template : ' ' # Empty string
114+ continue-on-error : true
115+ - name : Check for failure
116+ run : |
117+ if [ "${{ steps.test.outcome }}" == "success" ]; then
118+ echo "Test Failure: generate command should throw an error as no template or language specified but did not"
119+ exit 1
120+ else
121+ echo "Test Success: generate command threw an error as expected"
122+ fi
123+
124+ test-optimize :
125+ runs-on : ubuntu-latest
126+ steps :
127+ - uses : actions/checkout@v4
128+ - name : Test GitHub Action
129+ uses : ./
130+ with :
131+ filepath : test/unoptimized.yml
132+ command : optimize
133+ parameters : ' -o new-file --no-tty'
134+ - name : Assert GitHub Action
135+ run : |
136+ echo "Listing all files"
137+ ls -R
138+ echo "Asserting GitHub Action"
139+ if [ -f "./test/unoptimized_optimized.yml" ]; then
140+ echo "The specified file has been optimized"
141+ else
142+ echo "The specified file has not been optimized"
143+ echo "Action failed"
144+ exit 1
145+ fi
146+
147+ test-bundle :
148+ runs-on : ubuntu-latest
149+ steps :
150+ - uses : actions/checkout@v4
151+ - name : Make output directory
152+ run : mkdir -p ./output/bundle
153+ - name : Test GitHub Action
154+ uses : ./
155+ with :
156+ custom_command : ' bundle ./test/bundle/asyncapi.yaml ./test/bundle/features.yaml --base ./test/bundle/asyncapi.yaml --reference-into-components -o ./output/bundle/asyncapi.yaml'
157+ - name : Assert GitHub Action
158+ run : |
159+ echo "Listing all files"
160+ ls -R
161+ echo "Asserting GitHub Action"
162+ if [ -f "./output/bundle/asyncapi.yaml" ]; then
163+ echo "The specified files have been bundled"
164+ else
165+ echo "The specified files have not been bundled"
166+ echo "Action failed"
167+ exit 1
168+ fi
169+
170+ test-convert :
171+ runs-on : ubuntu-latest
172+ steps :
173+ - uses : actions/checkout@v4
174+ - name : Test GitHub Action
175+ uses : ./
176+ with :
177+ command : convert
178+ filepath : test/asyncapi.yml
179+ output : output/convert/asyncapi.yaml
180+ - name : Assert GitHub Action
181+ run : |
182+ echo "Listing all files"
183+ ls -R
184+ echo "Asserting GitHub Action"
185+ if [ -f "./output/convert/asyncapi.yaml" ]; then
186+ echo "The specified file has been converted"
187+ else
188+ echo "The specified file has not been converted"
189+ echo "Action failed"
190+ exit 1
191+ fi
0 commit comments