-
Notifications
You must be signed in to change notification settings - Fork 11
133 lines (118 loc) · 5 KB
/
reusable_e2e.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
133
# This is a reusable workflow that can be run based on `mirrord_release_branch` boolean input
# in the `mirrord` or `mirrord-vscode` repository and hence is maintained in a single place.
# The difference in the workflow when `mirrord_release_branch` is set is as follows:
# - we checkout into the latest released tag of `mirrord-vscode` from the perspective of binary
# that has to be released on `mirrord` side. if not set, we checkout into the current branch.
# - we rely on downloading the mirrord binary from `mirrord-artifacts` using `actions/download-artifact`
# and adding it to the path. if not set, the latest version is downloaded.
name: reusable_e2e
on:
workflow_call:
inputs:
mirrord_release_branch:
required: false
type: boolean
default: false
jobs:
vscode-e2e:
runs-on: ubuntu-24.04
env:
CI_BUILD_PLUGIN: "true"
steps:
- name: Remove unnecessary files
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: checkout repository
if: ${{ !inputs.mirrord_release_branch }}
uses: actions/checkout@v4
# mirrord_release_branch boolean when set, means we are on a release branch
# and hence we need to checkout into the last released tag of mirrord-vscode
- name: checkout into mirrord-vscode if mirrord_release_branch
if: ${{ inputs.mirrord_release_branch }}
uses: actions/checkout@v4
with:
repository: "metalbear-co/mirrord-vscode"
- name: checkout into the last released tag
if: ${{ inputs.mirrord_release_branch }}
run: |
git fetch --all --tags
git checkout tags/$(jq -r .version package.json)
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18.15.x
cache: npm
- name: Install dependencies
run: |
npm install
# we are on a release branch, so we need to download the mirrord binary from
# mirrord-artifacts and add it to the path
- name: download mirrord binary
if: ${{ inputs.mirrord_release_branch }}
uses: actions/download-artifact@v4
with:
name: mirrord-artifacts
- name: add downloaded mirrord to path
if: ${{ inputs.mirrord_release_branch }}
run: |
chmod u+x mirrord
echo "${GITHUB_WORKSPACE}" >> $GITHUB_PATH
- name: get the latest mirrord binary
if: ${{ !inputs.mirrord_release_branch }}
run: |
curl -fsSL https://raw.githubusercontent.com/metalbear-co/mirrord/main/scripts/install.sh | bash
- name: Start minikube
uses: medyagh/setup-minikube@master
with:
container-runtime: docker
- run: |
kubectl apply -f sample/kubernetes/app.yaml
echo "POD_TO_SELECT=$(kubectl get pods -o=name | head -n 1)" >> "$GITHUB_ENV"
kubectl wait --for=condition=ready --timeout=30s $(kubectl get pods -o=name | head -n 1)
KUBE_SERVICE=$(minikube service list --output=json | jq -r '.[] | select(.Name == "py-serv") | .URLs[0]')
echo "$KUBE_SERVICE"
echo "KUBE_SERVICE=$KUBE_SERVICE" >> "$GITHUB_ENV"
- name: download image
if: ${{ inputs.mirrord_release_branch }}
uses: actions/download-artifact@v4
with:
name: test
path: /tmp
- run: minikube image load /tmp/test.tar
if: ${{ inputs.mirrord_release_branch }}
- uses: actions/setup-python@v4
with:
python-version: "3.10"
# we can't run chrome like apps in the CI, we use a virtual frame buffer:
# refer: http://elementalselenium.com/tips/38-headless
- name: Run vscode e2e in headless state
if: ${{ inputs.mirrord_release_branch }}
env:
POD_TO_SELECT: ${{ env.POD_TO_SELECT }}
KUBE_SERVICE: ${{ env.KUBE_SERVICE }}
MIRRORD_AGENT_IMAGE: "test"
run: |
sudo apt-get update
sudo apt-get install -y xvfb x11-xserver-utils ffmpeg
/usr/bin/xvfb-run -s ":99 -auth /tmp/xvfb.auth -ac -screen 0 1920x1080x24" npm run test &
ffmpeg -loglevel panic -y -framerate 30 -f x11grab -video_size 1920x1080 -i :99 out.webm
wait -n
- name: Run vscode e2e in headless state
if: ${{ !inputs.mirrord_release_branch }}
env:
POD_TO_SELECT: ${{ env.POD_TO_SELECT }}
KUBE_SERVICE: ${{ env.KUBE_SERVICE }}
run: |
sudo apt-get update
sudo apt-get install -y xvfb x11-xserver-utils ffmpeg
/usr/bin/xvfb-run -s ":99 -auth /tmp/xvfb.auth -ac -screen 0 1920x1080x24" npm run test &
ffmpeg -loglevel panic -y -framerate 30 -f x11grab -video_size 1920x1080 -i :99 out.webm
wait -n
# the video starts at around ~2 minutes, before that you will see a black screen
- name: Upload video
if: always()
uses: actions/upload-artifact@v4
with:
name: video
path: out.webm