-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (91 loc) · 3.5 KB
/
test.yaml
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
name: Test Action
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
test_name:
description: 'Test name input'
required: true
type: string
test_number:
description: 'Test number input'
required: false
type: number
jobs:
test-push-pull-request:
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v3
- name: Run action (no inputs expected)
uses: ./
id: print_inputs
- name: Check output (no inputs expected)
run: |
echo "Action output:"
echo "${{ steps.print_inputs.outputs.output }}"
if [[ "${{ steps.print_inputs.outputs.output }}" == *"This is not a workflow_dispatch event. No inputs expected."* ]]; then
echo "Test passed: No inputs were found, as expected for push/pull_request events"
else
echo "Test failed: Unexpected output for push/pull_request events"
exit 1
fi
test-workflow-dispatch:
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch'
steps:
- uses: actions/checkout@v3
- name: Run action (inputs expected)
uses: ./
id: print_inputs
with:
add_to_summary: 'true'
- name: Check output (inputs expected)
run: |
echo "Action output:"
echo "${{ steps.print_inputs.outputs.output }}"
if [[ "${{ steps.print_inputs.outputs.output }}" == *"test_name"* && "${{ steps.print_inputs.outputs.output }}" == *"test_number"* ]]; then
echo "Test passed: Inputs were printed correctly for workflow_dispatch event"
else
echo "Test failed: Inputs were not printed as expected for workflow_dispatch event"
exit 1
fi
- name: Check GitHub Summary
run: |
echo "Debug Info:"
echo "${{ steps.run_action.outputs.debug_info }}"
echo "Summary Content:"
echo "${{ steps.run_action.outputs.summary_content }}"
summary_content="${{ steps.run_action.outputs.summary_content }}"
if [[ "$summary_content" == *"<details>"* ]] && [[ "$summary_content" == *"test_name"* ]] && [[ "$summary_content" == *"test_number"* ]]; then
echo "Test passed: Inputs were added to GitHub Summary in collapsible format"
else
echo "Test failed: Inputs were not added to GitHub Summary as expected"
echo "Summary content:"
echo "$summary_content"
echo "GitHub Step Summary content:"
cat $GITHUB_STEP_SUMMARY
exit 1
fi
test-env-vars:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run action (with env vars)
uses: ./
id: print_inputs_and_env
with:
print_env_vars: 'true'
- name: Check output (env vars)
run: |
echo "Action output:"
echo "${{ steps.print_inputs_and_env.outputs.output }}"
if [[ "${{ steps.print_inputs_and_env.outputs.output }}" == *"Printing environment variables:"* && "${{ steps.print_inputs_and_env.outputs.output }}" == *"GITHUB_"* ]]; then
echo "Test passed: Environment variables were printed correctly"
else
echo "Test failed: Environment variables were not printed as expected"
exit 1
fi