Skip to content

Commit c8dd9a0

Browse files
committed
Merge branch 'master' of github.com:Altinity/clickhouse-backup into zerolog,
apply suggestion from #670 (comment), test should pass # Conflicts: # .github/workflows/build.yaml # .github/workflows/release.yaml # Dockerfile # Vagrantfile # cmd/clickhouse-backup/main.go # go.mod # go.sum # pkg/backup/backup_shard.go # pkg/backup/backuper.go # pkg/backup/create.go # pkg/backup/delete.go # pkg/backup/download.go # pkg/backup/list.go # pkg/backup/restore.go # pkg/backup/table_pattern.go # pkg/backup/upload.go # pkg/backup/watch.go # pkg/clickhouse/clickhouse.go # pkg/config/config.go # pkg/custom/delete_custom.go # pkg/custom/download_custom.go # pkg/custom/list_custom.go # pkg/custom/upload_custom.go # pkg/filesystemhelper/filesystemhelper.go # pkg/logfmt/logfmt_test.go # pkg/metadata/load.go # pkg/server/callback_test.go # pkg/server/server.go # pkg/status/status.go # pkg/storage/ftp.go # pkg/storage/gcs.go # pkg/storage/general.go # pkg/storage/object_disk/object_disk.go # pkg/storage/s3.go # pkg/storage/sftp.go # pkg/utils/utils.go # test/integration/install_delve.sh # test/integration/integration_test.go
2 parents 8e963d1 + 0a3a9f2 commit c8dd9a0

File tree

131 files changed

+9556
-5176
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+9556
-5176
lines changed

.github/workflows/build.yaml

Lines changed: 104 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ jobs:
1616
strategy:
1717
matrix:
1818
golang-version:
19-
- "1.21"
19+
- "1.22"
2020
steps:
2121
- name: Checkout project
22-
uses: actions/checkout@v3
22+
uses: actions/checkout@v4
2323

2424
- name: Setup golang
2525
id: setup-go
26-
uses: actions/setup-go@v3
26+
uses: actions/setup-go@v5
2727
with:
2828
go-version: '^${{ matrix.golang-version }}'
2929

@@ -32,24 +32,24 @@ jobs:
3232
run: |
3333
sudo apt-get install -y musl-tools musl-dev
3434
35-
- name: Cache golang
36-
id: cache-golang
37-
uses: actions/cache@v3
38-
with:
39-
path: |
40-
~/go/pkg/mod
41-
~/.cache/go-build
42-
key: clickhouse-backup-golang-${{ matrix.golang-version }}-${{ hashFiles('go.mod', '.github/workflows/*.yaml') }}
35+
# - name: Cache golang
36+
# id: cache-golang
37+
# uses: actions/cache@v4
38+
# with:
39+
# path: |
40+
# ~/go/pkg/mod
41+
# ~/.cache/go-build
42+
# key: clickhouse-backup-golang-${{ matrix.golang-version }}-${{ hashFiles('go.mod', '.github/workflows/*.yaml') }}
4343

4444
- name: Install golang dependencies
4545
run: go mod download -x
46-
if: |
47-
steps.cache-golang.outputs.cache-hit != 'true'
46+
# if: |
47+
# steps.cache-golang.outputs.cache-hit != 'true'
4848

4949
- name: Build clickhouse-backup binary
5050
id: make-race
5151
env:
52-
GOROOT: ${{ env.GOROOT_1_20_X64 }}
52+
GOROOT: ${{ env.GOROOT_1_22_X64 }}
5353
run: |
5454
make build/linux/amd64/clickhouse-backup build/linux/arm64/clickhouse-backup
5555
make build/linux/amd64/clickhouse-backup-fips build/linux/arm64/clickhouse-backup-fips
@@ -76,7 +76,7 @@ jobs:
7676
fi
7777
echo "GCS_TESTS=$(if [ -z "${{ secrets.VAULT_PASSWORD }}" ]; then echo "false"; else echo "true"; fi)" >> $GITHUB_OUTPUT
7878
79-
- uses: actions/upload-artifact@v3
79+
- uses: actions/upload-artifact@v4
8080
with:
8181
name: build-gcp-credentials
8282
path: |
@@ -86,7 +86,7 @@ jobs:
8686
if: |
8787
steps.secrets.outputs.GCS_TESTS == 'true'
8888
89-
- uses: actions/upload-artifact@v3
89+
- uses: actions/upload-artifact@v4
9090
with:
9191
name: build-artifacts
9292
path: |
@@ -97,7 +97,7 @@ jobs:
9797
if-no-files-found: error
9898
retention-days: 1
9999

