-
Notifications
You must be signed in to change notification settings - Fork 65
207 lines (184 loc) · 6.78 KB
/
testing.yml
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# Copyright 2020 Wayback Archiver. All rights reserved.
# Use of this source code is governed by the GNU GPL v3
# license that can be found in the LICENSE file.
#
name: Testing
on:
push:
branches:
- "*"
paths:
- "**/*.go"
- "go.mod"
- "go.sum"
- ".github/workflows/testing.yml"
- "Makefile"
pull_request:
branches: [ main ]
types: [ opened, synchronize, reopened ]
paths:
- "**/*.go"
- "go.mod"
- "go.sum"
- ".github/workflows/testing.yml"
- "Makefile"
workflow_dispatch:
permissions:
contents: read
# New runs to only cancel in-progress runs of the same workflow.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
testing:
name: Testing
permissions:
actions: write # for styfle/cancel-workflow-action to cancel/stop running workflows
contents: read # for actions/checkout to fetch code
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
go: [ "1.18", "1.19", "1.20" ]
include:
# only update test coverage stats with the most recent go version on linux
- go: 1.x
os: ubuntu-latest
update-coverage: true
env:
SENDER_UID: ${{ secrets.MATRIX_SENDER_UID }}
SENDER_PWD: ${{ secrets.MATRIX_SENDER_PWD }}
RECVER_UID: ${{ secrets.MATRIX_RECVER_UID }}
RECVER_PWD: ${{ secrets.MATRIX_RECVER_PWD }}
WAYBACK_IPFS_MODE: ${{ vars.WAYBACK_IPFS_MODE }}
WAYBACK_IPFS_HOST: ${{ vars.WAYBACK_IPFS_HOST }}
WAYBACK_IPFS_PORT: ${{ vars.WAYBACK_IPFS_PORT }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@2e205a28d0e1da00c5f53b161f4067b052c61f34 # v1.5.0
with:
egress-policy: audit
disable-telemetry: true
- name: Set up Go ${{ matrix.go }}.x
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: ${{ matrix.go }}
- name: Set up IPFS
uses: ibnesayeed/setup-ipfs@3e5452e358dfa43a0fb92496e96c82cf756be94a
with:
run_daemon: true
ipfs_version: ${{ vars.IPFS_VERSION }}
- name: Set up Tor
uses: tor-actions/setup-tor@462b4eef22eecc86cc4abdedafc95a38667e2557
with:
daemon: true
- name: Set up Chrome
uses: browser-actions/setup-chrome@37c79b7f0199cec79c8b6a414e806d88c8662bdd
with:
chrome-version: stable
- name: Set up Meilisearch
if: matrix.os == 'ubuntu-latest'
uses: moy2010/meilisearch-github-action@fcc5ef714af0596633665032d459bfb279d3c730 # 0.1.4
with:
meilisearch-version: ${{ vars.MEILISEARCH_VERSION }}
meilisearch-port: ${{ vars.MEILISEARCH_PORT }}
meilisearch-api-key: ${{ vars.MEILISEARCH_APIKEY }}
- name: Set up Chocolatey
if: matrix.os == 'windows-latest'
uses: crazy-max/ghaction-chocolatey@b59ffdb6594d2e2c36d9e1174e15ac799dd0a8f1 # v2.0.0
with:
args: -h
- name: Install Packages for Linux
if: matrix.os == 'ubuntu-latest'
shell: bash
run: |
# search package https://pkgs.org/
sudo add-apt-repository universe
sudo apt-get -y -qq update
sudo apt-get -y -qq install ffmpeg webp youtube-dl
pip3 install you-get
echo "youtube-dl version $(youtube-dl --version)"
you-get --version
ffmpeg -version
- name: Install Packages for MacOS
if: matrix.os == 'macos-latest'
shell: bash
run: |
# search package https://brew.sh/
brew install --quiet ffmpeg webp youtube-dl you-get
echo "youtube-dl version $(youtube-dl --version)"
you-get --version
ffmpeg -version
- name: Install Packages for Windows
if: matrix.os == 'windows-latest'
shell: bash
run: |
# search package https://community.chocolatey.org/packages
choco install --no-progress wget ffmpeg webp youtube-dl you-get
echo "youtube-dl version $(youtube-dl --version)"
you-get --version
ffmpeg -version
wget --help
- name: Set environments
shell: bash
run: |
ipfsMode="${{ vars.WAYBACK_IPFS_MODE }}"
echo "WAYBACK_IPFS_MODE=${ipfsMode:-daemon}" >> $GITHUB_ENV
# Set env to enable reduxer
echo "WAYBACK_STORAGE_DIR=${{ runner.temp }}" >> $GITHUB_ENV
# Append paths to environment path
# echo "$(which youtube-dl)" >> $GITHUB_PATH
# echo "$(which you-get)" >> $GITHUB_PATH
# echo "$(which ffmpeg)" >> $GITHUB_PATH
# echo "$(which wget)" >> $GITHUB_PATH
- name: Set environments for Meilisearch
if: matrix.os == 'ubuntu-latest'
shell: bash
run: |
# Set env to enable reduxer
echo "WAYBACK_MEILI_ENDPOINT=${{ vars.WAYBACK_MEILI_ENDPOINT }}" >> $GITHUB_ENV
echo "PLAYBACK_MEILI_ENDPOINT=${{ vars.WAYBACK_MEILI_ENDPOINT }}" >> $GITHUB_ENV
echo "WAYBACK_MEILI_APIKEY=${{ vars.MEILISEARCH_APIKEY }}" >> $GITHUB_ENV
echo "PLAYBACK_MEILI_APIKEY=${{ vars.MEILISEARCH_APIKEY }}" >> $GITHUB_ENV
- name: Check out code base
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with:
fetch-depth: 0
- name: Check out code base
if: github.event_name == 'pull_request'
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Cache go module
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3.0.11
with:
path: |
~/.cache/go-build
~/go/pkg/mod
~/Library/Caches/go-build
~\AppData\Local\go-build
~\go\pkg\mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Run test
run: |
make test
make test-cover
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb # v3.1.1
with:
name: coverage-${{ matrix.os }}
path: coverage.*
- name: Upload coverage to Codecov
if: ${{ matrix.update-coverage }}
uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 #v3.1.0
- name: Run integration test
run: make test-integration