From 7f96f9774d4b6ae4ea6c61c86c28821108758139 Mon Sep 17 00:00:00 2001 From: eugene-seb Date: Wed, 20 Aug 2025 22:25:37 +0200 Subject: [PATCH 1/7] Refactor workflows and update submodule references - Streamlined pr_to_master.yml and push_pr_to_dev.yml for clarity and efficiency - Reduced redundant steps and improved job structure in CI workflows - Updated submodule references for all services to latest commits --- .github/workflows/pr_to_master.yml | 128 ++++++++++++++------------- .github/workflows/push_pr_to_dev.yml | 63 +++---------- submodules/api-gateway | 2 +- submodules/book-service | 2 +- submodules/registry-service | 2 +- submodules/review-service | 2 +- submodules/user-service | 2 +- 7 files changed, 85 insertions(+), 116 deletions(-) diff --git a/.github/workflows/pr_to_master.yml b/.github/workflows/pr_to_master.yml index 7133dea..bb1e638 100644 --- a/.github/workflows/pr_to_master.yml +++ b/.github/workflows/pr_to_master.yml @@ -1,5 +1,11 @@ # Execute only if it's a PR which comes from dev + name: PR to master + +# This pipeline runs everytime there is a PR on master. +# Because the changes on the submodules are track on their own GitHub project, +# I intentionally don't listen to the changes of each submodule in order to trigger this pipeline. + on: pull_request: branches: @@ -21,50 +27,11 @@ jobs: echo "✅ PR from dev to master authorized." fi - #----------------------------------------------------------------------- - #--- Detect the changes - #----------------------------------------------------------------------- - changes: - runs-on: ubuntu-latest - needs: validate-branch - if: success() - steps: - - name: Checkout the main repository - uses: actions/checkout@v4 - with: - submodules: true - - - name: Detect changes - id: filter - uses: dorny/paths-filter@v3 - with: - filters: | - user: - - 'submodules/user-service/**' - book: - - 'submodules/book-service/**' - review: - - 'submodules/review-service/**' - api_gateway: - - 'submodules/api-gateway/**' - registry_service: - - 'submodules/registry-service/**' - frontend: - - 'mflibrary-frontend/**' - outputs: - user: ${{ steps.filter.outputs.user }} - book: ${{ steps.filter.outputs.book }} - review: ${{ steps.filter.outputs.review }} - api_gateway: ${{ steps.filter.outputs.api_gateway }} - registry_service: ${{ steps.filter.outputs.registry_service }} - frontend: ${{ steps.filter.outputs.frontend }} - #----------------------------------------------------------------------- #--- Build and push user-service Docker image #----------------------------------------------------------------------- build-user-service: - needs: changes - if: needs.changes.outputs.user == 'true' + needs: validate-branch runs-on: ubuntu-latest steps: @@ -97,14 +64,19 @@ jobs: with: context: ./submodules/user-service push: true - tags: ghcr.io/${{ github.repository }}/user-service:latest + tags: | + ghcr.io/${{ github.repository }}/user-service:${{ github.sha }} + ghcr.io/${{ github.repository }}/user-service:latest + # Use Docker build cache stored in GitHub Container Registry to speed up builds. + # 'cache-from' pulls existing cache layers; 'cache-to' pushes new layers for future + cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/user-service:buildcache + cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/user-service:buildcache,mode=max #----------------------------------------------------------------------- #--- Build and push book-service Docker image #----------------------------------------------------------------------- build-book-service: - needs: changes - if: needs.changes.outputs.book == 'true' + needs: validate-branch runs-on: ubuntu-latest steps: @@ -137,14 +109,19 @@ jobs: with: context: ./submodules/book-service push: true - tags: ghcr.io/${{ github.repository }}/book-service:latest + tags: | + ghcr.io/${{ github.repository }}/book-service:${{ github.sha }} + ghcr.io/${{ github.repository }}/book-service:latest + # Use Docker build cache stored in GitHub Container Registry to speed up builds. + # 'cache-from' pulls existing cache layers; 'cache-to' pushes new layers for future + cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/book-service:buildcache + cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/book-service:buildcache,mode=max #----------------------------------------------------------------------- #--- Build and push review-service Docker image #----------------------------------------------------------------------- build-review-service: - needs: changes - if: needs.changes.outputs.review == 'true' + needs: validate-branch runs-on: ubuntu-latest steps: - name: Checkout the submodule review-service @@ -176,14 +153,19 @@ jobs: with: context: ./submodules/review-service push: true - tags: ghcr.io/${{ github.repository }}/review-service:latest + tags: | + ghcr.io/${{ github.repository }}/review-service:${{ github.sha }} + ghcr.io/${{ github.repository }}/review-service:latest + # Use Docker build cache stored in GitHub Container Registry to speed up builds. + # 'cache-from' pulls existing cache layers; 'cache-to' pushes new layers for future + cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/review-service:buildcache + cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/review-service:buildcache,mode=max #----------------------------------------------------------------------- #--- Build and push registry-service Docker image #----------------------------------------------------------------------- build-registry-service: - needs: changes - if: needs.changes.outputs.registry_service == 'true' + needs: validate-branch runs-on: ubuntu-latest steps: - name: Checkout the submodule registry-service @@ -215,14 +197,19 @@ jobs: with: context: ./submodules/registry-service push: true - tags: ghcr.io/${{ github.repository }}/registry-service:latest + tags: | + ghcr.io/${{ github.repository }}/registry-service:${{ github.sha }} + ghcr.io/${{ github.repository }}/registry-service:latest + # Use Docker build cache stored in GitHub Container Registry to speed up builds. + # 'cache-from' pulls existing cache layers; 'cache-to' pushes new layers for future + cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/registry-service:buildcache + cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/registry-service:buildcache,mode=max #----------------------------------------------------------------------- #--- Build and push api-gateway Docker image #----------------------------------------------------------------------- build-api-gateway: - needs: changes - if: needs.changes.outputs.api_gateway == 'true' + needs: validate-branch runs-on: ubuntu-latest steps: - name: Checkout the submodule api-gateway @@ -254,17 +241,23 @@ jobs: with: context: ./submodules/api-gateway push: true - tags: ghcr.io/${{ github.repository }}/api-gateway:latest + tags: | + ghcr.io/${{ github.repository }}/api-gateway:${{ github.sha }} + ghcr.io/${{ github.repository }}/api-gateway:latest + # Use Docker build cache stored in GitHub Container Registry to speed up builds. + # 'cache-from' pulls existing cache layers; 'cache-to' pushes new layers for future + cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/api-gateway:buildcache + cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/api-gateway:buildcache,mode=max #----------------------------------------------------------------------- #--- Build and push mflibrary-frontend Docker image #----------------------------------------------------------------------- build-mflibrary-frontend: - needs: changes - if: needs.changes.outputs.frontend == 'true' + needs: validate-branch runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Check out repository + uses: actions/checkout@v4 with: submodules: true @@ -277,20 +270,33 @@ jobs: run: npm ci working-directory: ./mflibrary-frontend + - name: Install Chrome + run: sudo apt-get update && sudo apt-get install -y google-chrome-stable + - name: Run frontend tests - run: npm test -- --watch=false --browsers=ChromeHeadless + run: npx ng test --watch=false --browsers=ChromeHeadless working-directory: ./mflibrary-frontend - - name: Login to GitHub Container Registry + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push mflibrary-frontend Docker image - uses: docker/build-push-action@v6 + - name: Build and Push mflibrary-frontend Docker Image + uses: docker/build-push-action@v5 with: context: ./mflibrary-frontend push: true - tags: ghcr.io/${{ github.repository }}/mflibrary-frontend:latest + file: ./mflibrary-frontend/Dockerfile + tags: | + ghcr.io/${{ github.repository }}/mflibrary-frontend:latest + ghcr.io/${{ github.repository }}/mflibrary-frontend:${{ github.sha }} + # Use Docker build cache stored in GitHub Container Registry to speed up builds. + # 'cache-from' pulls existing cache layers; 'cache-to' pushes new layers for future + cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/mflibrary-frontend:buildcache + cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/mflibrary-frontend:buildcache,mode=max diff --git a/.github/workflows/push_pr_to_dev.yml b/.github/workflows/push_pr_to_dev.yml index 6073c72..2851ff9 100644 --- a/.github/workflows/push_pr_to_dev.yml +++ b/.github/workflows/push_pr_to_dev.yml @@ -1,5 +1,11 @@ # Execute on every push or PR to dev + name: Push or PR to dev + +# This pipeline runs everytime there is a PR or push on dev. +# Because the changes on the submodules are track on their own GitHub project, +# I intentionally don't listen to the changes of each submodule in order to trigger this pipeline. + on: push: branches: @@ -7,49 +13,12 @@ on: pull_request: branches: - dev -jobs: - #----------------------------------------------------------------------- - #--- Detect the changes - #----------------------------------------------------------------------- - changes: - runs-on: ubuntu-latest - steps: - - name: Checkout the main repository - uses: actions/checkout@v4 - with: - submodules: true - - - name: Detect changes - id: filter - uses: dorny/paths-filter@v3 - with: - filters: | - user: - - 'submodules/user-service/**' - book: - - 'submodules/book-service/**' - review: - - 'submodules/review-service/**' - api_gateway: - - 'submodules/api-gateway/**' - registry_service: - - 'submodules/registry-service/**' - frontend: - - 'mflibrary-frontend/**' - outputs: - user: ${{ steps.filter.outputs.user }} - book: ${{ steps.filter.outputs.book }} - review: ${{ steps.filter.outputs.review }} - api_gateway: ${{ steps.filter.outputs.api_gateway }} - registry_service: ${{ steps.filter.outputs.registry_service }} - frontend: ${{ steps.filter.outputs.frontend }} +jobs: #----------------------------------------------------------------------- #--- Test user-service #----------------------------------------------------------------------- test-user-service: - needs: changes - if: needs.changes.outputs.user == 'true' runs-on: ubuntu-latest steps: @@ -74,8 +43,6 @@ jobs: #--- Test book-service #----------------------------------------------------------------------- test-book-service: - needs: changes - if: needs.changes.outputs.book == 'true' runs-on: ubuntu-latest steps: @@ -100,8 +67,6 @@ jobs: #--- Test review-service #----------------------------------------------------------------------- test-review-service: - needs: changes - if: needs.changes.outputs.review == 'true' runs-on: ubuntu-latest steps: - name: Checkout the submodule review-service @@ -125,8 +90,6 @@ jobs: #--- Test registry-service #----------------------------------------------------------------------- test-registry-service: - needs: changes - if: needs.changes.outputs.registry_service == 'true' runs-on: ubuntu-latest steps: - name: Checkout the submodule registry-service @@ -150,8 +113,6 @@ jobs: #--- Test api-gateway #----------------------------------------------------------------------- test-api-gateway: - needs: changes - if: needs.changes.outputs.api_gateway == 'true' runs-on: ubuntu-latest steps: - name: Checkout the submodule api-gateway @@ -175,11 +136,10 @@ jobs: #--- Test mflibrary-frontend #----------------------------------------------------------------------- test-mflibrary-frontend: - needs: changes - if: needs.changes.outputs.frontend == 'true' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Check out repository + uses: actions/checkout@v4 with: submodules: true @@ -192,6 +152,9 @@ jobs: run: npm ci working-directory: ./mflibrary-frontend + - name: Install Chrome + run: sudo apt-get update && sudo apt-get install -y google-chrome-stable + - name: Run frontend tests - run: npm test -- --watch=false --browsers=ChromeHeadless + run: npx ng test --watch=false --browsers=ChromeHeadless working-directory: ./mflibrary-frontend diff --git a/submodules/api-gateway b/submodules/api-gateway index fe213db..dd6543f 160000 --- a/submodules/api-gateway +++ b/submodules/api-gateway @@ -1 +1 @@ -Subproject commit fe213dbe355255874e38a420b5aca93f31483283 +Subproject commit dd6543f8e8b706037102679acff7b67a37c4ad08 diff --git a/submodules/book-service b/submodules/book-service index 22ba893..4bb1336 160000 --- a/submodules/book-service +++ b/submodules/book-service @@ -1 +1 @@ -Subproject commit 22ba893ee8f349bd0759b126a564757735372b4f +Subproject commit 4bb1336a77b5d6b47ba7c9e513b778fa658407b2 diff --git a/submodules/registry-service b/submodules/registry-service index fa16f06..6b07445 160000 --- a/submodules/registry-service +++ b/submodules/registry-service @@ -1 +1 @@ -Subproject commit fa16f060c8487b512944e6786f6414a49ffa1fed +Subproject commit 6b07445a36d37204af65ca9bb5d1ddaee3eebad0 diff --git a/submodules/review-service b/submodules/review-service index 072eab4..72c82d9 160000 --- a/submodules/review-service +++ b/submodules/review-service @@ -1 +1 @@ -Subproject commit 072eab45ab39366757486eb3edb88b6a5a6f1ab9 +Subproject commit 72c82d94d65819fdf73500c50350101b3b0724eb diff --git a/submodules/user-service b/submodules/user-service index 85d691e..507007b 160000 --- a/submodules/user-service +++ b/submodules/user-service @@ -1 +1 @@ -Subproject commit 85d691e01a07064e40ca7b641b779a5c173f472a +Subproject commit 507007bb15bf23d2acf9ff5df4bfbee4475af218 From 618dbfd03e2ec8b2554c38535fbdc8c7e96dfcd5 Mon Sep 17 00:00:00 2001 From: eugene-seb Date: Wed, 20 Aug 2025 22:56:47 +0200 Subject: [PATCH 2/7] Refactor workflows and update submodule references - Streamlined pr_to_master.yml and push_pr_to_dev.yml for clarity and efficiency - Reduced redundant steps and improved job structure in CI workflows - Updated submodule references for all services to latest commits --- .github/workflows/pr_to_master.yml | 8 ++++---- .github/workflows/push_pr_to_dev.yml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pr_to_master.yml b/.github/workflows/pr_to_master.yml index bb1e638..d170c11 100644 --- a/.github/workflows/pr_to_master.yml +++ b/.github/workflows/pr_to_master.yml @@ -268,14 +268,14 @@ jobs: - name: Install dependencies run: npm ci - working-directory: ./mflibrary-frontend + working-directory: ./submodules/mflibrary-frontend - name: Install Chrome run: sudo apt-get update && sudo apt-get install -y google-chrome-stable - name: Run frontend tests run: npx ng test --watch=false --browsers=ChromeHeadless - working-directory: ./mflibrary-frontend + working-directory: ./submodules/mflibrary-frontend - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -290,9 +290,9 @@ jobs: - name: Build and Push mflibrary-frontend Docker Image uses: docker/build-push-action@v5 with: - context: ./mflibrary-frontend + context: ./submodules/mflibrary-frontend push: true - file: ./mflibrary-frontend/Dockerfile + file: ./submodules/mflibrary-frontend/Dockerfile tags: | ghcr.io/${{ github.repository }}/mflibrary-frontend:latest ghcr.io/${{ github.repository }}/mflibrary-frontend:${{ github.sha }} diff --git a/.github/workflows/push_pr_to_dev.yml b/.github/workflows/push_pr_to_dev.yml index 2851ff9..4f0131b 100644 --- a/.github/workflows/push_pr_to_dev.yml +++ b/.github/workflows/push_pr_to_dev.yml @@ -150,11 +150,11 @@ jobs: - name: Install dependencies run: npm ci - working-directory: ./mflibrary-frontend + working-directory: ./submodules/mflibrary-frontend - name: Install Chrome run: sudo apt-get update && sudo apt-get install -y google-chrome-stable - name: Run frontend tests run: npx ng test --watch=false --browsers=ChromeHeadless - working-directory: ./mflibrary-frontend + working-directory: ./submodules/mflibrary-frontend From cdd53c5249d624d3d31fdacc532e94af6b5cc4c8 Mon Sep 17 00:00:00 2001 From: eugene-seb Date: Thu, 21 Aug 2025 01:37:23 +0200 Subject: [PATCH 3/7] Refactor CI workflows for simplicity and maintainability - Significantly reduced and streamlined steps in pr_to_master.yml and push_pr_to_dev.yml - Removed redundant or unnecessary actions to improve workflow efficiency - Enhanced clarity and maintainability of CI pipeline configuration --- .github/workflows/pr_to_master.yml | 211 +++------------------------ .github/workflows/push_pr_to_dev.yml | 108 ++------------ 2 files changed, 31 insertions(+), 288 deletions(-) diff --git a/.github/workflows/pr_to_master.yml b/.github/workflows/pr_to_master.yml index d170c11..be7176d 100644 --- a/.github/workflows/pr_to_master.yml +++ b/.github/workflows/pr_to_master.yml @@ -28,14 +28,17 @@ jobs: fi #----------------------------------------------------------------------- - #--- Build and push user-service Docker image + #--- Build backend services #----------------------------------------------------------------------- - build-user-service: + build-backend-services: needs: validate-branch runs-on: ubuntu-latest + strategy: + matrix: + service: [ api-gateway, registry-service, user-service, book-service, review-service ] steps: - - name: Checkout the submodule user-service + - name: Checkout repository uses: actions/checkout@v4 with: submodules: true @@ -47,187 +50,16 @@ jobs: distribution: 'temurin' cache: 'maven' - - name: Run the user-service tests + - name: Run tests run: | - chmod +x ./submodules/user-service/mvnw - ./submodules/user-service/mvnw -f ./submodules/user-service/pom.xml clean test + chmod +x ./submodules/${{ matrix.service }}/mvnw + ./submodules/${{ matrix.service }}/mvnw -f ./submodules/${{ matrix.service }}/pom.xml clean test - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push user-service Docker image - uses: docker/build-push-action@v6 - with: - context: ./submodules/user-service - push: true - tags: | - ghcr.io/${{ github.repository }}/user-service:${{ github.sha }} - ghcr.io/${{ github.repository }}/user-service:latest - # Use Docker build cache stored in GitHub Container Registry to speed up builds. - # 'cache-from' pulls existing cache layers; 'cache-to' pushes new layers for future - cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/user-service:buildcache - cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/user-service:buildcache,mode=max - - #----------------------------------------------------------------------- - #--- Build and push book-service Docker image - #----------------------------------------------------------------------- - build-book-service: - needs: validate-branch - runs-on: ubuntu-latest - - steps: - - name: Checkout the submodule book-service - uses: actions/checkout@v4 - with: - submodules: true - - - name: Set up JDK 21 - uses: actions/setup-java@v4 - with: - java-version: '21' - distribution: 'temurin' - cache: 'maven' - - - name: Run the book-service tests - run: | - chmod +x ./submodules/book-service/mvnw - ./submodules/book-service/mvnw -f ./submodules/book-service/pom.xml clean test - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push book-service Docker image - uses: docker/build-push-action@v6 - with: - context: ./submodules/book-service - push: true - tags: | - ghcr.io/${{ github.repository }}/book-service:${{ github.sha }} - ghcr.io/${{ github.repository }}/book-service:latest - # Use Docker build cache stored in GitHub Container Registry to speed up builds. - # 'cache-from' pulls existing cache layers; 'cache-to' pushes new layers for future - cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/book-service:buildcache - cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/book-service:buildcache,mode=max - - #----------------------------------------------------------------------- - #--- Build and push review-service Docker image - #----------------------------------------------------------------------- - build-review-service: - needs: validate-branch - runs-on: ubuntu-latest - steps: - - name: Checkout the submodule review-service - uses: actions/checkout@v4 - with: - submodules: true - - - name: Set up JDK 21 - uses: actions/setup-java@v4 - with: - java-version: '21' - distribution: 'temurin' - cache: 'maven' - - - name: Run the review-service tests - run: | - chmod +x ./submodules/review-service/mvnw - ./submodules/review-service/mvnw -f ./submodules/review-service/pom.xml clean test - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push review-service Docker image - uses: docker/build-push-action@v6 - with: - context: ./submodules/review-service - push: true - tags: | - ghcr.io/${{ github.repository }}/review-service:${{ github.sha }} - ghcr.io/${{ github.repository }}/review-service:latest - # Use Docker build cache stored in GitHub Container Registry to speed up builds. - # 'cache-from' pulls existing cache layers; 'cache-to' pushes new layers for future - cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/review-service:buildcache - cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/review-service:buildcache,mode=max - - #----------------------------------------------------------------------- - #--- Build and push registry-service Docker image - #----------------------------------------------------------------------- - build-registry-service: - needs: validate-branch - runs-on: ubuntu-latest - steps: - - name: Checkout the submodule registry-service - uses: actions/checkout@v4 - with: - submodules: true - - - name: Set up JDK 21 - uses: actions/setup-java@v4 - with: - java-version: '21' - distribution: 'temurin' - cache: 'maven' - - - name: Run the registry-service tests - run: | - chmod +x ./submodules/registry-service/mvnw - ./submodules/registry-service/mvnw -f ./submodules/registry-service/pom.xml clean test - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push registry-service Docker image - uses: docker/build-push-action@v6 - with: - context: ./submodules/registry-service - push: true - tags: | - ghcr.io/${{ github.repository }}/registry-service:${{ github.sha }} - ghcr.io/${{ github.repository }}/registry-service:latest - # Use Docker build cache stored in GitHub Container Registry to speed up builds. - # 'cache-from' pulls existing cache layers; 'cache-to' pushes new layers for future - cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/registry-service:buildcache - cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/registry-service:buildcache,mode=max - - #----------------------------------------------------------------------- - #--- Build and push api-gateway Docker image - #----------------------------------------------------------------------- - build-api-gateway: - needs: validate-branch - runs-on: ubuntu-latest - steps: - - name: Checkout the submodule api-gateway - uses: actions/checkout@v4 - with: - submodules: true - - - name: Set up JDK 21 - uses: actions/setup-java@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 with: - java-version: '21' - distribution: 'temurin' - cache: 'maven' - - - name: Run the api-gateway tests - run: | - chmod +x ./submodules/api-gateway/mvnw - ./submodules/api-gateway/mvnw -f ./submodules/api-gateway/pom.xml clean test + install: true + driver: docker-container - name: Login to GitHub Container Registry uses: docker/login-action@v3 @@ -236,18 +68,16 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push api-gateway Docker image + - name: Build and push Docker image uses: docker/build-push-action@v6 with: - context: ./submodules/api-gateway + context: ./submodules/${{ matrix.service }} push: true tags: | - ghcr.io/${{ github.repository }}/api-gateway:${{ github.sha }} - ghcr.io/${{ github.repository }}/api-gateway:latest - # Use Docker build cache stored in GitHub Container Registry to speed up builds. - # 'cache-from' pulls existing cache layers; 'cache-to' pushes new layers for future - cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/api-gateway:buildcache - cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/api-gateway:buildcache,mode=max + ghcr.io/${{ github.repository }}/${{ matrix.service }}:${{ github.sha }} + ghcr.io/${{ github.repository }}/${{ matrix.service }}:latest + cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/${{ matrix.service }}:buildcache + cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/${{ matrix.service }}:buildcache,mode=max #----------------------------------------------------------------------- #--- Build and push mflibrary-frontend Docker image @@ -279,6 +109,9 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + with: + install: true + driver: docker-container - name: Log in to GitHub Container Registry uses: docker/login-action@v3 diff --git a/.github/workflows/push_pr_to_dev.yml b/.github/workflows/push_pr_to_dev.yml index 4f0131b..10e4bc0 100644 --- a/.github/workflows/push_pr_to_dev.yml +++ b/.github/workflows/push_pr_to_dev.yml @@ -16,13 +16,16 @@ on: jobs: #----------------------------------------------------------------------- - #--- Test user-service + #--- Test backend services #----------------------------------------------------------------------- - test-user-service: + test-backend-services: runs-on: ubuntu-latest + strategy: + matrix: + service: [ api-gateway, registry-service, user-service, book-service, review-service ] steps: - - name: Checkout the submodule user-service + - name: Checkout repository uses: actions/checkout@v4 with: submodules: true @@ -34,103 +37,10 @@ jobs: distribution: 'temurin' cache: 'maven' - - name: Run the user-service tests + - name: Run tests run: | - chmod +x ./submodules/user-service/mvnw - ./submodules/user-service/mvnw -f ./submodules/user-service/pom.xml clean test - - #----------------------------------------------------------------------- - #--- Test book-service - #----------------------------------------------------------------------- - test-book-service: - runs-on: ubuntu-latest - - steps: - - name: Checkout the submodule book-service - uses: actions/checkout@v4 - with: - submodules: true - - - name: Set up JDK 21 - uses: actions/setup-java@v4 - with: - java-version: '21' - distribution: 'temurin' - cache: 'maven' - - - name: Run the book-service tests - run: | - chmod +x ./submodules/book-service/mvnw - ./submodules/book-service/mvnw -f ./submodules/book-service/pom.xml clean test - - #----------------------------------------------------------------------- - #--- Test review-service - #----------------------------------------------------------------------- - test-review-service: - runs-on: ubuntu-latest - steps: - - name: Checkout the submodule review-service - uses: actions/checkout@v4 - with: - submodules: true - - - name: Set up JDK 21 - uses: actions/setup-java@v4 - with: - java-version: '21' - distribution: 'temurin' - cache: 'maven' - - - name: Run the review-service tests - run: | - chmod +x ./submodules/review-service/mvnw - ./submodules/review-service/mvnw -f ./submodules/review-service/pom.xml clean test - - #----------------------------------------------------------------------- - #--- Test registry-service - #----------------------------------------------------------------------- - test-registry-service: - runs-on: ubuntu-latest - steps: - - name: Checkout the submodule registry-service - uses: actions/checkout@v4 - with: - submodules: true - - - name: Set up JDK 21 - uses: actions/setup-java@v4 - with: - java-version: '21' - distribution: 'temurin' - cache: 'maven' - - - name: Run the registry-service tests - run: | - chmod +x ./submodules/registry-service/mvnw - ./submodules/registry-service/mvnw -f ./submodules/registry-service/pom.xml clean test - - #----------------------------------------------------------------------- - #--- Test api-gateway - #----------------------------------------------------------------------- - test-api-gateway: - runs-on: ubuntu-latest - steps: - - name: Checkout the submodule api-gateway - uses: actions/checkout@v4 - with: - submodules: true - - - name: Set up JDK 21 - uses: actions/setup-java@v4 - with: - java-version: '21' - distribution: 'temurin' - cache: 'maven' - - - name: Run the api-gateway tests - run: | - chmod +x ./submodules/api-gateway/mvnw - ./submodules/api-gateway/mvnw -f ./submodules/api-gateway/pom.xml clean test + chmod +x ./submodules/${{ matrix.service }}/mvnw + ./submodules/${{ matrix.service }}/mvnw -f ./submodules/${{ matrix.service }}/pom.xml clean test #----------------------------------------------------------------------- #--- Test mflibrary-frontend From 855a7e36f09a445730c46799073bac3e456c7f9e Mon Sep 17 00:00:00 2001 From: eugene-seb Date: Thu, 21 Aug 2025 02:06:53 +0200 Subject: [PATCH 4/7] Refactor CI workflows for simplicity and maintainability - Significantly reduced and streamlined steps in pr_to_master.yml and push_pr_to_dev.yml - Removed redundant or unnecessary actions to improve workflow efficiency - Enhanced clarity and maintainability of CI pipeline configuration --- .github/workflows/pr_to_master.yml | 31 ++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pr_to_master.yml b/.github/workflows/pr_to_master.yml index be7176d..90d19f3 100644 --- a/.github/workflows/pr_to_master.yml +++ b/.github/workflows/pr_to_master.yml @@ -36,6 +36,9 @@ jobs: strategy: matrix: service: [ api-gateway, registry-service, user-service, book-service, review-service ] + env: + IMAGE_TAG: ${{ github.sha }} + REPO_NAME: ${{ github.repository }} steps: - name: Checkout repository @@ -55,6 +58,10 @@ jobs: chmod +x ./submodules/${{ matrix.service }}/mvnw ./submodules/${{ matrix.service }}/mvnw -f ./submodules/${{ matrix.service }}/pom.xml clean test + # GitHub Container Registry enforces all repository paths to be lowercase. + - name: Set lowercase repo name + run: echo "REPO_LC=${REPO_NAME,,}" >> $GITHUB_ENV + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 with: @@ -74,10 +81,10 @@ jobs: context: ./submodules/${{ matrix.service }} push: true tags: | - ghcr.io/${{ github.repository }}/${{ matrix.service }}:${{ github.sha }} - ghcr.io/${{ github.repository }}/${{ matrix.service }}:latest - cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/${{ matrix.service }}:buildcache - cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/${{ matrix.service }}:buildcache,mode=max + ghcr.io/${{ env.REPO_LC }}/${{ matrix.service }}:${{ env.IMAGE_TAG }} + ghcr.io/${{ env.REPO_LC }}/${{ matrix.service }}:latest + cache-from: type=registry,ref=ghcr.io/${{ env.REPO_LC }}/${{ matrix.service }}:buildcache + cache-to: type=registry,ref=ghcr.io/${{ env.REPO_LC }}/${{ matrix.service }}:buildcache,mode=max #----------------------------------------------------------------------- #--- Build and push mflibrary-frontend Docker image @@ -85,6 +92,10 @@ jobs: build-mflibrary-frontend: needs: validate-branch runs-on: ubuntu-latest + env: + IMAGE_TAG: ${{ github.sha }} + REPO_NAME: ${{ github.repository }} + steps: - name: Check out repository uses: actions/checkout@v4 @@ -107,6 +118,10 @@ jobs: run: npx ng test --watch=false --browsers=ChromeHeadless working-directory: ./submodules/mflibrary-frontend + # GitHub Container Registry enforces all repository paths to be lowercase. + - name: Set lowercase repo name + run: echo "REPO_LC=${REPO_NAME,,}" >> $GITHUB_ENV + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 with: @@ -127,9 +142,9 @@ jobs: push: true file: ./submodules/mflibrary-frontend/Dockerfile tags: | - ghcr.io/${{ github.repository }}/mflibrary-frontend:latest - ghcr.io/${{ github.repository }}/mflibrary-frontend:${{ github.sha }} + ghcr.io/${{ env.REPO_LC }}/mflibrary-frontend:latest + ghcr.io/${{ env.REPO_LC }}/mflibrary-frontend:${{ env.IMAGE_TAG }} # Use Docker build cache stored in GitHub Container Registry to speed up builds. # 'cache-from' pulls existing cache layers; 'cache-to' pushes new layers for future - cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/mflibrary-frontend:buildcache - cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/mflibrary-frontend:buildcache,mode=max + cache-from: type=registry,ref=ghcr.io/${{ env.REPO_LC }}/mflibrary-frontend:buildcache + cache-to: type=registry,ref=ghcr.io/${{ env.REPO_LC }}/mflibrary-frontend:buildcache,mode=max From 237551525084cd1fefab4e3fa54583a2ba3e9c9a Mon Sep 17 00:00:00 2001 From: eugene-seb Date: Thu, 21 Aug 2025 02:20:46 +0200 Subject: [PATCH 5/7] Refactor CI workflows for simplicity and maintainability - Significantly reduced and streamlined steps in pr_to_master.yml and push_pr_to_dev.yml - Removed redundant or unnecessary actions to improve workflow efficiency - Enhanced clarity and maintainability of CI pipeline configuration --- .github/workflows/pr_to_master.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pr_to_master.yml b/.github/workflows/pr_to_master.yml index 90d19f3..03f7d79 100644 --- a/.github/workflows/pr_to_master.yml +++ b/.github/workflows/pr_to_master.yml @@ -38,7 +38,7 @@ jobs: service: [ api-gateway, registry-service, user-service, book-service, review-service ] env: IMAGE_TAG: ${{ github.sha }} - REPO_NAME: ${{ github.repository }} + REPO_OWNER: ${{ github.repository_owner }} steps: - name: Checkout repository @@ -60,7 +60,7 @@ jobs: # GitHub Container Registry enforces all repository paths to be lowercase. - name: Set lowercase repo name - run: echo "REPO_LC=${REPO_NAME,,}" >> $GITHUB_ENV + run: echo "REPO_LC=${REPO_OWNER,,}" >> $GITHUB_ENV - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -94,7 +94,7 @@ jobs: runs-on: ubuntu-latest env: IMAGE_TAG: ${{ github.sha }} - REPO_NAME: ${{ github.repository }} + REPO_OWNER: ${{ github.repository_owner }} steps: - name: Check out repository @@ -120,7 +120,7 @@ jobs: # GitHub Container Registry enforces all repository paths to be lowercase. - name: Set lowercase repo name - run: echo "REPO_LC=${REPO_NAME,,}" >> $GITHUB_ENV + run: echo "REPO_LC=${REPO_OWNER,,}" >> $GITHUB_ENV - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 From ccd3be1306ce55c2bbbdab3526b1fb0fff37a00a Mon Sep 17 00:00:00 2001 From: eugene-seb Date: Thu, 21 Aug 2025 02:29:49 +0200 Subject: [PATCH 6/7] Refactor CI workflows for simplicity and maintainability - Significantly reduced and streamlined steps in pr_to_master.yml and push_pr_to_dev.yml - Removed redundant or unnecessary actions to improve workflow efficiency - Enhanced clarity and maintainability of CI pipeline configuration --- .github/workflows/pr_to_master.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pr_to_master.yml b/.github/workflows/pr_to_master.yml index 03f7d79..6e01717 100644 --- a/.github/workflows/pr_to_master.yml +++ b/.github/workflows/pr_to_master.yml @@ -81,10 +81,10 @@ jobs: context: ./submodules/${{ matrix.service }} push: true tags: | - ghcr.io/${{ env.REPO_LC }}/${{ matrix.service }}:${{ env.IMAGE_TAG }} - ghcr.io/${{ env.REPO_LC }}/${{ matrix.service }}:latest - cache-from: type=registry,ref=ghcr.io/${{ env.REPO_LC }}/${{ matrix.service }}:buildcache - cache-to: type=registry,ref=ghcr.io/${{ env.REPO_LC }}/${{ matrix.service }}:buildcache,mode=max + ghcr.io/${{ env.REPO_LC }}/mflibrary-${{ matrix.service }}:${{ env.IMAGE_TAG }} + ghcr.io/${{ env.REPO_LC }}/mflibrary-${{ matrix.service }}:latest + cache-from: type=registry,ref=ghcr.io/${{ env.REPO_LC }}/mflibrary-${{ matrix.service }}:buildcache + cache-to: type=registry,ref=ghcr.io/${{ env.REPO_LC }}/mflibrary-${{ matrix.service }}:buildcache,mode=max #----------------------------------------------------------------------- #--- Build and push mflibrary-frontend Docker image @@ -142,9 +142,9 @@ jobs: push: true file: ./submodules/mflibrary-frontend/Dockerfile tags: | - ghcr.io/${{ env.REPO_LC }}/mflibrary-frontend:latest - ghcr.io/${{ env.REPO_LC }}/mflibrary-frontend:${{ env.IMAGE_TAG }} + ghcr.io/${{ env.REPO_LC }}/mflibrary-mflibrary-frontend:latest + ghcr.io/${{ env.REPO_LC }}/mflibrary-mflibrary-frontend:${{ env.IMAGE_TAG }} # Use Docker build cache stored in GitHub Container Registry to speed up builds. # 'cache-from' pulls existing cache layers; 'cache-to' pushes new layers for future - cache-from: type=registry,ref=ghcr.io/${{ env.REPO_LC }}/mflibrary-frontend:buildcache - cache-to: type=registry,ref=ghcr.io/${{ env.REPO_LC }}/mflibrary-frontend:buildcache,mode=max + cache-from: type=registry,ref=ghcr.io/${{ env.REPO_LC }}/mflibrary-mflibrary-frontend:buildcache + cache-to: type=registry,ref=ghcr.io/${{ env.REPO_LC }}/mflibrary-mflibrary-frontend:buildcache,mode=max From 16bd64aaf39d25add26fd34e7a01746c68b080f7 Mon Sep 17 00:00:00 2001 From: eugene-seb Date: Thu, 21 Aug 2025 02:40:31 +0200 Subject: [PATCH 7/7] Refactor CI workflows for simplicity and maintainability - Significantly reduced and streamlined steps in pr_to_master.yml and push_pr_to_dev.yml - Removed redundant or unnecessary actions to improve workflow efficiency - Enhanced clarity and maintainability of CI pipeline configuration --- .github/workflows/pr_to_master.yml | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/pr_to_master.yml b/.github/workflows/pr_to_master.yml index 6e01717..fbe72af 100644 --- a/.github/workflows/pr_to_master.yml +++ b/.github/workflows/pr_to_master.yml @@ -11,6 +11,10 @@ on: branches: - master # I allow only PR from dev -> master +permissions: + contents: read + packages: write + jobs: #----------------------------------------------------------------------- #--- Validate the PR's branch @@ -38,7 +42,7 @@ jobs: service: [ api-gateway, registry-service, user-service, book-service, review-service ] env: IMAGE_TAG: ${{ github.sha }} - REPO_OWNER: ${{ github.repository_owner }} + REPO_NAME: ${{ github.repository }} steps: - name: Checkout repository @@ -60,7 +64,7 @@ jobs: # GitHub Container Registry enforces all repository paths to be lowercase. - name: Set lowercase repo name - run: echo "REPO_LC=${REPO_OWNER,,}" >> $GITHUB_ENV + run: echo "REPO_LC=${REPO_NAME,,}" >> $GITHUB_ENV - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -81,10 +85,10 @@ jobs: context: ./submodules/${{ matrix.service }} push: true tags: | - ghcr.io/${{ env.REPO_LC }}/mflibrary-${{ matrix.service }}:${{ env.IMAGE_TAG }} - ghcr.io/${{ env.REPO_LC }}/mflibrary-${{ matrix.service }}:latest - cache-from: type=registry,ref=ghcr.io/${{ env.REPO_LC }}/mflibrary-${{ matrix.service }}:buildcache - cache-to: type=registry,ref=ghcr.io/${{ env.REPO_LC }}/mflibrary-${{ matrix.service }}:buildcache,mode=max + ghcr.io/${{ env.REPO_LC }}/${{ matrix.service }}:${{ env.IMAGE_TAG }} + ghcr.io/${{ env.REPO_LC }}/${{ matrix.service }}:latest + cache-from: type=registry,ref=ghcr.io/${{ env.REPO_LC }}/${{ matrix.service }}:buildcache + cache-to: type=registry,ref=ghcr.io/${{ env.REPO_LC }}/${{ matrix.service }}:buildcache,mode=max #----------------------------------------------------------------------- #--- Build and push mflibrary-frontend Docker image @@ -94,7 +98,7 @@ jobs: runs-on: ubuntu-latest env: IMAGE_TAG: ${{ github.sha }} - REPO_OWNER: ${{ github.repository_owner }} + REPO_NAME: ${{ github.repository }} steps: - name: Check out repository @@ -120,7 +124,7 @@ jobs: # GitHub Container Registry enforces all repository paths to be lowercase. - name: Set lowercase repo name - run: echo "REPO_LC=${REPO_OWNER,,}" >> $GITHUB_ENV + run: echo "REPO_LC=${REPO_NAME,,}" >> $GITHUB_ENV - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -142,9 +146,9 @@ jobs: push: true file: ./submodules/mflibrary-frontend/Dockerfile tags: | - ghcr.io/${{ env.REPO_LC }}/mflibrary-mflibrary-frontend:latest - ghcr.io/${{ env.REPO_LC }}/mflibrary-mflibrary-frontend:${{ env.IMAGE_TAG }} + ghcr.io/${{ env.REPO_LC }}/mflibrary-frontend:latest + ghcr.io/${{ env.REPO_LC }}/mflibrary-frontend:${{ env.IMAGE_TAG }} # Use Docker build cache stored in GitHub Container Registry to speed up builds. # 'cache-from' pulls existing cache layers; 'cache-to' pushes new layers for future - cache-from: type=registry,ref=ghcr.io/${{ env.REPO_LC }}/mflibrary-mflibrary-frontend:buildcache - cache-to: type=registry,ref=ghcr.io/${{ env.REPO_LC }}/mflibrary-mflibrary-frontend:buildcache,mode=max + cache-from: type=registry,ref=ghcr.io/${{ env.REPO_LC }}/mflibrary-frontend:buildcache + cache-to: type=registry,ref=ghcr.io/${{ env.REPO_LC }}/mflibrary-frontend:buildcache,mode=max