-
Notifications
You must be signed in to change notification settings - Fork 16
168 lines (164 loc) · 6.16 KB
/
test-composite-action.yml
File metadata and controls
168 lines (164 loc) · 6.16 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: Test Composite Action
on:
pull_request:
workflow_dispatch:
jobs:
test-run-workflow-pr-mode:
name: "Test: run-workflow (PR mode)"
runs-on: ubuntu-latest
steps:
- name: Checkout test SDK repo
uses: actions/checkout@v4
with:
repository: speakeasy-api/sdk-generation-action-test-repo
token: ${{ secrets.BOT_REPO_TOKEN }}
fetch-depth: 0
- name: Checkout action
uses: actions/checkout@v4
with:
path: _action
- name: Prepare workspace
run: |
echo "_action/" >> .gitignore
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .gitignore
git commit -m "chore: ignore action dir"
echo "GITHUB_REPOSITORY=speakeasy-api/sdk-generation-action-test-repo" >> "$GITHUB_ENV"
- name: Run action in PR mode
id: run
uses: ./_action/
with:
github_access_token: ${{ secrets.BOT_REPO_TOKEN }}
speakeasy_api_key: ${{ secrets.SPEAKEASY_API_KEY }}
github_repository: speakeasy-api/sdk-generation-action-test-repo
action: generate
mode: pr
force: "true"
- name: Verify outputs
run: |
echo "=== Verifying run-workflow (PR mode) outputs ==="
echo "branch_name=${{ steps.run.outputs.branch_name }}"
echo "go_regenerated=${{ steps.run.outputs.go_regenerated }}"
echo "go_directory=${{ steps.run.outputs.go_directory }}"
if [ "${{ steps.run.outputs.go_regenerated }}" = "true" ]; then
echo "PASS: Go SDK was regenerated"
else
echo "FAIL: Go SDK was not regenerated"
exit 1
fi
echo "=== PR mode test complete ==="
test-run-workflow-direct-mode:
name: "Test: run-workflow (direct mode)"
runs-on: ubuntu-latest
steps:
- name: Checkout test SDK repo
uses: actions/checkout@v4
with:
repository: speakeasy-api/sdk-generation-action-test-repo
token: ${{ secrets.BOT_REPO_TOKEN }}
fetch-depth: 0
- name: Checkout action
uses: actions/checkout@v4
with:
path: _action
- name: Prepare workspace
run: |
echo "_action/" >> .gitignore
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .gitignore
git commit -m "chore: ignore action dir"
echo "GITHUB_REPOSITORY=speakeasy-api/sdk-generation-action-test-repo" >> "$GITHUB_ENV"
- name: Run action in direct mode
id: run
uses: ./_action/
with:
github_access_token: ${{ secrets.BOT_REPO_TOKEN }}
speakeasy_api_key: ${{ secrets.SPEAKEASY_API_KEY }}
github_repository: speakeasy-api/sdk-generation-action-test-repo
action: generate
mode: direct
force: "true"
- name: Verify outputs
run: |
echo "=== Verifying run-workflow (direct mode) outputs ==="
echo "commit_hash=${{ steps.run.outputs.commit_hash }}"
echo "go_regenerated=${{ steps.run.outputs.go_regenerated }}"
echo "go_directory=${{ steps.run.outputs.go_directory }}"
if [ "${{ steps.run.outputs.go_regenerated }}" = "true" ]; then
echo "PASS: Go SDK was regenerated"
else
echo "FAIL: Go SDK was not regenerated"
exit 1
fi
echo "=== Direct mode test complete ==="
test-release:
name: "Test: release"
runs-on: ubuntu-latest
needs: [test-run-workflow-direct-mode]
steps:
- name: Checkout test SDK repo
uses: actions/checkout@v4
with:
repository: speakeasy-api/sdk-generation-action-test-repo
token: ${{ secrets.BOT_REPO_TOKEN }}
fetch-depth: 0
- name: Checkout action
uses: actions/checkout@v4
with:
path: _action
- name: Prepare workspace
run: |
echo "_action/" >> .gitignore
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .gitignore
git commit -m "chore: ignore action dir"
echo "GITHUB_REPOSITORY=speakeasy-api/sdk-generation-action-test-repo" >> "$GITHUB_ENV"
- name: Run action in release mode
id: run
uses: ./_action/
with:
github_access_token: ${{ secrets.BOT_REPO_TOKEN }}
speakeasy_api_key: ${{ secrets.SPEAKEASY_API_KEY }}
github_repository: speakeasy-api/sdk-generation-action-test-repo
action: release
- name: Verify release outputs
run: |
echo "=== Verifying release outputs ==="
echo "publish_go=${{ steps.run.outputs.publish_go }}"
echo "go_regenerated=${{ steps.run.outputs.go_regenerated }}"
echo "=== Release test complete ==="
test-tag:
name: "Test: tag"
runs-on: ubuntu-latest
steps:
- name: Checkout test SDK repo
uses: actions/checkout@v4
with:
repository: speakeasy-api/sdk-generation-action-test-repo
token: ${{ secrets.BOT_REPO_TOKEN }}
fetch-depth: 0
- name: Checkout action
uses: actions/checkout@v4
with:
path: _action
- name: Prepare workspace
run: |
echo "_action/" >> .gitignore
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .gitignore
git commit -m "chore: ignore action dir"
echo "GITHUB_REPOSITORY=speakeasy-api/sdk-generation-action-test-repo" >> "$GITHUB_ENV"
- name: Run action in tag mode
id: run
uses: ./_action/
with:
github_access_token: ${{ secrets.BOT_REPO_TOKEN }}
speakeasy_api_key: ${{ secrets.SPEAKEASY_API_KEY }}
github_repository: speakeasy-api/sdk-generation-action-test-repo
action: tag
- name: Verify tag completed
run: echo "=== Tag action completed successfully ==="