129 lines (112 loc) · 4.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
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:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
browser: ["Chrome", "Firefox", "Edge", "Safari", "Safari-14"]
exclude:
- os: ubuntu-latest
browser: Edge
- os: windows-latest
browser: Safari
- os: windows-latest
browser: Safari-14
- os: ubuntu-latest
browser: Safari
- os: ubuntu-latest
browser: Safari-14
include:
# Run Linux browsers with xvfb, so they're in a headless X session.
- os: ubuntu-latest
extra_flags: "--use-xvfb"
# 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/63550 > safari-14.1.2.pkg
# Install Safari 14 to homedir specifically.
installer -pkg safari-14.1.2.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 }}
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