-
Notifications
You must be signed in to change notification settings - Fork 101
166 lines (142 loc) · 5.04 KB
/
ci.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
name: CI
on: [push, pull_request]
env:
HTTPTOOLKIT_SERVER_DISABLE_AUTOUPDATE: 1 # Don't try to autoupdate during tests etc
jobs:
build:
name: Build & test
runs-on: ubuntu-22.04
container:
image: httptoolkit/act-build-base:v3.0.0
options: "--privileged" # Required for DIND tests
env:
DIND_HOST: unix:///tmp/docker.sock
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.11.1
- run: npm install -g npm@^8
- name: Set up JDK 11 for Java testing
uses: actions/setup-java@v4
with:
java-version: 11
distribution: adopt-hotspot
- run: npm ci
env:
NPM_CONFIG_UNSAFE_PERM: true
- run: npm run build:src
- name: Prepare test environment
run: |
# Fix annoying Yarn issue: https://github.com/yarnpkg/yarn/issues/7866
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
# Ditto but for Google:
curl -sL https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo apt-get update
sudo apt-get install -y p7zip-full xterm
wget https://downloads.slack-edge.com/linux_releases/slack-desktop-4.12.2-amd64.deb
sudo apt install -y ./slack-desktop-4.12.2-amd64.deb
sudo cp test/no-sandbox-docker-wrapper.sh /usr/local/bin/google-chrome
sudo cp test/no-sandbox-docker-wrapper.sh /usr/local/bin/slack
# Fix $HOME perms to make Firefox happy
sudo chown $(whoami) $HOME
# Start a DIND docker host, running in the background
sudo dockerd -H $DIND_HOST &
sleep 5
# Pre-pull lots of the Docker images we'll want to use later
echo node:14 golang:1.16 openjdk:16-alpine3.13 python:3.9-slim ruby:alpine3.13 php:8.0-apache |
DOCKER_HOST=$DIND_HOST xargs -P10 -n1 docker pull
- run: DOCKER_HOST=$DIND_HOST xvfb-run npm run test
- run: npm run build:release
env:
SENTRY_AUTH_TOKEN: ${{ (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && secrets.SENTRY_AUTH_TOKEN) || '' }}
SENTRY_ORG: http-toolkit
SENTRY_PROJECT: httptoolkit-server
NPM_CONFIG_UNSAFE_PERM: true
- run: DOCKER_HOST=$DIND_HOST xvfb-run npm run test:integration:release
- uses: actions/upload-artifact@v4
with:
name: distributables
path: build/dist/*
if-no-files-found: error
- uses: actions/upload-artifact@v4
with:
name: test-scripts
path: test/distributables-test
if-no-files-found: error
test-distributables:
needs: build
strategy:
matrix:
include:
- platform: Ubuntu 24.04
os: "ubuntu-24.04"
test-script: "./unix.sh linux"
- platform: Ubuntu 22.04
os: "ubuntu-22.04"
test-script: "./unix.sh linux"
- platform: Ubuntu 20.04
os: "ubuntu-20.04"
test-script: "./unix.sh linux"
- platform: MacOS 14 (M1)
os: "macos-14"
test-script: "./unix.sh darwin"
- platform: MacOS 13
os: "macos-13"
test-script: "./unix.sh darwin"
- platform: MacOS 12
os: "macos-12"
test-script: "./unix.sh darwin"
- platform: Windows 2022
os: "windows-2022"
test-script: ".\\windows.bat"
- platform: Windows 2019
os: "windows-2019"
test-script: ".\\windows.bat"
fail-fast: false
name: Test on ${{ matrix.platform }}
runs-on: ${{ matrix.os }}
steps:
- name: Get our distributables
uses: actions/download-artifact@v4
with:
name: distributables
path: distributables
- name: Get the test scripts
uses: actions/download-artifact@v4
with:
name: test-scripts
path: .
- name: Make the test script executable
if: matrix.platform != 'Windows'
run: chmod +x unix.sh
- name: Test the server build
run: ${{ matrix.test-script }}
publish:
name: Publish a release
runs-on: "ubuntu-22.04"
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs:
- build
- test-distributables
steps:
- name: Get our distributables
uses: actions/download-artifact@v4
with:
name: distributables
path: distributables
- name: Upload server release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./distributables/*/*
file_glob: true
tag: ${{ github.ref }}
- name: Upload latest manifest
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./distributables/latest-manifest/*
file_glob: true
tag: latest-manifest
overwrite: true