forked from mattermost/mattermost
-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (77 loc) · 3.13 KB
/
migration.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
name: Database Migration Test
on:
workflow_call:
jobs:
test:
name: MySQL -> Postgres Migration
runs-on: ubuntu-22.04
env:
COMPOSE_PROJECT_NAME: ghactions
TEST_IMAGE: migration-test-image
defaults:
run:
working-directory: server
steps:
- name: Checkout mattermost project
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Calculate Golang Version
id: go
working-directory: ./server
run: echo GO_VERSION=$(cat .go-version) >> "${GITHUB_OUTPUT}"
- name: Run docker compose
run: |
cd build
docker compose --ansi never run --rm start_dependencies
docker compose --ansi never exec -T minio sh -c 'mkdir -p /data/mattermost-test';
docker compose --ansi never ps
- name: Fix MySQL user permissions
run: |
cd build
docker exec ${COMPOSE_PROJECT_NAME}-mysql-1 sh -c "sed -i '/# default-authentication-plugin/c\default-authentication-plugin=mysql_native_password' /etc/my.cnf"
docker exec ${COMPOSE_PROJECT_NAME}-mysql-1 sh -c "mysql -u root -pmostest -e \"ALTER USER 'mmuser'@'%' IDENTIFIED WITH mysql_native_password BY 'mostest';\""
docker exec ${COMPOSE_PROJECT_NAME}-mysql-1 sh -c "mysql -u root -pmostest -e \"ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'mostest';\""
docker restart ${COMPOSE_PROJECT_NAME}-mysql-1 && sleep 10
- name: Build test image
env:
BUILD_IMAGE: mattermostdevelopment/mattermost-build-server:${{ steps.go.outputs.GO_VERSION }}
run: |
echo -e "FROM $BUILD_IMAGE\n\nRUN apt update && \
apt remove -y pgloader && \
apt install -y sbcl unzip libsqlite3-dev make curl gawk freetds-dev libzip-dev && \
git clone https://github.com/dimitri/pgloader.git && \
cd pgloader && \
make && \
mv build/bin/pgloader /bin" >> dockerfile_tmp
docker build -t $TEST_IMAGE - < dockerfile_tmp
- name: Generate test-data
run: |
docker run --net ${COMPOSE_PROJECT_NAME}_mm-test \
--ulimit nofile=8096:8096 \
--env-file=build/dotenv/migration.env \
-v $(go env GOCACHE):/go/cache \
-e GOCACHE=/go/cache \
-v $PWD:/mattermost \
-w /mattermost \
$TEST_IMAGE \
make test-data
- name: Migrate the DB and compare
run: |
docker run --net ${COMPOSE_PROJECT_NAME}_mm-test \
--ulimit nofile=8096:8096 \
--env-file=build/dotenv/migration.env \
-v $(go env GOCACHE):/go/cache \
-e GOCACHE=/go/cache \
-v $PWD:/mattermost \
-w /mattermost \
$TEST_IMAGE \
make test-migration
- name: Upload artifacts
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
name: Migration logs
path: server/migration.log
retention-days: 7
- name: Stop docker compose
run: |
cd build
docker compose --ansi never stop