From 72ef8f0343dc276f0a3a9916a321055566c05636 Mon Sep 17 00:00:00 2001 From: PPawlowski Date: Thu, 26 Dec 2024 20:09:03 +0100 Subject: [PATCH 1/2] Wait for containers to build before testing docker compose, do not run on `release-*` branch --- .github/workflows/test-docker-compose.yaml | 80 ++++++++++++++++++++-- 1 file changed, 76 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-docker-compose.yaml b/.github/workflows/test-docker-compose.yaml index 4c58360..065a9b4 100644 --- a/.github/workflows/test-docker-compose.yaml +++ b/.github/workflows/test-docker-compose.yaml @@ -4,19 +4,55 @@ on: push: branches: - main - - '!release-**' + - '!release-*' pull_request: branches: - main - - '!release-**' + jobs: default-stack: name: Test default stack runs-on: ubuntu-latest + if: | + !startsWith(github.head_ref, 'release-') steps: - - name: Checkout repository + - name: Generate a token + id: generate_token + uses: tibdex/github-app-token@v2 + with: + app_id: ${{ secrets.GH_BOT_APP_ID }} + private_key: ${{ secrets.GH_BOT_APP_KEY }} + + - name: Wait for container images build + run: | + while :; do + result=$(gh api repos/:owner/:repo/actions/workflows | jq -r '.workflows[] | select(.name=="Build and push containers") | .id' | xargs -I {} gh api repos/:owner/:repo/actions/workflows/{}/runs --jq '.workflow_runs | max_by(.run_number)') + status=$(echo "$result" | jq -r '.status') + conclusion=$(echo "$result" | jq -r '.conclusion') + if [[ "$status" == "completed" ]]; then + if [[ "$conclusion" == "success" ]]; then + echo "Build and push containers workflow completed successfully" + break + else + echo "Build and push containers workflow failed" + exit 1 + fi + elif [[ "$status" == "in_progress" ]]; then + echo "Build and push containers workflow is still running" + sleep 60 + else + echo "Build and push containers workflow returned unexpected status: $status" + exit 1 + fi + done + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Checkout uses: actions/checkout@v4 + with: + token: ${{ steps.generate_token.outputs.token }} - name: Create .env file for default settings run: | @@ -91,9 +127,45 @@ jobs: quick-start-stack: name: Test quick-start stack runs-on: ubuntu-latest + if: | + !startsWith(github.head_ref, 'release-') steps: - - name: Checkout repository + - name: Generate a token + id: generate_token + uses: tibdex/github-app-token@v2 + with: + app_id: ${{ secrets.GH_BOT_APP_ID }} + private_key: ${{ secrets.GH_BOT_APP_KEY }} + + - name: Wait for container images build + run: | + while :; do + result=$(gh api repos/:owner/:repo/actions/workflows | jq -r '.workflows[] | select(.name=="Build and push containers") | .id' | xargs -I {} gh api repos/:owner/:repo/actions/workflows/{}/runs --jq '.workflow_runs | max_by(.run_number)') + status=$(echo "$result" | jq -r '.status') + conclusion=$(echo "$result" | jq -r '.conclusion') + if [[ "$status" == "completed" ]]; then + if [[ "$conclusion" == "success" ]]; then + echo "Build and push containers workflow completed successfully" + break + else + echo "Build and push containers workflow failed" + exit 1 + fi + elif [[ "$status" == "in_progress" ]]; then + echo "Build and push containers workflow is still running" + sleep 60 + else + echo "Build and push containers workflow returned unexpected status: $status" + exit 1 + fi + done + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Checkout uses: actions/checkout@v4 + with: + token: ${{ steps.generate_token.outputs.token }} - name: Create .env file for default settings run: | From a259b39e0fdea76e1ceeae7dc096604612ec6c40 Mon Sep 17 00:00:00 2001 From: PPawlowski Date: Thu, 26 Dec 2024 20:14:11 +0100 Subject: [PATCH 2/2] Move container build workflow check to separate job --- .github/workflows/test-docker-compose.yaml | 53 ++++++---------------- 1 file changed, 13 insertions(+), 40 deletions(-) diff --git a/.github/workflows/test-docker-compose.yaml b/.github/workflows/test-docker-compose.yaml index 065a9b4..a8f745b 100644 --- a/.github/workflows/test-docker-compose.yaml +++ b/.github/workflows/test-docker-compose.yaml @@ -11,8 +11,8 @@ on: jobs: - default-stack: - name: Test default stack + wait-for-containers-build: + name: Wait for container images build runs-on: ubuntu-latest if: | !startsWith(github.head_ref, 'release-') @@ -24,6 +24,11 @@ jobs: app_id: ${{ secrets.GH_BOT_APP_ID }} private_key: ${{ secrets.GH_BOT_APP_KEY }} + - name: Checkout + uses: actions/checkout@v4 + with: + token: ${{ steps.generate_token.outputs.token }} + - name: Wait for container images build run: | while :; do @@ -49,10 +54,13 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + default-stack: + name: Test default stack + needs: wait-for-containers-build + runs-on: ubuntu-latest + steps: - name: Checkout uses: actions/checkout@v4 - with: - token: ${{ steps.generate_token.outputs.token }} - name: Create .env file for default settings run: | @@ -126,46 +134,11 @@ jobs: quick-start-stack: name: Test quick-start stack + needs: wait-for-containers-build runs-on: ubuntu-latest - if: | - !startsWith(github.head_ref, 'release-') steps: - - name: Generate a token - id: generate_token - uses: tibdex/github-app-token@v2 - with: - app_id: ${{ secrets.GH_BOT_APP_ID }} - private_key: ${{ secrets.GH_BOT_APP_KEY }} - - - name: Wait for container images build - run: | - while :; do - result=$(gh api repos/:owner/:repo/actions/workflows | jq -r '.workflows[] | select(.name=="Build and push containers") | .id' | xargs -I {} gh api repos/:owner/:repo/actions/workflows/{}/runs --jq '.workflow_runs | max_by(.run_number)') - status=$(echo "$result" | jq -r '.status') - conclusion=$(echo "$result" | jq -r '.conclusion') - if [[ "$status" == "completed" ]]; then - if [[ "$conclusion" == "success" ]]; then - echo "Build and push containers workflow completed successfully" - break - else - echo "Build and push containers workflow failed" - exit 1 - fi - elif [[ "$status" == "in_progress" ]]; then - echo "Build and push containers workflow is still running" - sleep 60 - else - echo "Build and push containers workflow returned unexpected status: $status" - exit 1 - fi - done - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Checkout uses: actions/checkout@v4 - with: - token: ${{ steps.generate_token.outputs.token }} - name: Create .env file for default settings run: |