Skip to content

Commit

Permalink
Reuse the docker-compose section into a separate github action workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jarodmeng committed Jan 3, 2025
1 parent 4a09eea commit a511ce1
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 28 deletions.
31 changes: 3 additions & 28 deletions .github/workflows/check-standard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,35 +47,10 @@ jobs:
extra-packages: any::rcmdcheck
needs: check

# Install Docker Compose on Ubuntu
- name: Install Docker Compose on Ubuntu
# Install docker-compose and set up presto/trino servers
- name: Setup Presto and Trino servers
if: matrix.config.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y docker-compose
# Start Docker Compose services
- name: Start services with Docker Compose
if: matrix.config.os == 'ubuntu-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'
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: ./.github/workflows/setup-presto-trino-servers.yaml

- uses: r-lib/actions/check-r-package@v2
with:
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/setup-presto-trino-servers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Set up Presto and Trino servers

on:
workflow_call:

jobs:
setup-presto-trino-servers:
runs-on: ubuntu-latest
steps:
# Install Docker Compose on Ubuntu
- name: Install Docker Compose on Ubuntu
run: |
sudo apt-get update
sudo apt-get install -y docker-compose
# Start Docker Compose services
- name: Start services with Docker Compose
run: |
docker-compose up -d
# Ensure Presto and Trino servers are running
- name: Wait for Presto and Trino to be ready
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
10 changes: 10 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ jobs:
extra-packages: any::covr
needs: coverage

# Install docker-compose and set up presto/trino servers
- name: Setup Presto and Trino servers
uses: ./.github/workflows/setup-presto-trino-servers.yaml

- name: Test coverage
run: covr::codecov(quiet = FALSE)
shell: Rscript {0}

# Stop and remove Docker containers
- name: Stop and remove Docker containers
run: |
docker stop $(docker ps -q) || true
docker rm $(docker ps -aq) || true

0 comments on commit a511ce1

Please sign in to comment.