From 53ff310ee59b0475ee898219fb03fe5df7fb6d50 Mon Sep 17 00:00:00 2001 From: Ihor Vovk Date: Sat, 9 Nov 2024 14:13:59 +0100 Subject: [PATCH] Extract elasticsearch launch into its own action, add startup check --- .github/actions/launch-elasticsearch/action.yml | 14 ++++++++++++++ .github/workflows/build.yml | 6 +++--- .github/workflows/pr.yml | 6 +++--- 3 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 .github/actions/launch-elasticsearch/action.yml diff --git a/.github/actions/launch-elasticsearch/action.yml b/.github/actions/launch-elasticsearch/action.yml new file mode 100644 index 000000000..546aab0bb --- /dev/null +++ b/.github/actions/launch-elasticsearch/action.yml @@ -0,0 +1,14 @@ +name: Launch Elastic + +runs: + using: 'composite' + + steps: + - name: 'Launch elastic docker' + shell: bash + run: | + docker run -d -p 39227:9200 -p 39337:9300 -e "discovery.type=single-node" -v /home/runner/work/elastic4s/elastic4s/elastic4s-tests/src/test/resources/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml docker.elastic.co/elasticsearch/elasticsearch:8.15.3 + - name: 'Wait for cluster to start' + shell: bash + run: | + curl -s -S --retry 10 --retry-delay 5 --retry-all-errors "localhost:39227/_cluster/health?wait_for_status=green&timeout=50s" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ef23bd3ca..0d47a4c29 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,7 +27,7 @@ jobs: java-version: 11 - name: Launch elastic docker - run: docker run -d -it -p 39227:9200 -p 39337:9300 -e "discovery.type=single-node" -v /home/runner/work/elastic4s/elastic4s/elastic4s-tests/src/test/resources/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml docker.elastic.co/elasticsearch/elasticsearch:8.15.3 + uses: ./.github/actions/launch-elasticsearch - name: run tests run: sbt ++2.12.20 test @@ -47,7 +47,7 @@ jobs: java-version: 11 - name: Launch elastic docker - run: docker run -d -it -p 39227:9200 -p 39337:9300 -e "discovery.type=single-node" -v /home/runner/work/elastic4s/elastic4s/elastic4s-tests/src/test/resources/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml docker.elastic.co/elasticsearch/elasticsearch:8.15.3 + uses: ./.github/actions/launch-elasticsearch - name: run tests run: sbt ++2.13.15 test @@ -67,7 +67,7 @@ jobs: java-version: 11 - name: Launch elastic docker - run: docker run -d -it -p 39227:9200 -p 39337:9300 -e "discovery.type=single-node" -v /home/runner/work/elastic4s/elastic4s/elastic4s-tests/src/test/resources/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml docker.elastic.co/elasticsearch/elasticsearch:8.15.3 + uses: ./.github/actions/launch-elasticsearch - name: run tests run: sbt ++3.3.4 elastic4s-scala3/test diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index aedc4d175..b4486f991 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -23,7 +23,7 @@ jobs: java-version: 11 - name: Launch elastic docker - run: docker run -d -it -p 39227:9200 -p 39337:9300 -e "discovery.type=single-node" -v /home/runner/work/elastic4s/elastic4s/elastic4s-tests/src/test/resources/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml docker.elastic.co/elasticsearch/elasticsearch:8.15.3 + uses: ./.github/actions/launch-elasticsearch - name: run tests timeout-minutes: 30 @@ -44,7 +44,7 @@ jobs: java-version: 11 - name: Launch elastic docker - run: docker run -d -it -p 39227:9200 -p 39337:9300 -e "discovery.type=single-node" -v /home/runner/work/elastic4s/elastic4s/elastic4s-tests/src/test/resources/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml docker.elastic.co/elasticsearch/elasticsearch:8.15.3 + uses: ./.github/actions/launch-elasticsearch - name: run tests timeout-minutes: 30 @@ -65,7 +65,7 @@ jobs: java-version: 11 - name: Launch elastic docker - run: docker run -d -it -p 39227:9200 -p 39337:9300 -e "discovery.type=single-node" -v /home/runner/work/elastic4s/elastic4s/elastic4s-tests/src/test/resources/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml docker.elastic.co/elasticsearch/elasticsearch:8.15.3 + uses: ./.github/actions/launch-elasticsearch - name: run tests run: sbt ++3.3.4 elastic4s-scala3/test