Skip to content

Commit fd9d99e

Browse files
authored
Merge pull request #6 from upbound/feature/e2e-update
feat(e2e): use e2e workflow template
2 parents ec2532f + 871e616 commit fd9d99e

File tree

1 file changed

+7
-191
lines changed

1 file changed

+7
-191
lines changed

.github/workflows/e2e.yaml

+7-191
Original file line numberDiff line numberDiff line change
@@ -1,197 +1,13 @@
1-
name: Run Uptest
1+
name: End to End Testing
22

33
on:
44
issue_comment:
55
types: [created]
66

7-
env:
8-
trigger-keyword: '/test-examples'
9-
go-version: '1.19'
10-
package-type: configuration
11-
127
jobs:
13-
debug:
14-
runs-on: [e2-standard-8, linux]
15-
steps:
16-
- name: Debug
17-
run: |
18-
echo "Trigger keyword: ${{ env.trigger-keyword }}"
19-
echo "Go version: ${{ env.go-version }}"
20-
echo "github.event.comment.author_association: ${{ github.event.comment.author_association }}"
21-
echo "github.event.comment.body: ${{ github.event.comment.body }}"
22-
23-
get-example-list:
24-
if: ${{ (github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'CONTRIBUTOR' ) &&
25-
github.event.issue.pull_request &&
26-
contains(github.event.comment.body, env.trigger-keyword ) }}
27-
runs-on: [e2-standard-8, linux]
28-
outputs:
29-
example_list: ${{ steps.get-example-list-name.outputs.example-list }}
30-
example_hash: ${{ steps.get-example-list-name.outputs.example-hash }}
31-
32-
steps:
33-
- name: Checkout
34-
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
35-
with:
36-
submodules: true
37-
38-
- name: Checkout PR
39-
id: checkout-pr
40-
env:
41-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42-
run: |
43-
gh pr checkout ${{ github.event.issue.number }}
44-
git submodule update --init --recursive
45-
OUTPUT=$(git log -1 --format='%H')
46-
echo "commit-sha=$OUTPUT" >> $GITHUB_OUTPUT
47-
48-
- name: Prepare The Example List
49-
env:
50-
COMMENT: ${{ github.event.comment.body }}
51-
id: get-example-list-name
52-
run: |
53-
PATHS=$(echo $COMMENT | sed 's/^.*\${{ env.trigger-keyword }}="//g' | cut -d '"' -f 1 | sed 's/,/ /g')
54-
EXAMPLE_LIST=""
55-
for P in $PATHS; do EXAMPLE_LIST="${EXAMPLE_LIST},$(find $P -name '*.yaml' | tr '\n' ',')"; done
56-
57-
sudo apt-get -y install coreutils
58-
COUNT=$(echo ${EXAMPLE_LIST:1} | grep -o ".yaml" | wc -l)
59-
if [ $COUNT -gt 1 ]; then EXAMPLE_HASH=$(echo ${EXAMPLE_LIST} | md5sum | cut -f1 -d" "); else EXAMPLE_HASH=$(echo ${EXAMPLE_LIST:1} | sed 's/.$//'); fi
60-
61-
echo "Examples: ${EXAMPLE_LIST:1}"
62-
echo "Example Hash: ${EXAMPLE_HASH}"
63-
64-
echo "example-list=${EXAMPLE_LIST:1}" >> $GITHUB_OUTPUT
65-
echo "example-hash=${EXAMPLE_HASH}" >> $GITHUB_OUTPUT
66-
67-
- name: Create Pending Status Check
68-
env:
69-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70-
run: |
71-
gh api \
72-
--method POST \
73-
-H "Accept: application/vnd.github+json" \
74-
/repos/${{ github.repository }}/statuses/${{ steps.checkout-pr.outputs.commit-sha }} \
75-
-f state='pending' \
76-
-f target_url='https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' \
77-
-f description='Running...' \
78-
-f context="Uptest-${{ steps.get-example-list-name.outputs.example-hash }}"
79-
80-
uptest:
81-
if: ${{ (github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'CONTRIBUTOR' ) &&
82-
github.event.issue.pull_request &&
83-
contains(github.event.comment.body, env.trigger-keyword ) }}
84-
runs-on: [e2-standard-8, linux]
85-
needs: get-example-list
86-
87-
steps:
88-
- name: Setup QEMU
89-
uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7 # v2
90-
with:
91-
platforms: all
92-
93-
- name: Checkout
94-
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
95-
with:
96-
submodules: true
97-
98-
- name: Setup Go
99-
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3
100-
with:
101-
go-version: ${{ env.go-version }}
102-
103-
- name: Checkout PR
104-
id: checkout-pr
105-
env:
106-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107-
run: |
108-
gh pr checkout ${{ github.event.issue.number }}
109-
git submodule update --init --recursive
110-
OUTPUT=$(git log -1 --format='%H')
111-
echo "commit-sha=$OUTPUT" >> $GITHUB_OUTPUT
112-
113-
- name: Find the Go Build Cache
114-
if: ${{ env.package-type == 'provider' }}
115-
id: go
116-
run: echo "cache=$(make go.cachedir)" >> $GITHUB_OUTPUT
117-
118-
- name: Cache the Go Build Cache
119-
if: ${{ env.package-type == 'provider' }}
120-
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3
121-
with:
122-
path: ${{ steps.go.outputs.cache }}
123-
key: ${{ runner.os }}-build-uptest-${{ hashFiles('**/go.sum') }}
124-
restore-keys: ${{ runner.os }}-build-uptest-
125-
126-
- name: Cache Go Dependencies
127-
if: ${{ env.package-type == 'provider' }}
128-
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3
129-
with:
130-
path: .work/pkg
131-
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
132-
restore-keys: ${{ runner.os }}-pkg-
133-
134-
- name: Vendor Dependencies
135-
if: ${{ env.package-type == 'provider' }}
136-
run: make vendor vendor.check
137-
138-
- name: Run Uptest
139-
id: run-uptest
140-
env:
141-
UPTEST_AWS_CLOUD_CREDENTIALS: ${{ secrets.UPTEST_AWS_CLOUD_CREDENTIALS }}
142-
UPTEST_AZURE_CLOUD_CREDENTIALS: ${{ secrets.UPTEST_AZURE_CLOUD_CREDENTIALS }}
143-
UPTEST_GCP_CLOUD_CREDENTIALS: ${{ secrets.UPTEST_GCP_CLOUD_CREDENTIALS }}
144-
UPTEST_UPBOUND_CLOUD_CREDENTIALS: ${{ secrets.UPTEST_UPBOUND_CLOUD_CREDENTIALS }}
145-
UPTEST_EXAMPLE_LIST: ${{ needs.get-example-list.outputs.example_list }}
146-
UPTEST_TEST_DIR: ./_output/controlplane-dump
147-
UPTEST_DATASOURCE_PATH: .work/uptest-datasource.yaml
148-
run: |
149-
mkdir -p .work && echo "${{ secrets.UPTEST_DATASOURCE }}" > .work/uptest-datasource.yaml
150-
make e2e
151-
152-
- name: Create Successful Status Check
153-
env:
154-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
155-
EXAMPLE_HASH: ${{ needs.get-example-list.outputs.example_hash }}
156-
run: |
157-
gh api \
158-
--method POST \
159-
-H "Accept: application/vnd.github+json" \
160-
/repos/${{ github.repository }}/statuses/${{ steps.checkout-pr.outputs.commit-sha }} \
161-
-f state='success' \
162-
-f target_url='https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' \
163-
-f description='Passed' \
164-
-f context="Uptest-${EXAMPLE_HASH}"
165-
166-
- name: Collect Cluster Dump
167-
if: always()
168-
run: |
169-
make controlplane.dump
170-
171-
- name: Upload Cluster Dump
172-
if: always()
173-
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3
174-
with:
175-
name: controlplane-dump
176-
path: ./_output/controlplane-dump
177-
178-
- name: Cleanup
179-
if: always()
180-
run: |
181-
eval $(make --no-print-directory build.vars)
182-
${KUBECTL} delete managed --all || true
183-
184-
- name: Create Unsuccessful Status Check
185-
if: failure()
186-
env:
187-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
188-
EXAMPLE_HASH: ${{ needs.get-example-list.outputs.example_hash }}
189-
run: |
190-
gh api \
191-
--method POST \
192-
-H "Accept: application/vnd.github+json" \
193-
/repos/${{ github.repository }}/statuses/${{ steps.checkout-pr.outputs.commit-sha }} \
194-
-f state='failure' \
195-
-f target_url='https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' \
196-
-f description='Failed' \
197-
-f context="Uptest-${EXAMPLE_HASH}"
8+
e2e:
9+
uses: upbound/uptest/.github/workflows/pr-comment-trigger.yml@main
10+
with:
11+
package-type: configuration
12+
secrets:
13+
UPTEST_CLOUD_CREDENTIALS: ${{ secrets.UPTEST_CLOUD_CREDENTIALS }}

0 commit comments

Comments
 (0)