From ad26c95de03863cd870496e36779285ff0a6ede3 Mon Sep 17 00:00:00 2001 From: "Jarod G.R. Meng" Date: Fri, 3 Jan 2025 10:07:26 +0800 Subject: [PATCH] Add a docker-compose file to set up presto and trino servers for unit testing and use those servers in github action --- .github/workflows/check-standard.yaml | 33 +++++++++++++++++++++++++++ docker-compose.yml | 18 +++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 docker-compose.yml diff --git a/.github/workflows/check-standard.yaml b/.github/workflows/check-standard.yaml index 52c2b27..3f4f5b7 100644 --- a/.github/workflows/check-standard.yaml +++ b/.github/workflows/check-standard.yaml @@ -5,6 +5,7 @@ on: branches: [main, master] pull_request: branches: [main, master] + workflow_dispatch: {} name: R-CMD-check @@ -27,6 +28,8 @@ jobs: env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} R_KEEP_PKG_SOURCE: yes + PRESTO_VERSION: "${{ matrix.config.presto_version || 'latest' }}" + TRINO_VERSION: "${{ matrix.config.trino_version || 'latest' }}" steps: - uses: actions/checkout@v2 @@ -44,6 +47,36 @@ jobs: extra-packages: any::rcmdcheck needs: check + # Install Docker and Docker Compose on macOS + - name: Install Docker on macOS + if: matrix.config.os == 'macOS-latest' + run: | + brew install --cask docker + brew install docker-compose + + # Start Docker Compose services + - name: Start services with Docker Compose + if: matrix.config.os == 'ubuntu-latest' || matrix.config.os == 'macOS-latest' + run: | + docker-compose up -d + + # Ensure Presto and Trino servers are running + - name: Wait for Presto and Trino to be ready + if: matrix.config.os == 'ubuntu-latest' || matrix.config.os == 'macOS-latest' + run: | + for i in {1..30}; do + if curl -s http://localhost:8080/v1/info && curl -s http://localhost:8090/v1/info; then + echo "Presto and Trino are up and running." + break + fi + echo "Waiting for Presto and Trino to be ready..." + sleep 5 + done + if ! curl -s http://localhost:8080/v1/info || ! curl -s http://localhost:8090/v1/info; then + echo "Presto or Trino did not start in time. Exiting." + exit 1 + fi + - uses: r-lib/actions/check-r-package@v2 with: upload-snapshots: true diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..2232719 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,18 @@ +services: + presto: + image: prestodb/presto:${PRESTO_VERSION:-latest} + container_name: presto + ports: + - "8080:8080" + volumes: + - ./prestodb_presto/etc:/opt/presto-server/etc + restart: unless-stopped + + trino: + image: trinodb/trino:${TRINO_VERSION:-latest} + container_name: trino + ports: + - "8090:8080" + volumes: + - ./trinodb_trino/etc:/usr/lib/trino/etc + restart: unless-stopped