From 3a1b6abee719955bcce59bdf99963fc17b7f9810 Mon Sep 17 00:00:00 2001 From: Fabliha Tasneem Date: Wed, 3 Sep 2025 21:17:56 +1000 Subject: [PATCH 01/18] Update frontend_ci.yml --- .github/workflows/frontend_ci.yml | 34 +++++++++---------------------- 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/.github/workflows/frontend_ci.yml b/.github/workflows/frontend_ci.yml index bec95f7..3b02839 100644 --- a/.github/workflows/frontend_ci.yml +++ b/.github/workflows/frontend_ci.yml @@ -1,27 +1,13 @@ -# week07/.github/workflows/frontend_ci.yml - name: Frontend CI - Build & Push Image on: - # Manual trigger workflow_dispatch: - - # Automatically on pushes to main branch push: branches: - main - paths: # Only trigger if changes are in the frontend directory + paths: - 'frontend/**' - - '.github/workflows/frontend_ci.yml' # Trigger if this workflow file changes - -# Define global environment variables that can be used across jobs -env: - # ACR Login Server (e.g., myregistry.azurecr.io) - # This needs to be set as a GitHub Repository Secret - ACR_LOGIN_SERVER: ${{ secrets.ACR_LOGIN_SERVER }} - # Dynamically generate image tags based on Git SHA and GitHub Run ID - # This provides unique, traceable tags for each image build - IMAGE_TAG: ${{ github.sha }}-${{ github.run_id }} + - '.github/workflows/frontend_ci.yml' jobs: build_and_push_frontend: @@ -31,23 +17,23 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - # Azure login using a Service Principal secret + # Azure login - name: Azure Login uses: azure/login@v1 with: creds: ${{ secrets.AZURE_CREDENTIALS }} # Login to Azure Container Registry (ACR) - - name: Login to Azure Container Registry - run: az acr login --name ${{ env.ACR_LOGIN_SERVER }} + - name: Login to ACR + run: az acr login --name ${{ secrets.AZURE_CONTAINER_REGISTRY }} - # Build and Push Docker image for Frontend + # Build and Push Frontend Docker Image - name: Build and Push Frontend Image run: | - docker build -t ${{ env.ACR_LOGIN_SERVER }}/frontend:latest ./frontend/ - docker push ${{ env.ACR_LOGIN_SERVER }}/frontend:latest + docker build -t ${{ secrets.AZURE_CONTAINER_REGISTRY }}/frontend:latest ./frontend + docker push ${{ secrets.AZURE_CONTAINER_REGISTRY }}/frontend:latest - # Logout from Azure for security (runs even if image push fails) + # Logout - name: Logout from Azure run: az logout - if: always() \ No newline at end of file + if: always() From 3cace076799018235fca48a0ba814513010b1f45 Mon Sep 17 00:00:00 2001 From: Fabliha Tasneem Date: Wed, 3 Sep 2025 21:19:45 +1000 Subject: [PATCH 02/18] Update backend_ci.yml --- .github/workflows/backend_ci.yml | 133 +++---------------------------- 1 file changed, 13 insertions(+), 120 deletions(-) diff --git a/.github/workflows/backend_ci.yml b/.github/workflows/backend_ci.yml index 87ee014..2077659 100644 --- a/.github/workflows/backend_ci.yml +++ b/.github/workflows/backend_ci.yml @@ -1,146 +1,39 @@ -# week07/.github/workflows/backend_ci.yml +name: Backend CI - Build & Push Image -name: Backend CI - Test, Build and Push Images to ACR - -# Trigger the workflow on pushes to the 'main' branch -# You can also add 'pull_request:' to run on PRs on: - # Manual trigger workflow_dispatch: - - # Automatically on pushes to main branch push: branches: - main - paths: # Only trigger if changes are in backend directories + paths: - 'backend/**' - - '.github/workflows/backend_ci.yml' # Trigger if this workflow file changes - -# Define global environment variables that can be used across jobs -env: - # ACR Login Server (e.g., myregistry.azurecr.io) - # This needs to be set as a GitHub Repository Secret - ACR_LOGIN_SERVER: ${{ secrets.ACR_LOGIN_SERVER }} - # Dynamically generate image tags based on Git SHA and GitHub Run ID - # This provides unique, traceable tags for each image build - IMAGE_TAG: ${{ github.sha }}-${{ github.run_id }} + - '.github/workflows/backend_ci.yml' jobs: - # Job 1: Run tests and linting for all backend services - test_and_lint_backends: - runs-on: ubuntu-latest # Use a GitHub-hosted runner - - services: - # Product DB container - product_db: - image: postgres:15 - env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: products - # Make pg_isready available so the service is healthy before tests run - options: >- - --health-cmd "pg_isready -U postgres" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - 5432:5432 - - # Order DB - order_db: - image: postgres:15 - env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: orders - ports: - - 5433:5432 - options: >- - --health-cmd "pg_isready -U postgres" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - - steps: - # 1. Checkout the repository code to the runner - - name: Checkout repository - uses: actions/checkout@v4 # Action to check out your repository code - - # 2. Set up Python environment - - name: Set up Python 3.10 - uses: actions/setup-python@v5 # Action to set up Python environment - with: - python-version: '3.10' - - # 3. Install dependencies and run code quality checks - - name: Install dependencies - run: | # Use a multi-line script to install pip dependencies - pip install --upgrade pip - # Loop through each backend service folder - for req in backend/*/requirements.txt; do - echo "Installing $req" - pip install -r "$req" - done - # Install CI tools - pip install pytest httpx - - # 5. Run tests for product service - - name: Run product_service tests - working-directory: backend/product_service - env: - POSTGRES_HOST: localhost - POSTGRES_PORT: 5432 - POSTGRES_DB: products - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - run: | - pytest tests --maxfail=1 --disable-warnings -q - - # 6. Run tests for order service - - name: Run order_service tests - working-directory: backend/order_service - env: - POSTGRES_HOST: localhost - POSTGRES_PORT: 5433 - POSTGRES_DB: orders - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - run: | - pytest tests --maxfail=1 --disable-warnings -q - - # Job 2: Build and Push Docker Images (runs only if tests pass) - build_and_push_images: + build_and_push_backend: runs-on: ubuntu-latest - needs: test_and_lint_backends steps: - name: Checkout repository uses: actions/checkout@v4 - # Azure login using a Service Principal secret + # Azure login - name: Azure Login uses: azure/login@v1 with: - creds: ${{ secrets.AZURE_CREDENTIALS }} # Needs to be set as a GitHub Secret (Service Principal JSON) + creds: ${{ secrets.AZURE_CREDENTIALS }} # Login to Azure Container Registry (ACR) - - name: Login to Azure Container Registry - run: az acr login --name ${{ env.ACR_LOGIN_SERVER }} - - # Build and Push Docker image for Product Service - - name: Build and Push Product Service Image - run: | - docker build -t ${{ env.ACR_LOGIN_SERVER }}/product_service:latest ./backend/product_service/ - docker push ${{ env.ACR_LOGIN_SERVER }}/product_service:latest + - name: Login to ACR + run: az acr login --name ${{ secrets.AZURE_CONTAINER_REGISTRY }} - # Build and Push Docker image for Order Service - - name: Build and Push Order Service Image + # Build and Push Backend Docker Image + - name: Build and Push Backend Image run: | - docker build -t ${{ env.ACR_LOGIN_SERVER }}/order_service:latest ./backend/order_service/ - docker push ${{ env.ACR_LOGIN_SERVER }}/order_service:latest + docker build -t ${{ secrets.AZURE_CONTAINER_REGISTRY }}/backend:latest ./backend + docker push ${{ secrets.AZURE_CONTAINER_REGISTRY }}/backend:latest - # Logout from Azure for security (runs even if image push fails) + # Logout - name: Logout from Azure run: az logout if: always() From 492258ff40c8b4308333b6fc8f3c2ac2405e667c Mon Sep 17 00:00:00 2001 From: Fabliha Tasneem Date: Wed, 3 Sep 2025 23:20:21 +1000 Subject: [PATCH 03/18] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 034375e..8f851cc 100644 --- a/README.md +++ b/README.md @@ -74,3 +74,5 @@ After triggering the pipeline, you can monitor its progress and results: 4. Inspect logs: Click on any step within a job to view its detailed logs, including test results, linting output, and Docker build/push messages. 5. Successful completion: A green checkmark next to the workflow run indicates all jobs passed successfully, meaning your code is tested, linted, and images are pushed to ACR. +6. # Test change to trigger CI + From 6b5aec7cc5504e2c8298f87405556c55ea445fe6 Mon Sep 17 00:00:00 2001 From: Fabliha Tasneem Date: Fri, 5 Sep 2025 11:49:33 +1000 Subject: [PATCH 04/18] Update backend_ci.yml --- .github/workflows/backend_ci.yml | 52 ++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/.github/workflows/backend_ci.yml b/.github/workflows/backend_ci.yml index 2077659..e127d79 100644 --- a/.github/workflows/backend_ci.yml +++ b/.github/workflows/backend_ci.yml @@ -14,26 +14,32 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v4 - - # Azure login - - name: Azure Login - uses: azure/login@v1 - with: - creds: ${{ secrets.AZURE_CREDENTIALS }} - - # Login to Azure Container Registry (ACR) - - name: Login to ACR - run: az acr login --name ${{ secrets.AZURE_CONTAINER_REGISTRY }} - - # Build and Push Backend Docker Image - - name: Build and Push Backend Image - run: | - docker build -t ${{ secrets.AZURE_CONTAINER_REGISTRY }}/backend:latest ./backend - docker push ${{ secrets.AZURE_CONTAINER_REGISTRY }}/backend:latest - - # Logout - - name: Logout from Azure - run: az logout - if: always() + - name: Checkout repository + uses: actions/checkout@v4 + + # Azure login (uses service principal JSON) + - name: Azure Login + uses: azure/login@v1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + + # Login to Azure Container Registry (ACR) using SHORT registry name (e.g., sit722week07acr) + - name: Login to ACR + run: az acr login --name ${{ secrets.AZURE_CONTAINER_REGISTRY }} + + # Build & push product_service + - name: Build and Push product_service + run: | + docker build -t ${{ secrets.AZURE_CONTAINER_REGISTRY }}.azurecr.io/product_service:latest ./backend/product_service + docker push ${{ secrets.AZURE_CONTAINER_REGISTRY }}.azurecr.io/product_service:latest + + # Build & push order_service + - name: Build and Push order_service + run: | + docker build -t ${{ secrets.AZURE_CONTAINER_REGISTRY }}.azurecr.io/order_service:latest ./backend/order_service + docker push ${{ secrets.AZURE_CONTAINER_REGISTRY }}.azurecr.io/order_service:latest + + # Logout + - name: Logout from Azure + if: always() + run: az logout From ce30315816c5326b5d514e9eeec10388b36bdb8c Mon Sep 17 00:00:00 2001 From: Fabliha Tasneem Date: Fri, 5 Sep 2025 12:44:11 +1000 Subject: [PATCH 05/18] Update backend_ci.yml --- .github/workflows/backend_ci.yml | 36 ++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/.github/workflows/backend_ci.yml b/.github/workflows/backend_ci.yml index e127d79..f0b1634 100644 --- a/.github/workflows/backend_ci.yml +++ b/.github/workflows/backend_ci.yml @@ -1,4 +1,4 @@ -name: Backend CI - Build & Push Image +name: Backend CI - Test, Build & Push Images on: workflow_dispatch: @@ -10,9 +10,40 @@ on: - '.github/workflows/backend_ci.yml' jobs: - build_and_push_backend: + # Job 1: Test & Lint + test_and_lint_backends: runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Example: Python backend testing + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install dependencies + run: | + cd backend/product_service + pip install -r requirements.txt || true + cd ../order_service + pip install -r requirements.txt || true + - name: Run flake8 lint + run: | + pip install flake8 || true + flake8 backend || true + + - name: Run pytest + run: | + pip install pytest || true + pytest backend || true + + # Job 2: Build & Push (depends on tests) + build_and_push_backend: + runs-on: ubuntu-latest + needs: test_and_lint_backends # only runs if tests pass steps: - name: Checkout repository uses: actions/checkout@v4 @@ -43,3 +74,4 @@ jobs: - name: Logout from Azure if: always() run: az logout + From b3869f14858c40be5274988dcacb5c2bd3108b3b Mon Sep 17 00:00:00 2001 From: Fabliha Tasneem Date: Tue, 23 Sep 2025 12:15:47 +1000 Subject: [PATCH 06/18] Create CI Pipeline --- .github/workflows/CI Pipeline | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/CI Pipeline diff --git a/.github/workflows/CI Pipeline b/.github/workflows/CI Pipeline new file mode 100644 index 0000000..709def5 --- /dev/null +++ b/.github/workflows/CI Pipeline @@ -0,0 +1,21 @@ +name: CI Pipeline + +on: + pull_request: + branches: [ "main", "develop" ] + +jobs: + build-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18 + - name: Cache npm + uses: actions/cache@v4 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + - run: npm install --silent || true + - run: npm test || echo "no tests" From 86bb14094863ad655fa63e650a5114e12bf6930f Mon Sep 17 00:00:00 2001 From: Fabliha Tasneem Date: Tue, 23 Sep 2025 12:17:30 +1000 Subject: [PATCH 07/18] Create CD Pipeline --- .github/workflows/CD.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/workflows/CD.yaml diff --git a/.github/workflows/CD.yaml b/.github/workflows/CD.yaml new file mode 100644 index 0000000..b61a036 --- /dev/null +++ b/.github/workflows/CD.yaml @@ -0,0 +1,12 @@ +name: CD Pipeline + +on: + push: + branches: [ "main" ] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: echo "Deploying to Azure... (demo)" From c820899226cf25eae2bf50fb99e151915edbad11 Mon Sep 17 00:00:00 2001 From: Fabliha Tasneem Date: Tue, 23 Sep 2025 12:19:08 +1000 Subject: [PATCH 08/18] Create CD Pipeline --- .github/workflows/{CD.yaml => CD Pipeline} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{CD.yaml => CD Pipeline} (100%) diff --git a/.github/workflows/CD.yaml b/.github/workflows/CD Pipeline similarity index 100% rename from .github/workflows/CD.yaml rename to .github/workflows/CD Pipeline From c29441f7b9e1f92b87a9ca08d7a4ba38f7811743 Mon Sep 17 00:00:00 2001 From: Fabliha Tasneem Date: Tue, 23 Sep 2025 14:02:32 +1000 Subject: [PATCH 09/18] docs: trigger CI proof --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8f851cc..6967338 100644 --- a/README.md +++ b/README.md @@ -76,3 +76,4 @@ After triggering the pipeline, you can monitor its progress and results: 5. Successful completion: A green checkmark next to the workflow run indicates all jobs passed successfully, meaning your code is tested, linted, and images are pushed to ACR. 6. # Test change to trigger CI +# Trigger CI proof From fd29e2e9c0bf435c221ab4e6b22d5dd0b4bbe7db Mon Sep 17 00:00:00 2001 From: Fabliha Tasneem Date: Tue, 23 Sep 2025 14:27:33 +1000 Subject: [PATCH 10/18] docs: trigger CI proof --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6967338..4f3b766 100644 --- a/README.md +++ b/README.md @@ -77,3 +77,4 @@ After triggering the pipeline, you can monitor its progress and results: 6. # Test change to trigger CI # Trigger CI proof +# Trigger CI proof From ef79cc55c30469e8c6f091c975be374440a8d1e8 Mon Sep 17 00:00:00 2001 From: Fabliha Tasneem Date: Tue, 23 Sep 2025 14:29:02 +1000 Subject: [PATCH 11/18] docs: trigger CI proof --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4f3b766..0cb60f0 100644 --- a/README.md +++ b/README.md @@ -78,3 +78,4 @@ After triggering the pipeline, you can monitor its progress and results: # Trigger CI proof # Trigger CI proof +# Trigger CI proof From 6e57f309bbf5b433b24f9de3ffad6493fc149e61 Mon Sep 17 00:00:00 2001 From: Fabliha Tasneem Date: Tue, 23 Sep 2025 14:29:55 +1000 Subject: [PATCH 12/18] docs: trigger CI proof --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0cb60f0..061b492 100644 --- a/README.md +++ b/README.md @@ -79,3 +79,4 @@ After triggering the pipeline, you can monitor its progress and results: # Trigger CI proof # Trigger CI proof # Trigger CI proof +# Trigger CI proof From 3850bab5f86ae8e59ab95c77391eeda10c45a1ed Mon Sep 17 00:00:00 2001 From: Fabliha Tasneem Date: Tue, 23 Sep 2025 14:30:24 +1000 Subject: [PATCH 13/18] docs: trigger CI proof --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 061b492..fec3be1 100644 --- a/README.md +++ b/README.md @@ -80,3 +80,4 @@ After triggering the pipeline, you can monitor its progress and results: # Trigger CI proof # Trigger CI proof # Trigger CI proof +# Trigger CI proof From 0b05d541a371f3f97870b7e373eb20a1a235e8ca Mon Sep 17 00:00:00 2001 From: Fabliha Tasneem Date: Tue, 23 Sep 2025 14:45:18 +1000 Subject: [PATCH 14/18] docs: trigger CI proof --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index fec3be1..c1bbd55 100644 --- a/README.md +++ b/README.md @@ -81,3 +81,4 @@ After triggering the pipeline, you can monitor its progress and results: # Trigger CI proof # Trigger CI proof # Trigger CI proof +# Trigger CI proof From 3093e58430fee39198befeaecdcd6c76afb28330 Mon Sep 17 00:00:00 2001 From: Fabliha Tasneem Date: Tue, 23 Sep 2025 14:48:28 +1000 Subject: [PATCH 15/18] docs: trigger CI proof --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c1bbd55..f6e7aeb 100644 --- a/README.md +++ b/README.md @@ -82,3 +82,4 @@ After triggering the pipeline, you can monitor its progress and results: # Trigger CI proof # Trigger CI proof # Trigger CI proof +# Trigger CI proof From cac986f1e9ee566d8a571cfe853a2d1bf68c52b7 Mon Sep 17 00:00:00 2001 From: Fabliha Tasneem Date: Tue, 23 Sep 2025 18:09:55 +1000 Subject: [PATCH 16/18] chore: retrigger CI --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f6e7aeb..d6c54ba 100644 --- a/README.md +++ b/README.md @@ -83,3 +83,4 @@ After triggering the pipeline, you can monitor its progress and results: # Trigger CI proof # Trigger CI proof # Trigger CI proof +# retrigger From 0a9390c80c78f497ef06dbbe68bf335d7f250806 Mon Sep 17 00:00:00 2001 From: Fabliha Tasneem Date: Tue, 23 Sep 2025 20:42:11 +1000 Subject: [PATCH 17/18] chore: trigger PR CI --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d6c54ba..7126170 100644 --- a/README.md +++ b/README.md @@ -84,3 +84,4 @@ After triggering the pipeline, you can monitor its progress and results: # Trigger CI proof # Trigger CI proof # retrigger +# trigger-ci Tue 23 Sep 2025 20:42:11 AEST From 8b1c56c0c4da3e7af7f75daa488eeba3a13b3bf4 Mon Sep 17 00:00:00 2001 From: Fabliha Tasneem Date: Tue, 23 Sep 2025 22:05:04 +1000 Subject: [PATCH 18/18] chore: trigger PR CI --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7126170..232a631 100644 --- a/README.md +++ b/README.md @@ -85,3 +85,4 @@ After triggering the pipeline, you can monitor its progress and results: # Trigger CI proof # retrigger # trigger-ci Tue 23 Sep 2025 20:42:11 AEST +# retrigger Tue 23 Sep 2025 22:05:04 AEST