-
Notifications
You must be signed in to change notification settings - Fork 13
132 lines (113 loc) · 5.59 KB
/
e2e-agora.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
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
name: Run e2e tests for Agora
on:
push:
# Warning: using the pull_request_target event without the cautionary measures may allow
# unauthorized GitHub users to open a “pwn request” and exfiltrate secrets.
pull_request_target:
types: [opened, synchronize, reopened, labeled]
jobs:
check-agora-affected:
# Run in Sage repo on main branch and on all branches in user-owned forks
if: ${{ github.ref_name == 'main' || github.actor == github.repository_owner }}
runs-on: ubuntu-22.04
outputs:
agora_affected: ${{ steps.agora_affected.outputs.affected }}
steps:
- uses: actions/checkout@v4
with:
# We need to fetch all branches and commits so that Nx affected has a base to compare
# against.
fetch-depth: 0
persist-credentials: false
# By default, actions/checkout@v4 will checkout the main branch instead of the merge
# commit when when using pull_request_target. It is currently difficult to checkout the
# merge commit in this context. The current solution is to checkout the PR HEAD instead
# and enable the branch protection rule "Require branches to be up to date before
# merging".
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository && github.event.pull_request.head.sha || github.ref }}
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v4
- name: Set up the dev container
id: setup-dev-container
uses: ./.github/actions/setup-dev-container
- name: Check if Agora was affected
id: agora_affected
run: |
IFS=',' read -ra PROJECTS <<< "${{ steps.setup-dev-container.outputs.affected_projects }}"
for project in "${PROJECTS[@]}"; do
if [[ "$project" == agora-* ]]; then
echo "affected=true" >> "${GITHUB_OUTPUT}"
exit 0
fi
done
echo "affected=false" >> "${GITHUB_OUTPUT}"
- name: Remove the dev container
run: docker rm -f sage_devcontainer
run-agora-e2e-tests:
needs: check-agora-affected
if: needs.check-agora-affected.outputs.agora_affected == 'true'
# The agora and agora-pr environments contain the same secrets. However, the agora environment
# will run workflows automatically and should only be used when the workflow is running against
# trusted code. The agora-pr environment requires an authorized user's approval to run the
# workflow, so should be used when running against untrused code, e.g. PRs from forked repos.
environment: ${{ github.event_name == 'pull_request_target' &&
github.event.pull_request.head.repo.full_name != github.repository && 'agora-pr' || 'agora' }}
timeout-minutes: 60
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
# We need to fetch all branches and commits so that Nx affected has a base to compare
# against.
fetch-depth: 0
persist-credentials: false
# By default, actions/checkout@v4 will checkout the main branch instead of the merge
# commit when when using pull_request_target. It is currently difficult to checkout the
# merge commit in this context. The current solution is to checkout the PR HEAD instead
# and enable the branch protection rule "Require branches to be up to date before
# merging".
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository && github.event.pull_request.head.sha || github.ref }}
- name:
Switch from the detached HEAD of the merge commit to a new branch
# Buildx does not work on a detached HEAD
run: git switch -c new-branch
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v4
- name: Set up the dev container
id: setup-dev-container
uses: ./.github/actions/setup-dev-container
- name: Install Playwright Browsers
run: |
devcontainer exec --workspace-folder ../sage-monorepo bash -c ". ./dev-env.sh \
&& npx playwright install --with-deps"
- name: Setup Agora
run: |
devcontainer exec --workspace-folder ../sage-monorepo bash -c ". ./dev-env.sh \
&& bash ./tools/setup-projects.sh agora"
- name: Build Agora
run: |
devcontainer exec --workspace-folder ../sage-monorepo bash -c ". ./dev-env.sh \
&& agora-build-images"
- name: Write Synapse PAT for Agora
run: |
sed -i "s/^SYNAPSE_AUTH_TOKEN=.*/SYNAPSE_AUTH_TOKEN=\"${{ secrets.AGORA_DATA_SYNAPSE_AUTH_TOKEN }}\"/" apps/agora/data/.env
- name: Start Agora
run: |
devcontainer exec --workspace-folder ../sage-monorepo bash -c ". ./dev-env.sh \
&& nx run agora-apex:serve-detach"
- name: Run Agora e2e tests
run: |
devcontainer exec --workspace-folder ../sage-monorepo bash -c ". ./dev-env.sh \
&& nx run agora-app:e2e"
- name: Stop Agora
run: |
devcontainer exec --workspace-folder ../sage-monorepo bash -c ". ./dev-env.sh \
&& workspace-docker-stop"
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 5
- name: Remove the dev container
run: docker rm -f sage_devcontainer