forked from shaka-project/shaka-player
-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (119 loc) · 5.2 KB
/
selenium-lab-tests.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
134
135
name: Selenium Lab Tests
on:
workflow_dispatch:
# Allows for manual triggering on PRs. They should be reviewed first, to
# avoid malicious code executing in the lab.
inputs:
pr:
description: "A PR number to build and test in the lab. If empty, will build and test from main."
required: false
schedule:
# Runs every night at 2am PST / 10am UTC, testing against the main branch.
- cron: '0 10 * * *'
# Only one run of this workflow is allowed at a time, since it uses physical
# resources in our lab.
concurrency: selenium-lab
jobs:
lab-tests:
# This is a self-hosted runner in a Docker container, with access to our
# lab's Selenium grid on port 4444.
runs-on: self-hosted-selenium
steps:
# This runs on our self-hosted runner, and the Docker image it is based
# on doesn't have GitHub's CLI pre-installed. This installs it. Taken
# verbatim from the official installation instructions at
# https://github.com/cli/cli/blob/trunk/docs/install_linux.md
- name: Install GitHub Actions CLI
run: |
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt install gh
- name: Compute ref
run: |
if [[ "${{ github.event.inputs.pr }}" != "" ]]; then
echo LAB_TEST_REF="refs/pull/${{ github.event.inputs.pr }}/head" >> $GITHUB_ENV
else
echo LAB_TEST_REF="main" >> $GITHUB_ENV
fi
- uses: actions/checkout@v2
with:
ref: ${{ env.LAB_TEST_REF }}
- name: Set Commit Status to Pending
uses: ./.github/workflows/custom-actions/set-commit-status
with:
context: Selenium Lab Tests
state: pending
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@v1
with:
node-version: 16
registry-url: 'https://registry.npmjs.org'
# The Docker image for this self-hosted runner doesn't contain java.
- uses: actions/setup-java@v2
with:
distribution: zulu
java-version: 11
# The Docker image for this self-hosted runner has "python3" but not
# plain "python".
- name: Build Player
run: python3 build/all.py
# Run tests on the Selenium grid in our lab. This uses a private
# hostname and TLS cert to get EME tests working on all platforms
# (since EME only works on https or localhost).
- name: Test Player
run: |
python3 build/test.py \
--reporters spec --spec-hide-passed \
--lets-encrypt-folder /etc/shakalab.rocks \
--hostname karma.shakalab.rocks \
--port 61731 \
--grid-config build/shaka-lab.yaml \
--grid-address selenium-grid.lab:4444 \
--html-coverage-report
- name: Find coverage report
id: coverage
if: always() # Even on failure of an earlier step.
shell: bash
run: |
# If the directory exists...
if [ -d coverage ]; then
# Find the path to the coverage report specifically for Chrome on
# Linux. It includes the exact browser version in the path, so it
# will vary. Having a single path will make the artifact zip
# simpler, whereas using a wildcard in the upload step will result
# in a zip file with internal directories.
coverage_report="$( (ls coverage/Chrome*Linux*/coverage.json || true) | head -1 )"
# Show what's there, for debugging purposes.
ls -l coverage/
if [ -f "$coverage_report" ]; then
echo "Found coverage report: $coverage_report"
echo "::set-output name=coverage_report::$coverage_report"
else
echo "Could not locate coverage report!"
exit 1
fi
else
echo "No coverage report generated."
fi
- uses: actions/upload-artifact@v3
# If there's a coverage report, upload it, even if a previous step
# failed.
if: ${{ always() && steps.coverage.outputs.coverage_report }}
with:
# This will create a download called coverage.zip containing only
# coverage.json.
path: ${{ steps.coverage.outputs.coverage_report }}
name: coverage
# Since we've already filtered this step for instances where there is
# an environment variable set for this, the file should definitely be
# there.
if-no-files-found: error
- name: Report Final Commit Status
# Will run on success or failure, but not if the workflow is cancelled.
if: ${{ success() || failure() }}
uses: ./.github/workflows/custom-actions/set-commit-status
with:
context: Selenium Lab Tests
state: ${{ job.status }}
token: ${{ secrets.GITHUB_TOKEN }}