forked from ONLYOFFICE/DocSpace-buildtools
-
Notifications
You must be signed in to change notification settings - Fork 0
215 lines (188 loc) · 8.5 KB
/
ci-oci-install.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
208
209
210
211
212
213
214
215
name: Install OneClickInstall DocSpace
on:
# pull_request:
# types: [opened, reopened, synchronize]
# paths:
# - '.github/workflows/ci-oci-install.yml'
# - 'install/OneClickInstall/install-Debian/**'
# - 'install/OneClickInstall/install-RedHat/**'
# - 'install/OneClickInstall/install-Debian.sh'
# - 'install/OneClickInstall/install-RedHat.sh'
# schedule:
# - cron: '00 20 * * 6' # At 23:00 on Saturday.
workflow_dispatch:
inputs:
centos8s:
type: boolean
description: 'CentOS 8 Stream'
default: true
centos9s:
type: boolean
description: 'CentOS 9 Stream'
default: true
debian11:
type: boolean
description: 'Debian 11'
default: true
debian12:
type: boolean
description: 'Debian 12'
default: true
ubuntu2004:
type: boolean
description: 'Ubuntu 20.04'
default: true
ubuntu2204:
type: boolean
description: 'Ubuntu 22.04'
default: true
ubuntu2404:
type: boolean
description: 'Ubuntu 24.04'
default: true
fedora39:
type: boolean
description: 'Fedora 39'
default: true
fedora40:
type: boolean
description: 'Fedora 40'
default: true
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout code
if: github.event_name == 'pull_request'
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine affected distributions
id: determine-distros
if: github.event_name == 'pull_request'
run: |
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }})
echo "debian_changed=$(echo "$CHANGED_FILES" | grep -q 'install-Debian' && echo true || echo false)" >> $GITHUB_ENV
echo "redhat_changed=$(echo "$CHANGED_FILES" | grep -q 'install-RedHat' && echo true || echo false)" >> $GITHUB_ENV
- name: Set matrix names
id: set-matrix
run: |
matrix=$(echo '{
"include": [
{"execute": '${{ github.event.inputs.centos8s || true }}', "name": "CentOS8S", "os": "centos8s", "distr": "generic"},
{"execute": '${{ github.event.inputs.centos9s || true }}', "name": "CentOS9S", "os": "centos9s", "distr": "generic"},
{"execute": '${{ github.event.inputs.debian11 || true }}', "name": "Debian11", "os": "debian11", "distr": "generic"},
{"execute": '${{ github.event.inputs.debian12 || true }}', "name": "Debian12", "os": "debian12", "distr": "generic"},
{"execute": '${{ github.event.inputs.ubuntu2004 || true }}', "name": "Ubuntu20.04", "os": "ubuntu2004", "distr": "generic"},
{"execute": '${{ github.event.inputs.ubuntu2204 || true }}', "name": "Ubuntu22.04", "os": "ubuntu2204", "distr": "generic"},
{"execute": '${{ github.event.inputs.ubuntu2404 || true }}', "name": "Ubuntu24.04", "os": "ubuntu-24.04", "distr": "bento"},
{"execute": '${{ github.event.inputs.fedora39 || true }}', "name": "Fedora39", "os": "39-cloud-base", "distr": "fedora"},
{"execute": '${{ github.event.inputs.fedora40 || true }}', "name": "Fedora40", "os": "fedora-40", "distr": "bento"}
]
}' | jq -c '.include')
matrix=$(jq -c --arg REDHAT_CHANGED "${{ env.redhat_changed }}" --arg DEBIAN_CHANGED "${{ env.debian_changed }}" '
{ include: [.[] | select(
($REDHAT_CHANGED == "true" and $DEBIAN_CHANGED == "true" and .execute == true) or
($REDHAT_CHANGED == "true" and (.name | test("CentOS|Fedora"))) or
($DEBIAN_CHANGED == "true" and (.name | test("Debian|Ubuntu"))) or
($REDHAT_CHANGED != "true" and $DEBIAN_CHANGED != "true" and .execute == true))]
}' <<< "$matrix")
echo "matrix=${matrix}" >> $GITHUB_OUTPUT
vagrant-up:
name: "Test DocSpace with ${{ matrix.name}}"
runs-on: ubuntu-22.04
needs: prepare
strategy:
fail-fast: false
matrix: ${{fromJSON(needs.prepare.outputs.matrix)}}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Get update and install vagrant
run: |
- name: Get update and install vagrant
run: |
set -eux
sudo apt-get remove --purge virtualbox || true # Удаляем старую версию, если есть
# Добавляем репозитории VirtualBox 7
curl https://www.virtualbox.org/download/oracle_vbox_2016.asc | gpg --dearmor > oracle_vbox_2016.gpg
curl https://www.virtualbox.org/download/oracle_vbox.asc | gpg --dearmor > oracle_vbox.gpg
sudo install -o root -g root -m 644 oracle_vbox_2016.gpg /etc/apt/trusted.gpg.d/
sudo install -o root -g root -m 644 oracle_vbox.gpg /etc/apt/trusted.gpg.d/
echo "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list
# Обновляем пакеты
sudo apt update -y
# Устанавливаем зависимости
sudo apt install -y linux-headers-$(uname -r) dkms
# Устанавливаем VirtualBox 7
sudo apt install -y virtualbox-7.0
# Устанавливаем Vagrant
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update -y
sudo apt install -y vagrant
# Устанавливаем плагин vagrant-vbguest
vagrant plugin install vagrant-vbguest
# Выводим версии
echo "Vagrant version: $(vagrant --version)"
echo "VirtualBox version: $(vboxmanage --version)"
- name: Free Disk Space
run: |
sudo rm -rf /usr/local/lib/android /opt/ghc
sudo docker image prune --all --force
- name: "Test production scripts with ${{matrix.name}}"
if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
uses: nick-fields/retry@v3
with:
max_attempts: 2
timeout_minutes: 80
retry_on: error
command: |
set -eux
cd tests/vagrant
cat Vagrantfile
# Экспортируем переменные
export TEST_CASE='--production-install'
export DISTR='${{ matrix.distr }}'
export OS='${{ matrix.os }}'
export DOWNLOAD_SCRIPT='-ds true'
export RAM='1024'
export CPU='1'
export ARGUMENTS="-arg '--skiphardwarecheck true'"
# Запускаем vagrant с sudo, используя -E для передачи переменных
sudo -E vagrant up --provider=virtualbox
on_retry_command: |
echo "RUN CLEAN UP: Destroy vagrant and one more try"
cd tests/vagrant
sleep 10
vagrant destroy --force
- name: "Test Local scripts with ${{matrix.name}}"
if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }}
uses: nick-fields/retry@v3
with:
max_attempts: 2
timeout_minutes: 80
retry_on: error
command: |
set -eux
cd tests/vagrant
export TEST_CASE='--local-install' \
export DISTR='${{ matrix.distr }}' \
export OS='${{matrix.os}}' \
export RAM='5100' \
export CPU='3' \
export DOWNLOAD_SCRIPT='-ds false' \
export TEST_REPO='-tr true' \
export ARGUMENTS="-arg '--skiphardwarecheck true --localscripts true'" \
sudo -E vagrant up --provider=virtualbox
on_retry_command: |
echo "RUN CLEAN UP: Destroy vagrant and one more try"
cd tests/vagrant
sleep 10
vagrant destroy --force