From 6e9ab384359cc9b1216770081d269c5957655d04 Mon Sep 17 00:00:00 2001 From: Muhammad Faisal Date: Wed, 21 Jun 2023 21:03:47 +0500 Subject: [PATCH] Change working directory didn't work, so specifying the pom path. --- .github/actions/generate-reports/action.yml | 13 ++++--- .../run-tests-and-upload-results/action.yml | 11 +++--- .github/workflows/build.yml | 34 +++++++++++-------- .github/workflows/deploy.yml | 7 ++-- 4 files changed, 39 insertions(+), 26 deletions(-) diff --git a/.github/actions/generate-reports/action.yml b/.github/actions/generate-reports/action.yml index 6846b0b8..de95308d 100644 --- a/.github/actions/generate-reports/action.yml +++ b/.github/actions/generate-reports/action.yml @@ -8,6 +8,9 @@ inputs: UPLOADED_ARTIFACTS_DIR: required: true description: 'Uploads artifacts directory' + PUTTING_ALL_TOGETHER_DIR: + required: true + description: 'Directory containing the module code' runs: using: "composite" @@ -22,9 +25,9 @@ runs: path: ${{ inputs.UPLOADED_ARTIFACTS_DIR }} - name: 'Copy the `ut` and `it` artifacts into the `target` folder' run: | - mkdir target - cp -r ${{ env.UPLOADED_ARTIFACTS_DIR }}/${{ env.UPLOADED_ARTIFACTS_DIR }}-ut/* target - cp -rf ${{ env.UPLOADED_ARTIFACTS_DIR }}/${{ env.UPLOADED_ARTIFACTS_DIR }}-it/* target + mkdir ${{ inputs.PUTTING_ALL_TOGETHER_DIR }}/target + cp -r ${{ env.UPLOADED_ARTIFACTS_DIR }}/${{ env.UPLOADED_ARTIFACTS_DIR }}-ut/* ${{ inputs.PUTTING_ALL_TOGETHER_DIR }}/target + cp -rf ${{ env.UPLOADED_ARTIFACTS_DIR }}/${{ env.UPLOADED_ARTIFACTS_DIR }}-it/* ${{ inputs.PUTTING_ALL_TOGETHER_DIR }}/target shell: bash - name: 'Cache Maven packages' uses: actions/cache@v2 @@ -33,11 +36,11 @@ runs: key: ${{ runner.os }}-m2-site-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-m2-* - name: 'Generates the project''s site' - run: mvn site -P nt --file pom.xml + run: mvn site -P nt --file ${{ inputs.PUTTING_ALL_TOGETHER_DIR }}/pom.xml shell: bash - name: 'Uploads the results to ${{ inputs.UPLOADED_ARTIFACTS_DIR }} folder' uses: actions/upload-artifact@v3 with: name: ${{ inputs.UPLOADED_ARTIFACTS_DIR }} retention-days: 1 - path: target \ No newline at end of file + path: ${{ inputs.PUTTING_ALL_TOGETHER_DIR }}/target \ No newline at end of file diff --git a/.github/actions/run-tests-and-upload-results/action.yml b/.github/actions/run-tests-and-upload-results/action.yml index ede511ee..266ea4eb 100644 --- a/.github/actions/run-tests-and-upload-results/action.yml +++ b/.github/actions/run-tests-and-upload-results/action.yml @@ -8,6 +8,9 @@ inputs: UPLOADED_ARTIFACTS_DIR: required: true description: 'Uploads artifacts directory' + PUTTING_ALL_TOGETHER_DIR: + required: true + description: 'Directory containing the module code' RUN_UNIT_TESTS: required: true description: 'Run unit tests if `TRUE`, else integration tests' @@ -21,11 +24,11 @@ runs: JAVA_VERSION_TO_INSTALL: ${{ inputs.JAVA_VERSION_TO_INSTALL }} - name: 'Runs the unit tests' if: ${{ inputs.RUN_UNIT_TESTS == 'true' }} - run: mvn -Djacoco.haltOnFailure=false test -P ut --file pom.xml + run: mvn -Djacoco.haltOnFailure=false test -P ut --file ${{ inputs.PUTTING_ALL_TOGETHER_DIR }}/pom.xml shell: bash - name: 'Runs the integration tests' if: ${{ inputs.RUN_UNIT_TESTS == 'false' }} - run: mvn -Djacoco.haltOnFailure=false verify -P it --file pom.xml + run: mvn -Djacoco.haltOnFailure=false verify -P it --file ${{ inputs.PUTTING_ALL_TOGETHER_DIR }}/pom.xml shell: bash - name: 'Set environment variables' run: | @@ -37,10 +40,10 @@ runs: uses: test-summary/action@v2 with: show: "all" - paths: "target/test-results/${{ env.FILES_DIR_PREFIX }}-tests/**/TEST-*.xml" + paths: "${{ inputs.PUTTING_ALL_TOGETHER_DIR }}/target/test-results/${{ env.FILES_DIR_PREFIX }}-tests/**/TEST-*.xml" - name: 'Uploads the results to ${{ env.UPLOAD_DIR }} folder' uses: actions/upload-artifact@v3 with: name: ${{ env.UPLOAD_DIR }} retention-days: 1 - path: target \ No newline at end of file + path: ${{ inputs.PUTTING_ALL_TOGETHER_DIR }}/target \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 162b5ce9..bbe372f0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,22 +4,22 @@ env: JAVA_VERSION: 20 UPLOADED_ARTIFACTS_DIR: 'gh-pages' SITE_DIR: 'gh-pages/site' + PUTTING_ALL_TOGETHER_DIR: 'PuttingAllTogether' BRANCHES_COVERAGE_THRESHOLD: '60%' INSTRUCTIONS_COVERAGE_THRESHOLD: '60%' -defaults: - run: - working-directory: 'PuttingAllTogether' jobs: setup-env: runs-on: ubuntu-latest outputs: JAVA_VERSION: ${{steps.setup-env.outputs.JAVA_VERSION}} + PUTTING_ALL_TOGETHER_DIR: ${{steps.setup-env.outputs.PUTTING_ALL_TOGETHER_DIR}} steps: - name: 'Setup Environment' id: setup-env run: | echo "JAVA_VERSION=${{ env.JAVA_VERSION }}" >> $GITHUB_OUTPUT + echo "PUTTING_ALL_TOGETHER_DIR=${{ env.PUTTING_ALL_TOGETHER_DIR }}" >> $GITHUB_OUTPUT build: runs-on: ubuntu-latest @@ -38,7 +38,7 @@ jobs: key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-m2-* - name: 'Compiles the application code' - run: mvn clean compile --file pom.xml + run: mvn clean compile --file ${{ env.PUTTING_ALL_TOGETHER_DIR }}/pom.xml unit-tests: runs-on: ubuntu-latest @@ -52,6 +52,7 @@ jobs: RUN_UNIT_TESTS: true JAVA_VERSION_TO_INSTALL: ${{ env.JAVA_VERSION }} UPLOADED_ARTIFACTS_DIR: ${{ env.UPLOADED_ARTIFACTS_DIR }} + PUTTING_ALL_TOGETHER_DIR: ${{ env.PUTTING_ALL_TOGETHER_DIR }} integration-tests: runs-on: ubuntu-latest @@ -65,6 +66,7 @@ jobs: RUN_UNIT_TESTS: false JAVA_VERSION_TO_INSTALL: ${{ env.JAVA_VERSION }} UPLOADED_ARTIFACTS_DIR: ${{ env.UPLOADED_ARTIFACTS_DIR }} + PUTTING_ALL_TOGETHER_DIR: ${{ env.PUTTING_ALL_TOGETHER_DIR }} generate-project-site: runs-on: ubuntu-latest @@ -80,6 +82,7 @@ jobs: with: JAVA_VERSION_TO_INSTALL: ${{ env.JAVA_VERSION }} UPLOADED_ARTIFACTS_DIR: ${{ env.UPLOADED_ARTIFACTS_DIR }} + PUTTING_ALL_TOGETHER_DIR: ${{ env.PUTTING_ALL_TOGETHER_DIR }} generate-code-coverage-badge: if: ${{ github.ref == 'refs/heads/master' }} @@ -146,14 +149,15 @@ jobs: folder: ${{ env.SITE_DIR }} CLEAN: true # Automatically remove deleted files from the deploy branch - deploy-to-gh-packages: - needs: - - setup-env - - unit-tests - - integration-tests - permissions: - contents: read - packages: write - uses: './.github/workflows/deploy.yml' - with: - JAVA_VERSION_TO_INSTALL: ${{ needs.setup-env.outputs.JAVA_VERSION }} \ No newline at end of file +# deploy-to-gh-packages: +# needs: +# - setup-env +# - unit-tests +# - integration-tests +# permissions: +# contents: read +# packages: write +# uses: './.github/workflows/deploy.yml' +# with: +# JAVA_VERSION_TO_INSTALL: ${{ needs.setup-env.outputs.JAVA_VERSION }} +# PUTTING_ALL_TOGETHER_DIRECTORY: ${{ needs.setup-env.outputs.PUTTING_ALL_TOGETHER_DIR }} \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 806eee35..1bbe74fd 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -9,6 +9,9 @@ on: JAVA_VERSION_TO_INSTALL: required: true type: string + PUTTING_ALL_TOGETHER_DIRECTORY: + required: true + type: string jobs: deploy-to-gh-packages: @@ -23,9 +26,9 @@ jobs: JAVA_VERSION_TO_INSTALL: ${{ inputs.JAVA_VERSION_TO_INSTALL }} - name: 'Packaging the application' - run: mvn -DskipTests package --file pom.xml + run: mvn -DskipTests package --file ${{ inputs.PUTTING_ALL_TOGETHER_DIRECTORY }}/pom.xml - name: 'Publishing/deploying the packaged application' - run: mvn --batch-mode -DskipTests deploy + run: mvn --batch-mode -DskipTests deploy--file ${{ inputs.PUTTING_ALL_TOGETHER_DIRECTORY }}/pom.xml env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file