-
Notifications
You must be signed in to change notification settings - Fork 1k
197 lines (174 loc) · 6.98 KB
/
test-upgrade.yaml
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
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Upgrade Ranger
on:
push:
pull_request:
branches: [ "master" ]
env:
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3
jobs:
build:
strategy:
fail-fast: false # Ensures all matrix jobs run to completion
matrix:
release: [ranger-2.4, ranger-2.5, ranger-2.6] # builds all these release versions
runs-on: ubuntu-22.04
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- name: Cache for maven dependencies
uses: actions/cache@v4
with:
path: |
~/.m2/repository/*/*/*
!~/.m2/repository/org/apache/ranger
key: maven-repo-${{ hashFiles('**/pom.xml') }}
restore-keys: |
maven-repo-
- name: Set up .m2 directory and permissions
run: |
mkdir -p ~/.m2/repository
chmod -R 777 ~/.m2
chmod -R 777 ./
- name: Set up JDK 8
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'temurin'
- name: Update .env
run: |
cd dev-support/ranger-docker
RELEASE="${{ matrix.release }}"
python3 <<EOF
branch_to_version = {"ranger-2.4": "2.4.1-SNAPSHOT", "ranger-2.5": "2.5.1-SNAPSHOT", "ranger-2.6": "2.6.0"}
with open(r'.env', 'r') as file:
data = file.read()
release_branch = "$RELEASE"
data = data.replace('BUILD_HOST_SRC=true', 'BUILD_HOST_SRC=false')
data = data.replace('BRANCH=master', f'BRANCH={release_branch}')
ranger_version = branch_to_version[release_branch]
data = data.replace('3.0.0-SNAPSHOT', ranger_version)
with open(r'.env', 'w') as file:
file.write(data)
EOF
cat .env
- name: Clean up Docker space
run: docker system prune --all --force --volumes
- name: Build Ranger in Docker
run: |
cd dev-support/ranger-docker
export DOCKER_BUILDKIT=1
export COMPOSE_DOCKER_CLI_BUILD=1
docker compose -f docker-compose.ranger-base.yml -f docker-compose.ranger-build.yml build
docker compose -f docker-compose.ranger-base.yml -f docker-compose.ranger-build.yml up -d
# Get container ID of ranger-build
CONTAINER_ID=$(docker ps -aqf "name=ranger-build")
docker logs -f $CONTAINER_ID &
# Wait for the container to exit
docker wait $CONTAINER_ID
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.release }}-build-artifacts
path: dev-support/ranger-docker/dist/*
upgrade:
needs: build
strategy:
fail-fast: false
matrix:
release: [ranger-2.4, ranger-2.5]
db: [postgres, mysql, oracle]
runs-on: ubuntu-22.04
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- name: Set up JDK 8
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'temurin'
- name: Download release artifacts
uses: actions/download-artifact@v4
with:
name: ${{ matrix.release }}-build-artifacts
- name: Download release artifacts for upgrade
uses: actions/download-artifact@v4
with:
name: ranger-2.6-build-artifacts
- name: Copy artifacts for docker build
run: |
cp ranger-*.tar.gz dev-support/ranger-docker/dist
cp version dev-support/ranger-docker/dist
ls -lrt dev-support/ranger-docker/dist/
- name: Update .env
run: |
cd dev-support/ranger-docker
RELEASE="${{ matrix.release }}"
python3 <<EOF
branch_to_version = {"ranger-2.4": "2.4.1-SNAPSHOT", "ranger-2.5": "2.5.1-SNAPSHOT", "ranger-2.6": "2.6.0"}
with open(r'.env', 'r') as file:
data = file.read()
release_branch = "$RELEASE"
ranger_version = branch_to_version[release_branch]
data = data.replace('3.0.0-SNAPSHOT', ranger_version)
with open(r'.env', 'w') as file:
file.write(data)
EOF
cat .env
- name: Run download-archives.sh
run: |
cd dev-support/ranger-docker
./download-archives.sh none
- name: Bringing up ${{ matrix.release }} in docker
run: |
cd dev-support/ranger-docker
export DOCKER_BUILDKIT=1
export COMPOSE_DOCKER_CLI_BUILD=1
export RANGER_DB_TYPE=${{ matrix.db }}
docker compose -f docker-compose.ranger-base.yml build
docker compose -f docker-compose.ranger.yml -f docker-compose.ranger-${RANGER_DB_TYPE}.yml build
docker compose -f docker-compose.ranger.yml -f docker-compose.ranger-${RANGER_DB_TYPE}.yml up -d
sleep 30
docker logs ranger
- name: Update .env for upgrade
run: |
cd dev-support/ranger-docker
RELEASE="${{ matrix.release }}"
python3 <<EOF
branch_to_version = {"ranger-2.4": "2.4.1-SNAPSHOT", "ranger-2.5": "2.5.1-SNAPSHOT", "ranger-2.6": "2.6.0"}
with open(r'.env', 'r') as file:
data = file.read()
release_branch = "$RELEASE"
ranger_version = branch_to_version[release_branch]
data = data.replace(ranger_version, branch_to_version["ranger-2.6"])
with open(r'.env', 'w') as file:
file.write(data)
EOF
cat .env
- name: Upgrading to ranger-2.6 in docker
run: |
cd dev-support/ranger-docker
export DOCKER_BUILDKIT=1
export COMPOSE_DOCKER_CLI_BUILD=1
export RANGER_DB_TYPE=${{ matrix.db }}
docker compose -f docker-compose.ranger-base.yml build
docker compose -f docker-compose.ranger.yml -f docker-compose.ranger-${RANGER_DB_TYPE}.yml build
docker compose -f docker-compose.ranger.yml -f docker-compose.ranger-${RANGER_DB_TYPE}.yml up -d
sleep 180
docker logs ranger
- name: Remove running containers
run: |
docker stop $(docker ps -q) && docker rm $(docker ps -aq)