Create upgrade-test.yaml #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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. | |
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven | |
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
name: Ranger Upgrade | |
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: | |
install_n_upgrade: | |
strategy: | |
fail-fast: false # Ensures all matrix jobs run to completion | |
matrix: | |
db: [postgres, mysql] | |
release: [ranger-2.4, ranger-2.5] | |
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 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 | |
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 = release_branch.split('-')[1] + '.1-SNAPSHOT' | |
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: Clean up Docker space | |
run: docker system prune --all --force --volumes | |
- name: Bring up containers | |
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 -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") | |
# Step 3: Wait for the container to exit | |
echo "Waiting for $CONTAINER_ID to exit..." | |
while [ "$(docker inspect -f '{{.State.Status}}' $CONTAINER_ID)" != "exited" ]; do | |
sleep 20 | |
done | |
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 | |
with open(r'.env', 'r') as file: | |
data = file.read() | |
release_branch = "$RELEASE" | |
data = data.replace(f'BRANCH={release_branch}', 'BRANCH=ranger-2.6') | |
ranger_version = release_branch.split('-')[1] + '.0-SNAPSHOT' | |
data = data.replace(ranger_version, '2.6.0-SNAPSHOT') | |
with open(r'.env', 'w') as file: | |
file.write(data) | |
EOF | |
cat .env | |
- name: Upgrade Ranger | |
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 -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") | |
# Step 3: Wait for the container to exit | |
echo "Waiting for $CONTAINER_ID to exit..." | |
while [ "$(docker inspect -f '{{.State.Status}}' $CONTAINER_ID)" != "exited" ]; do | |
sleep 20 | |
done | |
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 | |