forked from flojoy-ai/studio
-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (144 loc) · 6.5 KB
/
test_pr.yml
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
# name: Trigger Live test
#
# on:
# pull_request:
# types:
# - opened
# - synchronize
# pull_request_target:
# types:
# - closed
#
# env:
# PROJECT_OWNER: flojoy-io
# PROJECT_REPO: rc
# PROJECT_WORKFLOW_ID: terraform-test-env.yml
# PROJECT_TOKEN: ${{ secrets.ACCESS_TOKEN_FLOJOY_RC }}
# REFLECT_SUITE: flojoy-live-test
# REFLECT_TOKEN: ${{ secrets.REFLECT_TOKEN }}
#
# jobs:
# trigger_workflow:
# runs-on: ubuntu-latest
# if: ${{ github.event.pull_request.base.ref == 'develop' }}
# steps:
# - name: Checkout Repository
# uses: actions/checkout@v3
#
# - name: Print Parameters
# run: |
# echo "GitHub Event Name: ${{ github.event_name}}"
# echo "GitHub Head Ref: ${{ github.head_ref }}"
# echo "GitHub Event Pull Request Number: ${{ github.event.pull_request.number }}"
# echo "Context Issue Number: ${{ github.event.pull_request.number}}"
# echo "Context Repo Owner: ${{ github.repository_owner }}"
# echo "Context Repo Repo: ${{ github.repository }}"
# echo "GitHub Event Pull Request Merged: ${{ github.event.pull_request.merged }}"
# echo "GitHub Event Action: ${{ github.event.action }}"
#
# - name: Trigger test PR
# if: github.event.action == 'opened'
# id: trigger_pr
# run: |
# curl -X POST https://api.github.com/repos/${{ env.PROJECT_OWNER }}/${{ env.PROJECT_REPO }}/actions/workflows/${{ env.PROJECT_WORKFLOW_ID }}/dispatches \
# -H 'Accept: application/vnd.github.everest-preview+json' \
# -u ${{ env.PROJECT_TOKEN }} \
# --data '{"ref":"main", "inputs":{"github_event_name":"${{ github.event_name }}", "github_head_ref": "${{ github.head_ref }}", "github_event_pull_request_number": "${{ github.event.pull_request.number }}", "context_issue_number": "${{ github.event.pull_request.number }}", "context_repo_owner": "${{ github.repository_owner }}", "context_repo_repo": "${{ github.repository }}", "github_event_pull_request_merged": "${{ github.event.pull_request.merged }}", "github_event_action": "${{ github.event.action }}"}}'
# - uses: actions/checkout@v3
# - name: Wait for 10m
# run: sleep 10m
#
# - name: Find Comment with URLs
# if: github.event.action == 'opened' || github.event.action == 'synchronize'
# uses: peter-evans/find-comment@v2
# id: fc
# with:
# token: ${{ secrets.ACCESS_TOKEN_FLOJOY_RC }}
# issue-number: ${{ github.event.pull_request.number }}
# body-regex: 'flojoy-test\.com:3000'
#
# - name: Extract test URLs
# if: github.event.action == 'opened' || github.event.action == 'synchronize'
# id: extract-ip-port
# run: |
# URL_REGEX='([0-9]+)_(windows|linux)\.flojoy-test\.com'
# if [[ "${{ steps.fc.outputs.comment-body }}" =~ $URL_REGEX ]]; then
# export FC_COMMENT_BODY="${{ steps.fc.outputs.comment-body }}"
# while [[ "${FC_COMMENT_BODY}" =~ $URL_REGEX ]]; do
# domain="${BASH_REMATCH[1]}"
# platform="${BASH_REMATCH[2]}"
#
# if [[ $platform == "windows" ]]; then
# echo "domain_windows=${domain}_windows.flojoy-test.com" >> $GITHUB_OUTPUT
# elif [[ $platform == "linux" ]]; then
# echo "domain_linux=${domain}_linux.flojoy-test.com" >> $GITHUB_OUTPUT
# fi
#
# # Replace the matched URL with an empty string to continue searching for more URLs
# FC_COMMENT_BODY="${FC_COMMENT_BODY//${BASH_REMATCH[0]}/}"
# done
# else
# echo "No matching URLs found in the comment body."
# fi
#
# - name: Test if Flojoy-studio is up
# if: github.event.action == 'opened' || github.event.action == 'synchronize'
# id: test-http-page
# run: |
# echo "Test on http://${{ steps.extract-ip-port.outputs.domain_windows }}:3000"
# CONTENT=$(curl -s "${{ steps.extract-ip-port.outputs.domain_windows }}:3000")
# if [[ $CONTENT == *"<title>FLOJOY</title>"* ]]; then
# echo "The HTTP page contains '<title>FLOJOY</title>'."
# echo "Test passed on Windows."
# else
# echo "The HTTP page does not contain '<title>FLOJOY</title>'."
# echo "Test failed on Windows."
# exit 1
# fi
#
# echo "Test on http://${{ steps.extract-ip-port.outputs.domain_linux }}:3000"
# CONTENT=$(curl -s "${{ steps.extract-ip-port.outputs.domain_linux }}:3000")
# if [[ $CONTENT == *"<title>FLOJOY</title>"* ]]; then
# echo "The HTTP page contains '<title>FLOJOY</title>'."
# echo "Test passed on Linux."
# else
# echo "The HTTP page does not contain '<title>FLOJOY</title>'."
# echo "Test failed on Linux."
# exit1
# fi
#
# - name: Windows live test on Reflect.run
# if: github.event.action == 'opened' || github.event.action == 'synchronize'
# run: |
# curl --location 'https://api.reflect.run/v1/suites/${{ env.REFLECT_SUITE }}/executions' \
# --header 'Content-Type: text/plain' \
# --header 'X-API-KEY: ${{ secrets.REFLECT_TOKEN }}' \
# --data '{
# "browser": "Chrome",
# "variables": {
# "URL": "http://${{ steps.extract-ip-port.outputs.domain_windows }}:3000/"
# },
# "gitHub": {
# "owner": "${{ github.repository_owner }}",
# "repo": "${{ github.event.repository.name}}",
# "sha": "${{ github.event.pull_request.head.sha }}"
# }
# }'
#
# - name: Linux live test on Reflect.run
# if: github.event.action == 'opened' || github.event.action == 'synchronize'
# run: |
# curl --location 'https://api.reflect.run/v1/suites/${{ env.REFLECT_SUITE }}/executions' \
# --header 'Content-Type: text/plain' \
# --header 'X-API-KEY: ${{ secrets.REFLECT_TOKEN }}' \
# --data '{
# "browser": "Chrome",
# "variables": {
# "URL": "http://${{ steps.extract-ip-port.outputs.domain_linux }}:3000/"
# },
# "gitHub": {
# "owner": "${{ github.repository_owner }}",
# "repo": "${{ github.event.repository.name}}",
# "sha": "${{ github.event.pull_request.head.sha }}"
# }
# }'