Panorama CI #1315
This file contains hidden or 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
| # GitHub action recipe | |
| # preconditions: | |
| # - Install Java | |
| # > wget https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.rpm | |
| # > rpm -Uvh jdk-17_linux-x64_bin.rpm && rm jdk-17_linux-x64_bin.rpm | |
| # - Install Chromium for the dependencies needed by playwright: | |
| # - Install jRuby | |
| # > curl -sSL https://get.rvm.io | bash | |
| # > source "$HOME/.rvm/scripts/rvm" | |
| # > rvm install ${JRUBY_VERSION} | |
| # > rvm --default use ${JRUBY_VERSION} | |
| # > gem install bundler | |
| name: Panorama CI | |
| permissions: | |
| contents: read | |
| on: | |
| push: | |
| branches: | |
| - master | |
| schedule: | |
| # * is a special character in YAML so you have to quote this string, runs each day to keep the free autonomous DB alive | |
| - cron: '0 0 * * *' | |
| jobs: | |
| setup: | |
| runs-on: self-hosted | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Remove orphanded DB containers older than 1 hour from previous runs | |
| run: | | |
| docker ps --filter "name=DB*" | grep "hours ago\|days ago|weeks ago" | awk '{print $1}' | xargs -r docker rm -f | |
| - name: Prepare Gem repo for all tests | |
| run: | | |
| rm -rf /tmp/jruby | |
| JRUBY_VERSION=`cat .ruby-version | cut -c 7-20` | |
| echo "JRUBY_VERSION=$JRUBY_VERSION" | tee -a $GITHUB_ENV | |
| source "$HOME/.rvm/scripts/rvm" | |
| rvm use --default jruby-$JRUBY_VERSION | |
| which bundle | |
| bundle --version | |
| pwd | |
| bundle config deployment 'true' | |
| # All runners should use the same path | |
| bundle config path '/tmp' | |
| bundle lock --add-platform universal-java-21 | |
| bundle lock --add-platform universal-java-24 | |
| bundle install --jobs 4 | |
| # !!! Remember to adjust the "needed" jobs in awaits_tests if changing the test jobs here !!! | |
| test_autonomous_PDB: { uses: "rammpeter/panorama/.github/workflows/run_tests.yml@master", needs: [setup], with: { db_version: "autonomous", container: "PDB", max_parallel: 1 }, secrets: "inherit"} | |
| test_11_2-ee: { uses: "rammpeter/panorama/.github/workflows/run_tests.yml@master", needs: [setup], with: { db_version: "11.2.0.4-ee", container: "PDB", max_parallel: 4 }, secrets: "inherit"} | |
| test_12_1-ee: { uses: "rammpeter/panorama/.github/workflows/run_tests.yml@master", needs: [setup], with: { db_version: "12.1.0.2-ee", container: "PDB", max_parallel: 4 }, secrets: "inherit"} | |
| test_12_2-ee_CDB: { uses: "rammpeter/panorama/.github/workflows/run_tests.yml@master", needs: [setup], with: { db_version: "12.2.0.1-ee", container: "CDB", max_parallel: 4 }, secrets: "inherit"} | |
| test_12_2-ee_PDB: { uses: "rammpeter/panorama/.github/workflows/run_tests.yml@master", needs: [setup], with: { db_version: "12.2.0.1-ee", container: "PDB", max_parallel: 4 }, secrets: "inherit"} | |
| #test_18_3-ee_CDB: { uses: "rammpeter/panorama/.github/workflows/run_tests.yml@master", needs: [setup], with: { db_version: "18.3.0.0-ee", container: "CDB", max_parallel: 4 }, secrets: "inherit"} | |
| #test_18_3-ee_PDB: { uses: "rammpeter/panorama/.github/workflows/run_tests.yml@master", needs: [setup], with: { db_version: "18.3.0.0-ee", container: "PDB", max_parallel: 4 }, secrets: "inherit"} | |
| test_18_4-xe_CDB: { uses: "rammpeter/panorama/.github/workflows/run_tests.yml@master", needs: [setup], with: { db_version: "18.4.0.0-xe", container: "CDB", max_parallel: 4 }, secrets: "inherit"} | |
| # test_18_4-xe_PDB: { uses: "rammpeter/panorama/.github/workflows/run_tests.yml@master", needs: [setup], with: { db_version: "18.4.0.0-xe", container: "PDB", max_parallel: 4 }, secrets: "inherit"} | |
| #test_19_10-ee_CDB: { uses: "rammpeter/panorama/.github/workflows/run_tests.yml@master", needs: [setup], with: { db_version: "19.10.0.0-ee", container: "CDB", max_parallel: 4 }, secrets: "inherit"} | |
| test_19_10-ee_PDB: { uses: "rammpeter/panorama/.github/workflows/run_tests.yml@master", needs: [setup], with: { db_version: "19.10.0.0-ee", container: "PDB", max_parallel: 4 }, secrets: "inherit"} | |
| test_19_10-se2_CDB: { uses: "rammpeter/panorama/.github/workflows/run_tests.yml@master", needs: [setup], with: { db_version: "19.10.0.0-se2", container: "CDB", max_parallel: 4 }, secrets: "inherit"} | |
| test_19_10-se2_PDB: { uses: "rammpeter/panorama/.github/workflows/run_tests.yml@master", needs: [setup], with: { db_version: "19.10.0.0-se2", container: "PDB", max_parallel: 4 }, secrets: "inherit"} | |
| test_21_3-ee_CDB: { uses: "rammpeter/panorama/.github/workflows/run_tests.yml@master", needs: [setup], with: { db_version: "21.3.0.0-ee", container: "CDB", max_parallel: 4 }, secrets: "inherit"} | |
| test_21_3-ee_PDB: { uses: "rammpeter/panorama/.github/workflows/run_tests.yml@master", needs: [setup], with: { db_version: "21.3.0.0-ee", container: "PDB", max_parallel: 4 }, secrets: "inherit"} | |
| test_21_3-se2_CDB: { uses: "rammpeter/panorama/.github/workflows/run_tests.yml@master", needs: [setup], with: { db_version: "21.3.0.0-se2", container: "CDB", max_parallel: 4 }, secrets: "inherit"} | |
| test_21_3-se2_PDB: { uses: "rammpeter/panorama/.github/workflows/run_tests.yml@master", needs: [setup], with: { db_version: "21.3.0.0-se2", container: "PDB", max_parallel: 4 }, secrets: "inherit"} | |
| # test_23_4-free_PDB: { uses: "rammpeter/panorama/.github/workflows/run_tests.yml@master", needs: [setup], with: { db_version: "21.4-free", container: "PDB", max_parallel: 4 }, secrets: "inherit"} | |
| test_23_5-free_CDB: { uses: "rammpeter/panorama/.github/workflows/run_tests.yml@master", needs: [setup], with: { db_version: "23.5.0.24-free", container: "CDB", max_parallel: 4 }, secrets: "inherit"} | |
| test_23_5-free_PDB: { uses: "rammpeter/panorama/.github/workflows/run_tests.yml@master", needs: [setup], with: { db_version: "23.5.0.24-free", container: "PDB", max_parallel: 4 }, secrets: "inherit"} | |
| await_tests: | |
| runs-on: ubuntu-latest | |
| needs: [test_autonomous_PDB, test_11_2-ee, test_12_1-ee, test_12_2-ee_CDB, test_12_2-ee_PDB, test_18_4-xe_CDB, test_19_10-ee_PDB, test_19_10-se2_CDB, test_19_10-se2_PDB, test_21_3-ee_CDB, test_21_3-ee_PDB, test_21_3-se2_CDB, test_21_3-se2_PDB] | |
| steps: | |
| - name: Proceed | |
| run: echo "Proceed with build if all tests passed" | |
| build_docker: | |
| permissions: | |
| packages: write # Crucial: Grants write access to GitHub Packages (GHCR) | |
| runs-on: self-hosted | |
| needs: await_tests | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v6 | |
| - name: Get version numbers | |
| run: | | |
| echo "JRUBY_VERSION=`cat .ruby-version | cut -c 7-20`" >> $GITHUB_ENV | |
| echo JRUBY_VERSION=$JRUBY_VERSION | |
| PANORAMA_VERSION=`cat config/application.rb | grep "VERSION =" | cut -d " " -f5 | sed "s/'//g"` | |
| echo "PANORAMA_VERSION=$PANORAMA_VERSION" >> $GITHUB_ENV | |
| echo PANORAMA_VERSION=$PANORAMA_VERSION | |
| - name: Build and local push Docker image | |
| run: | | |
| for FROM in `grep "^FROM" Dockerfile | grep -v scratch | awk '{print $2}' | tail -n1`; do | |
| echo "Ensure using latest version of $FROM" | |
| docker pull $FROM | |
| done | |
| docker build --build-arg JRUBY_VERSION=$JRUBY_VERSION -t ghcr.io/rammpeter/panorama:ci-temp . | |
| docker login -u rammpeter -p ${{ secrets.GITHUB_TOKEN }} ghcr.io | |
| docker push ghcr.io/rammpeter/panorama:ci-temp | |
| - name: Test Docker image | |
| run: | | |
| echo "Test docker image" | |
| docker run -d --name panorama-ci-test -p 8080:8080 ghcr.io/rammpeter/panorama:ci-temp | |
| docker ps -a | |
| # Wait for the container to become available | |
| MAX_WAIT=240 # 4 minutes | |
| typeset -i LOOPS=0 | |
| while [ $LOOPS -lt $MAX_WAIT ]; do | |
| retval=0 | |
| curl http://localhost:8080/ 2>/dev/null >/dev/null || retval=$? | |
| if [ $retval -eq 0 ]; then | |
| break | |
| fi | |
| LOOPS=LOOPS+1 | |
| echo -n . | |
| sleep 1 | |
| done | |
| if [ $LOOPS -eq $MAX_WAIT ]; then | |
| echo "Docker container not reachable at port 8080 after $LOOPS seconds! Details follow:" | |
| docker logs panorama-ci-test | |
| docker rm -f panorama-ci-test | |
| exit 1 | |
| fi | |
| # Check content of the web interface | |
| if curl -s http://localhost:8080/ | grep -q "Please choose saved connection or"; then | |
| echo "Panorama start page is accessible" | |
| else | |
| echo "Panorama start page is not accessible" | |
| docker logs panorama-ci-test | |
| docker rm -f panorama-ci-test | |
| exit 1 | |
| fi | |
| docker rm -f panorama-ci-test | |
| - name: Final push Docker image | |
| run: | | |
| # Check if release already exists | |
| # Ensure that exit code != 0 does not stop the build | |
| set +e | |
| docker pull ghcr.io/rammpeter/panorama:$PANORAMA_VERSION | |
| if [[ $? -eq 1 ]];then | |
| echo "Image with release $PANORAMA_VERSION does not exist, deploying" | |
| set -e | |
| docker tag ghcr.io/rammpeter/panorama:ci-temp ghcr.io/rammpeter/panorama:$PANORAMA_VERSION | |
| docker tag ghcr.io/rammpeter/panorama:ci-temp ghcr.io/rammpeter/panorama:latest | |
| docker push ghcr.io/rammpeter/panorama:$PANORAMA_VERSION | |
| docker push ghcr.io/rammpeter/panorama:latest | |
| docker login -u rammpeter -p ${{ secrets.DOCKER_IO_API_KEY }} docker.io | |
| docker tag ghcr.io/rammpeter/panorama:latest docker.io/rammpeter/panorama:$PANORAMA_VERSION | |
| docker push docker.io/rammpeter/panorama:$PANORAMA_VERSION | |
| docker tag ghcr.io/rammpeter/panorama:latest docker.io/rammpeter/panorama:latest | |
| docker push docker.io/rammpeter/panorama:latest | |
| else | |
| echo "Image with release $PANORAMA_VERSION already exists, no deployment" | |
| fi | |
| build_jar: | |
| runs-on: self-hosted | |
| needs: await_tests | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v6 | |
| - name: Get version numbers | |
| run: | | |
| echo "JRUBY_VERSION=`cat .ruby-version | cut -c 7-20`" >> $GITHUB_ENV | |
| echo JRUBY_VERSION=$JRUBY_VERSION | |
| - name: Build jar | |
| run: | | |
| source "$HOME/.rvm/scripts/rvm" | |
| rvm use --default jruby-$JRUBY_VERSION | |
| ./build_jar.sh | |
| - name: Archive Panorama.jar | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Panorama.jar | |
| path: Panorama.jar | |
| test_jar: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| java: ['21', '24'] | |
| runs-on: ${{ matrix.os }} | |
| needs: build_jar | |
| steps: | |
| - uses: actions/setup-java@v3 | |
| with: | |
| java-version: ${{ matrix.java }} | |
| distribution: 'temurin' | |
| - uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: '3.4' | |
| bundler-cache: false # runs 'bundle install' and caches installed gems automatically | |
| - name: Check out code | |
| uses: actions/checkout@v6 | |
| - name: Download artifact | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: Panorama.jar | |
| - name: Test Panorama.jar | |
| run: | | |
| echo "Test Panorama.jar" | |
| ruby test/test_panorama_jar.rb | |
| deploy_jar: | |
| permissions: | |
| contents: write # Allow creation of releaes and upload assets | |
| runs-on: self-hosted | |
| needs: test_jar | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v6 | |
| - name: Download artifact | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: Panorama.jar | |
| - name: Final deploy Panorama.jar | |
| run: | | |
| PANORAMA_VERSION=`cat config/application.rb | grep "VERSION =" | cut -d " " -f5 | sed "s/'//g"` | |
| echo "PANORAMA_VERSION=$PANORAMA_VERSION" | |
| # Ensure that exit code != 0 does not stop the build | |
| set +e | |
| # Scan all releases for the version | |
| curl -L -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/rammpeter/panorama/releases | grep tag_name | grep "$PANORAMA_VERSION" | |
| if [[ $? -eq 1 ]];then | |
| echo "Release with version $PANORAMA_VERSION does not exist, deploying" | |
| set -e | |
| # Create release | |
| RES=`curl -L -X POST --silent \ | |
| -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
| https://api.github.com/repos/rammpeter/panorama/releases \ | |
| -d "{\"tag_name\":\"v$PANORAMA_VERSION\",\"target_commitish\":\"master\",\"name\":\"Release $PANORAMA_VERSION\",\"body\":\"Continous development\",\"draft\":false,\"prerelease\":false,\"generate_release_notes\":false}"` | |
| RELEASE_ID=`echo $RES | jq ".id"` | |
| if [[ "$RELEASE_ID" == "null" ]]; then | |
| echo "Release creation failed! Response was:" | |
| echo $RES | |
| exit 1 | |
| fi | |
| # Add asset to release | |
| RES=`curl -L -X POST --silent \ | |
| -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
| -H "Content-Type: application/octet-stream" \ | |
| --data-binary @Panorama.jar \ | |
| "https://uploads.github.com/repos/rammpeter/panorama/releases/$RELEASE_ID/assets?name=Panorama.jar&label=Panorama.jar:%20Download%20and%20start%20with%20\"java%20-jar%20Panorama.jar\""` | |
| URL=`echo $RES | jq ".url"` | |
| if [[ "$URL" == "null" ]]; then | |
| echo "Asset creation for release failed! Response was:" | |
| echo $RES | |
| exit 1 | |
| fi | |
| else | |
| echo "Release with version $PANORAMA_VERSION already exists, no deployment" | |
| fi |