Skip to content

Commit 18a03b9

Browse files
committed
RANGER-5126: Updates to upgrade workflow
- download earlier releases instead of building them - refactor changes to include build-branch as input, for ex: ranger-2.7
1 parent 7831f6c commit 18a03b9

File tree

3 files changed

+184
-0
lines changed

3 files changed

+184
-0
lines changed
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
name: Upgrade Ranger
17+
18+
on:
19+
workflow_dispatch:
20+
inputs:
21+
build-branch:
22+
description: 'branch to checkout and build'
23+
required: true
24+
25+
jobs:
26+
build:
27+
runs-on: ubuntu-22.04
28+
timeout-minutes: 60
29+
steps:
30+
- uses: actions/checkout@v4
31+
with:
32+
ref: ${{ inputs.build-branch }}
33+
34+
- name: Clean up Docker space
35+
run: docker system prune --all --force --volumes
36+
37+
- name: Build Ranger from branch ${{ inputs.build-branch }} in Docker
38+
run: |
39+
cd dev-support/ranger-docker
40+
docker compose -f docker-compose.ranger-build.yml build
41+
docker compose -f docker-compose.ranger-build.yml up -d
42+
43+
# Get container ID of ranger-build
44+
CONTAINER_ID=$(docker ps -aqf "name=ranger-build")
45+
46+
docker logs -f $CONTAINER_ID &
47+
48+
# Wait for the container to exit
49+
docker wait $CONTAINER_ID
50+
51+
- name: Upload build artifacts
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: ${{ inputs.build-branch }}-build-artifacts
55+
path: dev-support/ranger-docker/dist/*
56+
57+
upgrade:
58+
needs: build
59+
strategy:
60+
fail-fast: false
61+
matrix:
62+
earlier-release: [2.6.0]
63+
db: [postgres, mysql, oracle]
64+
runs-on: ubuntu-22.04
65+
timeout-minutes: 60
66+
steps:
67+
- uses: actions/checkout@v4
68+
with:
69+
ref: ${{ inputs.build-branch }}
70+
71+
- name: Download previous build artifacts
72+
uses: actions/download-artifact@v4
73+
with:
74+
name: ${{ inputs.build-branch }}-build-artifacts
75+
76+
- name: Copy artifacts for docker build
77+
run: |
78+
cp ranger-*.tar.gz dev-support/ranger-docker/dist
79+
cp version dev-support/ranger-docker/dist
80+
ls -lrt dev-support/ranger-docker/dist/
81+
82+
- name: Run download-archives.sh
83+
run: |
84+
cd dev-support/ranger-docker
85+
./download-archives.sh none
86+
87+
- name: Bringing up Ranger ${{ matrix.earlier-release }} in Docker
88+
run: |
89+
cd dev-support/ranger-docker
90+
chmod +x download-ranger.sh && ./download-ranger.sh
91+
export RANGER_DB_TYPE=${{ matrix.db }}
92+
export RANGER_VERSION=${{ matrix.earlier-release }}
93+
docker compose -f docker-compose.ranger.yml build
94+
docker compose -f docker-compose.ranger.yml up -d
95+
sleep 30
96+
docker logs ranger
97+
98+
- name: Upgrading to ${{ inputs.build-branch }} in Docker
99+
run: |
100+
cd dev-support/ranger-docker
101+
export RANGER_DB_TYPE=${{ matrix.db }}
102+
docker compose -f docker-compose.ranger.yml build
103+
docker compose -f docker-compose.ranger.yml up -d
104+
sleep 180
105+
docker logs ranger
106+
107+
- name: Remove running containers
108+
run: |
109+
docker stop $(docker ps -q) && docker rm $(docker ps -aq)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
19+
set -u -o pipefail
20+
21+
: ${BASE_URL:="https://www.apache.org/dyn/closer.lua?action=download&filename="}
22+
: ${CHECKSUM_BASE_URL:="https://downloads.apache.org/"}
23+
: ${RANGER_VERSION:=2.6.0}
24+
25+
source lib.sh
26+
27+
mkdir -p dist
28+
29+
# source
30+
download_and_verify "ranger/${RANGER_VERSION}/apache-ranger-${RANGER_VERSION}.tar.gz"
31+
# binary
32+
download_and_verify "ranger/${RANGER_VERSION}/services/admin/ranger-${RANGER_VERSION}-admin.tar.gz"

dev-support/ranger-docker/lib.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
19+
: ${BASE_URL:="https://www.apache.org/dyn/closer.lua?action=download&filename="}
20+
: ${CHECKSUM_BASE_URL:="https://downloads.apache.org/"}
21+
22+
download_if_not_exists() {
23+
local url="$1"
24+
local file="$2"
25+
26+
if [[ -e "${file}" ]]; then
27+
echo "${file} already downloaded"
28+
else
29+
echo "Downloading ${file} from ${url}"
30+
curl --fail --location --output "${file}" --show-error --silent "${url}" || rm -fv "${file}"
31+
fi
32+
}
33+
34+
download_and_verify() {
35+
local remote_path="$1"
36+
local file="$(basename "${remote_path}")"
37+
38+
pushd dist
39+
download_if_not_exists "${BASE_URL}${remote_path}" "${file}"
40+
download_if_not_exists "${CHECKSUM_BASE_URL}${remote_path}.asc" "${file}.asc"
41+
gpg --verify "${file}.asc" "${file}" || exit 1
42+
popd
43+
}

0 commit comments

Comments
 (0)