forked from shaka-project/shaka-player
-
Notifications
You must be signed in to change notification settings - Fork 0
181 lines (157 loc) · 6.35 KB
/
build-and-test.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
name: Build and Test PR
on:
pull_request: # Trigger for pull requests.
types: [opened, synchronize, reopened]
branches:
- main
- v[0-9]*
workflow_dispatch: # Allows for manual triggering.
inputs:
ref:
description: "The ref to build and test."
required: false
# If another instance of this workflow is started for the same PR, cancel the
# old one. If a PR is updated and a new test run is started, the old test run
# will be cancelled automatically to conserve resources.
concurrency:
group: ${{ github.workflow }}-${{ github.event.inputs.ref || github.ref }}
cancel-in-progress: true
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.ref || github.ref }}
- name: Lint
run: python build/check.py
build_and_test:
# Don't waste time doing a full matrix of test runs when there was an
# obvious linter error.
needs: lint
strategy:
matrix:
include:
# Run Linux browsers with xvfb, so they're in a headless X session.
# Additionally, generate a code coverage report from Linux Chrome.
- os: ubuntu-latest
browser: Chrome
extra_flags: "--use-xvfb --html-coverage-report"
- os: ubuntu-latest
browser: Firefox
extra_flags: "--use-xvfb"
- os: macos-latest
browser: Chrome
- os: macos-latest
browser: Firefox
- os: macos-latest
browser: Edge
- os: macos-latest
browser: Safari
- os: macos-latest
browser: Safari-14
- os: windows-latest
browser: Chrome
- os: windows-latest
browser: Firefox
- os: windows-latest
browser: Edge
# Disable fail-fast so that one matrix-job failing doesn't make the other
# ones end early.
fail-fast: false
name: ${{ matrix.os }} ${{ matrix.browser }}
runs-on: ${{ matrix.os }}
steps:
# Firefox on Ubuntu appears to not have the right things installed in
# the environment used by GitHub actions, so make sure that ffmpeg is
# installed. Otherwise, the browser might not support some codecs that the
# tests assume will be supported.
- name: Install FFmpeg
if: matrix.os == 'ubuntu-latest' && matrix.browser == 'Firefox'
run: sudo apt -y update && sudo apt -y install ffmpeg
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.ref || github.ref }}
# Safari 14 can be installed, but not to the root, and it can't replace
# the standard version, at least not on GitHub's VMs. If you try to
# install directly to the root with sudo, it will appear to succeed, but
# will have no effect. If you try to script it explicitly with rm -rf
# and cp, this will fail. Safari may be on a read-only filesystem.
- name: Install Safari 14 to home directory
if: matrix.os == 'macos-latest' && matrix.browser == 'Safari-14'
run: |
# Download Safari 14
# See also https://www.macupdate.com/app/mac/15675/apple-safari/old-versions
curl -Lv https://www.macupdate.com/action/download/62946 > Safari14.0CatalinaAuto.pkg.zip
# Install Safari 14 to homedir specifically.
unzip Safari14.0CatalinaAuto.pkg.zip
installer -pkg Safari14.0CatalinaAuto.pkg -target CurrentUserHomeDirectory
# Install a launcher that can execute a shell script to launch this
npm install karma-script-launcher --save-dev
- name: Build Player
run: python build/all.py
- name: Test Player
shell: bash
run: |
browser=${{ matrix.browser }}
if [[ "$browser" == "Safari-14" ]]; then
# Replace the browser name with a script that can launch this
# browser from the command line.
browser="$PWD/.github/workflows/safari-homedir-launcher.sh"
fi
python build/test.py \
--browsers "$browser" \
--reporters spec --spec-hide-passed \
${{ matrix.extra_flags }}
- name: Find coverage reports
id: coverage
if: always() # Even on failure of an earlier step.
shell: bash
run: |
# If the "coverage" directory exists...
if [ -d coverage ]; then
# Find the path to the coverage output folder. It includes the
# exact browser version in the path, so it will vary.
coverage_folder="$( (ls -d coverage/* || true) | head -1 )"
# Build a folder to stage all the coverage artifacts with
# predictable paths. The resulting zip file will not have any
# internal directories.
mkdir coverage/staging/
cp "$coverage_folder"/coverage.json coverage/staging/
cp "$coverage_folder"/coverage-details.json coverage/staging/
echo "${{ github.event.number }}" > coverage/staging/pr-number.json
echo "::set-output name=coverage_found::true"
echo "Coverage report staged."
else
echo "No coverage report generated."
fi
- name: Upload coverage reports
uses: actions/upload-artifact@v3
if: ${{ always() && steps.coverage.outputs.coverage_found }}
with:
name: coverage
# This will create a download called coverage.zip containing all of
# these files, with no internal folders.
path: |
coverage/staging/coverage.json
coverage/staging/coverage-details.json
coverage/staging/pr-number.json
# Since we've already filtered this step for instances where there is
# an environment variable set, the file should definitely be there.
if-no-files-found: error
build_in_docker:
# Don't waste time doing a full matrix of test runs when there was an
# obvious linter error.
needs: lint
name: Docker
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.ref || github.ref }}
- name: Docker
run: docker-compose -f build/docker/docker-compose.yml up