100-
- uses: actions/upload-artifact@v3
100+
- uses: actions/upload-artifact@v4
101101
with:
102102
name: build-test-artifacts
103103
path: |
@@ -114,15 +114,25 @@ jobs:
114114
runs-on: ubuntu-22.04
115115
strategy:
116116
matrix:
117+
golang-version:
118+
- "1.22"
117119
clickhouse:
118120
- '22.3'
119121
- '22.8'
120122
- '23.3'
123+
- '23.8'
124+
- '24.3'
121125
steps:
122126
- name: Checkout project
123-
uses: actions/checkout@v3
127+
uses: actions/checkout@v4
124128

125-
- uses: actions/download-artifact@v3
129+
- name: Setup golang
130+
id: setup-go
131+
uses: actions/setup-go@v5
132+
with:
133+
go-version: '^${{ matrix.golang-version }}'
134+
135+
- uses: actions/download-artifact@v4
126136
with:
127137
name: build-test-artifacts
128138
path: ./clickhouse-backup/
@@ -134,7 +144,7 @@ jobs:
134144
python3 -m venv ~/venv/qa
135145
136146
- name: Cache python
137-
uses: actions/cache@v3
147+
uses: actions/cache@v4
138148
id: cache-python
139149
with:
140150
path: ~/venv/qa
@@ -159,30 +169,26 @@ jobs:
159169
# don't change it to avoid not working CI/CD
160170
RUN_TESTS: "*"
161171
run: |
162-
set -x
172+
set -xe
163173
export CLICKHOUSE_TESTS_DIR=$(pwd)/test/testflows/clickhouse_backup
164174
165-
command -v docker-compose || (sudo apt-get update && sudo apt-get install -y python3-pip && pip3 install -U docker-compose)
166-
docker-compose -f ${CLICKHOUSE_TESTS_DIR}/docker-compose/docker-compose.yml pull
175+
docker compose -f ${CLICKHOUSE_TESTS_DIR}/docker-compose/docker-compose.yml pull
167176
168177
chmod +x $(pwd)/clickhouse-backup/clickhouse-backup*
169178
source ~/venv/qa/bin/activate
170-
set +e
171179
~/venv/qa/bin/python3 ./test/testflows/clickhouse_backup/regression.py --debug --only="${RUN_TESTS:-*}" --log ./test/testflows/raw.log
172-
if [[ "0" != "$?" ]]; then
173-
docker-compose -f ${CLICKHOUSE_TESTS_DIR}/docker-compose/docker-compose.yml logs clickhouse_backup
174-
exit 1
175-
fi
176-
set -e
177180
tfs --debug --no-colors transform compact ./test/testflows/raw.log ./test/testflows/compact.log
178181
tfs --debug --no-colors transform nice ./test/testflows/raw.log ./test/testflows/nice.log.txt
179182
tfs --debug --no-colors transform short ./test/testflows/raw.log ./test/testflows/short.log.txt
180183
tfs --debug --no-colors report results -a "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/" ./test/testflows/raw.log - --confidential --copyright "Altinity LTD" --logo ./test/testflows/altinity.png | ~/venv/qa/bin/tfs --debug --no-colors document convert > ./test/testflows/report.html
181184
sudo chmod -Rv +rx test/testflows/clickhouse_backup/_instances
182185
- name: Format testflows coverage
186+
env:
187+
GOROOT: ${{ env.GOROOT_1_22_X64 }}
183188
run: |
184189
sudo chmod -Rv a+rw test/testflows/_coverage_/
185-
ls -la test/testflows/_coverage_
190+
ls -la test/testflows/_coverage_
191+
go env
186192
go tool covdata textfmt -i test/testflows/_coverage_/ -o test/testflows/_coverage_/coverage.out
187193
- name: Report testflows coverage
188194
uses: coverallsapp/github-action@v2
@@ -191,17 +197,17 @@ jobs:
191197
parallel: true
192198
format: golang
193199
flag-name: testflows-${{ matrix.clickhouse }}
194-
# todo wait when resolve https://github.com/actions/upload-artifact/issues/270 and uncomment
195-
# - name: Upload testflows logs
196-
# uses: actions/upload-artifact@v3
197-
# with:
198-
# name: testflows-logs-and-reports-${{ matrix.clickhouse }}-${{ github.run_id }}
199-
# path: |
200-
# test/testflows/*.log
201-
# test/testflows/*.log.txt
202-
# test/testflows/clickhouse_backup/_instances/**/*.log
203-
# test/testflows/*.html
204-
# retention-days: 7
200+
# todo possible failures https://github.com/actions/upload-artifact/issues/270
201+
- name: Upload testflows logs
202+
uses: actions/upload-artifact@v4
203+
with:
204+
name: testflows-logs-and-reports-${{ matrix.clickhouse }}-${{ github.run_id }}
205+
path: |
206+
test/testflows/*.log
207+
test/testflows/*.log.txt
208+
test/testflows/clickhouse_backup/_instances/**/*.log
209+
test/testflows/*.html
210+
retention-days: 7
205211

206212
test:
207213
needs: build
@@ -210,7 +216,7 @@ jobs:
210216
strategy:
211217
matrix:
212218
golang-version:
213-
- "1.21"
219+
- "1.22"
214220
clickhouse:
215221
- '1.1.54394'
216222
- '19.17'
@@ -221,31 +227,33 @@ jobs:
221227
- '22.3'
222228
- '22.8'
223229
- '23.3'
230+
- '23.8'
231+
- '24.3'
224232
steps:
225233
- name: Checkout project
226-
uses: actions/checkout@v3
234+
uses: actions/checkout@v4
227235

228236
- name: Setup golang
229237
id: setup-go
230-
uses: actions/setup-go@v3
238+
uses: actions/setup-go@v5
231239
with:
232240
go-version: '^${{ matrix.golang-version }}'
233241

234-
- name: Cache golang
235-
id: cache-golang
236-
uses: actions/cache@v3
237-
with:
238-
path: |
239-
~/go/pkg/mod
240-
~/.cache/go-build
241-
key: clickhouse-backup-golang-${{ matrix.golang-version }}-${{ hashFiles('go.mod', '.github/workflows/*.yaml') }}
242+
# - name: Cache golang
243+
# id: cache-golang
244+
# uses: actions/cache@v4
245+
# with:
246+
# path: |
247+
# ~/go/pkg/mod
248+
# ~/.cache/go-build
249+
# key: clickhouse-backup-golang-${{ matrix.golang-version }}-${{ hashFiles('go.mod', '.github/workflows/*.yaml') }}
242250

243-
- uses: actions/download-artifact@v3
251+
- uses: actions/download-artifact@v4
244252
with:
245253
name: build-test-artifacts
246254
path: ./clickhouse-backup/
247255

248-
- uses: actions/download-artifact@v3
256+
- uses: actions/download-artifact@v4
249257
with:
250258
name: build-gcp-credentials
251259
path: ./test/integration/
@@ -254,10 +262,16 @@ jobs:
254262
255263
- name: Running integration tests
256264
env:
265+
RUN_PARALLEL: 3
266+
GOROOT: ${{ env.GOROOT_1_22_X64 }}
257267
CLICKHOUSE_VERSION: ${{ matrix.clickhouse }}
258-
# don't change it to avoid broken CI/CD!!!
259-
# RUN_TESTS: "TestFIPS"
268+
# options for advanced debug CI/CD
269+
# RUN_TESTS: "TestLongListRemote"
260270
# LOG_LEVEL: "debug"
271+
# TEST_LOG_LEVEL: "debug"
272+
# GCS_DEBUG: "true"
273+
# SFTP_DEBUG: "true"
274+
# AZBLOB_DEBUG: "true"
261275
# FTP_DEBUG: "true"
262276
# S3_DEBUG: "true"
263277
CGO_ENABLED: 0
@@ -274,7 +288,7 @@ jobs:
274288
QA_GCS_OVER_S3_SECRET_KEY: ${{ secrets.QA_GCS_OVER_S3_SECRET_KEY }}
275289
QA_GCS_OVER_S3_BUCKET: ${{ secrets.QA_GCS_OVER_S3_BUCKET }}
276290
run: |
277-
set -x
291+
set -xe
278292
echo "CLICKHOUSE_VERSION=${CLICKHOUSE_VERSION}"
279293
echo "GCS_TESTS=${GCS_TESTS}"
280294
@@ -292,13 +306,30 @@ jobs:
292306
export COMPOSE_FILE=docker-compose.yml
293307
fi
294308
295-
command -v docker-compose || (apt-get update && apt-get install -y python3-pip && pip3 install -U docker-compose)
296-
309+
export CUR_DIR="$(pwd)/test/integration"
297310
export CLICKHOUSE_BACKUP_BIN="$(pwd)/clickhouse-backup/clickhouse-backup-race"
298-
docker-compose -f test/integration/${COMPOSE_FILE} up -d || ( docker-compose -f test/integration/${COMPOSE_FILE} ps -a && docker-compose -f test/integration/${COMPOSE_FILE} logs clickhouse && exit 1 )
299-
docker-compose -f test/integration/${COMPOSE_FILE} ps -a
300-
go test -timeout 30m -failfast -tags=integration -run "${RUN_TESTS:-.+}" -v test/integration/integration_test.go
311+
docker compose -f "${CUR_DIR}/${COMPOSE_FILE}" --progress=quiet pull
312+
313+
pids=()
314+
for ((i = 0; i < RUN_PARALLEL; i++)); do
315+
docker compose -f ${CUR_DIR}/${COMPOSE_FILE} --project-name project${i} --progress plain up -d &
316+
pids+=($!)
317+
done
318+
319+
320+
for pid in "${pids[@]}"; do
321+
if wait "$pid"; then
322+
echo "$pid docker compose up successful"
323+
else
324+
echo "$pid the docker compose up failed. Exiting."
325+
exit 1 # Exit with an error code if any command fails
326+
fi
327+
done
328+
329+
go test -parallel ${RUN_PARALLEL} -timeout 60m -failfast -tags=integration -run "${RUN_TESTS:-.+}" -v test/integration/integration_test.go
301330
- name: Format integration coverage
331+
env:
332+
GOROOT: ${{ env.GOROOT_1_22_X64 }}
302333
run: |
303334
sudo chmod -Rv a+rw test/integration/_coverage_/
304335
ls -la test/integration/_coverage_
@@ -329,9 +360,9 @@ jobs:
329360
runs-on: ubuntu-22.04
330361
steps:
331362
- name: Checkout project
332-
uses: actions/checkout@v3
363+
uses: actions/checkout@v4
333364

334-
- uses: actions/download-artifact@v3
365+
- uses: actions/download-artifact@v4
335366
with:
336367
name: build-artifacts
337368
path: ./build/linux/
@@ -344,9 +375,9 @@ jobs:
344375
echo "docker_tag=${DOCKER_TAG:-dev}" >> $GITHUB_OUTPUT
345376
346377
- name: Set up QEMU
347-
uses: docker/setup-qemu-action@v2
378+
uses: docker/setup-qemu-action@v3
348379
- name: Set up Docker Buildx
349-
uses: docker/setup-buildx-action@v2
380+
uses: docker/setup-buildx-action@v3
350381

351382
- name: Building docker image
352383
env:
@@ -360,9 +391,11 @@ jobs:
360391
if [[ "${DOCKER_TOKEN}" != "" ]]; then
361392
export DOCKER_REGISTRY=${DOCKER_REGISTRY:-docker.io}
362393
echo ${DOCKER_TOKEN} | docker login -u ${DOCKER_USER} --password-stdin ${DOCKER_REGISTRY}
363-
docker buildx build --progress=plain --platform=linux/amd64,linux/arm64 --tag=${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:${DOCKER_TAG} --target=image_short --pull --push .
364-
docker buildx build --progress=plain --platform=linux/amd64,linux/arm64 --tag=${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:${DOCKER_TAG}-fips --target=image_fips --pull --push .
365-
docker buildx build --progress=plain --platform=linux/amd64,linux/arm64 --tag=${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}-full:${DOCKER_TAG} --target=image_full --pull --push .
394+
export VERSION=$(git describe --always --tags --abbrev=0 2>/dev/null | sed 's/^v//;s/\([^-]*-g\)/c\1/;s/-/./g')
395+
396+
docker buildx build --progress=plain --platform=linux/amd64,linux/arm64 --tag=${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:${DOCKER_TAG} --build-arg VERSION=$VERSION --target=image_short --pull --push .
397+
docker buildx build --progress=plain --platform=linux/amd64,linux/arm64 --tag=${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:${DOCKER_TAG}-fips --build-arg VERSION=$VERSION --target=image_fips --pull --push .
398+
docker buildx build --progress=plain --platform=linux/amd64,linux/arm64 --tag=${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}-full:${DOCKER_TAG} --build-arg VERSION=$VERSION --target=image_full --pull --push .
366399
fi
367400
368401
cleanup:
@@ -374,13 +407,13 @@ jobs:
374407
if: always()
375408
steps:
376409
- name: delete build-artifacts
377-
uses: geekyeggo/delete-artifact@v2
410+
uses: geekyeggo/delete-artifact@v5
378411
with:
379412
name: build-artifacts
380413
failOnError: false
381414

382415
- name: delete build-gcp-credentials
383-
uses: geekyeggo/delete-artifact@v2
416+
uses: geekyeggo/delete-artifact@v5
384417
with:
385418
name: build-gcp-credentials
386419
failOnError: false

0 commit comments

Comments
 (0)