From 5895d211056d3f00af207d2505f339ad5a2884ef Mon Sep 17 00:00:00 2001 From: NkwaTambe Date: Mon, 11 Nov 2024 17:42:24 +0100 Subject: [PATCH] update workflow refinement --- .github/workflows/ci.cd.yml | 114 --------------------------------- .github/workflows/develop.yaml | 76 ++++++++++++++++------ 2 files changed, 55 insertions(+), 135 deletions(-) delete mode 100644 .github/workflows/ci.cd.yml diff --git a/.github/workflows/ci.cd.yml b/.github/workflows/ci.cd.yml deleted file mode 100644 index ff14c02..0000000 --- a/.github/workflows/ci.cd.yml +++ /dev/null @@ -1,114 +0,0 @@ -name: Java CI/CD Pipeline with Maven - -on: - push: - branches: [ "main", "staging" ] - pull_request: - branches: [ "main", "staging" ] - -jobs: - # 1. Build Stage - build: - runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'temurin' - cache: maven - - - name: Build with Maven - run: mvn clean install - - # 2. Test Stage - test: - runs-on: ubuntu-latest - needs: build - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'temurin' - - - name: Run Unit Tests - run: mvn test - - - name: Run Integration Tests - run: mvn verify - - # 3. Code Quality Check with SonarQube - # quality-check: - # runs-on: ubuntu-latest - # needs: build - # steps: - # - uses: actions/checkout@v4 - # - # - name: Set up JDK 17 - # uses: actions/setup-java@v4 - # with: - # java-version: '17' - # distribution: 'temurin' - # - # - name: SonarQube Scan - # env: - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - # run: mvn sonar:sonar -Dsonar.login=${{ secrets.SONAR_TOKEN }} - - # 4. Deployment Stage - # deploy: - # runs-on: ubuntu-latest - # needs: test - # steps: - # - uses: actions/checkout@v4 - # - # - name: Set up JDK 17 - # uses: actions/setup-java@v4 - # with: - # java-version: '17' - # distribution: 'temurin' - # - # - name: Login to Docker Hub - # uses: docker/login-action@v2 - # with: - # username: ${{ secrets.DOCKER_USERNAME }} - # password: ${{ secrets.DOCKER_PASSWORD }} - # - # - name: Build Docker Image - # run: docker build -t ${{ secrets.DOCKER_USERNAME }}/online-banking-service:${{ github.sha }} . - # - # - name: Push Docker Image - # run: docker push ${{ secrets.DOCKER_USERNAME }}/online-banking-service:${{ github.sha }} - # - # - name: Deploy to Staging - # if: github.ref == 'refs/heads/staging' - # run: | - # echo "Deploying to staging environment" - # # Add deployment script or command here - # - # - name: Deploy to Production - # if: github.ref == 'refs/heads/main' - # run: | - # echo "Deploying to production environment" - # # Add deployment script or command here - - # 5. Notifications - # notifications: - # runs-on: ubuntu-latest - # needs: [build, quality-check, test, deploy] - # steps: - # - name: Notify on Success or Failure - # if: always() - # run: | - # if [ "${{ job.status }}" == "success" ]; then - # echo "Build and deployment successful." - # else - # echo "Build or deployment failed." - # fi diff --git a/.github/workflows/develop.yaml b/.github/workflows/develop.yaml index 45645d7..70c45fb 100644 --- a/.github/workflows/develop.yaml +++ b/.github/workflows/develop.yaml @@ -1,18 +1,12 @@ -# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven - -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - name: Java CI with Maven on: push: - branches: [ "main" ] + branches: + - main pull_request: - branches: [ "main" ] + branches: + - main jobs: build: @@ -20,14 +14,54 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'temurin' - cache: maven - - name: Build with Maven - run: mvn clean install - -#Add pmd check + - uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + architecture: x64 + distribution: 'temurin' + + - name: Cache Maven packages + uses: actions/cache@v2 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + + - name: Set up Maven settings.xml + run: | + mkdir -p ~/.m2 + echo " + + + github-ledgers + ${{ github.actor }} + ${{ secrets.WEBANK_ACCESS_TOKEN }} + + + " > ~/.m2/settings.xml + + - name: Build with webank Online banking + run: mvn clean install -s ~/.m2/settings.xml -DskipTests -DskipITs -Dmaven.javadoc.skip=true + + # 2. Test Stage + test: + runs-on: ubuntu-latest + needs: build + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: Run Unit Tests + run: mvn test + + - name: Run Integration Tests + run: mvn verify