From 66364d9093357d540b0fbcbe49d69093491df7b6 Mon Sep 17 00:00:00 2001 From: Mark Do Date: Thu, 8 Feb 2024 03:59:28 +0000 Subject: [PATCH] Testing entire unit test pipeline with specific module testing only --- .github/workflows/temp_ci_test.yml | 101 ++++++++++++++++++++++++++++- src/action/test.txt | 2 +- src/interfacing/test2.txt | 2 +- 3 files changed, 102 insertions(+), 3 deletions(-) diff --git a/.github/workflows/temp_ci_test.yml b/.github/workflows/temp_ci_test.yml index 9eae8b32..d633cbae 100644 --- a/.github/workflows/temp_ci_test.yml +++ b/.github/workflows/temp_ci_test.yml @@ -139,4 +139,103 @@ jobs: - name: Generate GitHub Environment id: github-environment - uses: "./.github/templates/github_context" \ No newline at end of file + uses: "./.github/templates/github_context" + + build-and-unittest: + name: Build Image and Run Unit Testing Suite + runs-on: ubuntu-latest + needs: setup-environment + + env: + DOCKER_REGISTRY: ${{ needs.setup-environment.outputs.registry }} + DOCKER_REPOSITORY: ${{ needs.setup-environment.outputs.repository }} + SOURCE_BRANCH: ${{ needs.setup-environment.outputs.source_branch }} + TARGET_BRANCH: ${{ needs.setup-environment.outputs.target_branch }} + + strategy: + fail-fast: false + matrix: ${{ fromJSON(needs.setup-environment.outputs.docker_matrix) }} + + concurrency: + group: ${{ matrix.service }}-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Construct Registry URL + id: construct-registry-url + run: | + echo "url=${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_REPOSITORY }}/${{ matrix.module }}/${{ matrix.service }}" \ + >> $GITHUB_OUTPUT + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + id: buildx + + - name: Docker Login + uses: docker/login-action@v3 + with: + registry: ${{ env.DOCKER_REGISTRY }} + username: ${{ secrets.GHCR_USER }} + password: ${{ secrets.GHCR_PWD }} + + - name: Prepare Image Dependencies + if: ${{ matrix.module != 'infrastructure' }} + uses: docker/build-push-action@v5 + with: + context: . + file: docker/${{ matrix.module }}/${{ matrix.service }}/${{ matrix.service }}.Dockerfile + push: true + tags: | + ${{ steps.construct-registry-url.outputs.url }}:source_${{ env.SOURCE_BRANCH }} + cache-from: | + ${{ steps.construct-registry-url.outputs.url }}:source_${{ env.SOURCE_BRANCH }} + ${{ steps.construct-registry-url.outputs.url }}:source_${{ env.TARGET_BRANCH }} + cache-to: type=inline + builder: ${{ steps.buildx.outputs.name }} + target: dependencies + + - name: Build Image from Source + uses: docker/build-push-action@v5 + with: + context: . + file: docker/${{ matrix.module }}/${{ matrix.service }}/${{ matrix.service }}.Dockerfile + push: true + tags: | + ${{ steps.construct-registry-url.outputs.url }}:build_${{ env.SOURCE_BRANCH }} + cache-from: | + ${{ steps.construct-registry-url.outputs.url }}:source_${{ env.SOURCE_BRANCH }} + ${{ steps.construct-registry-url.outputs.url }}:build_${{ env.SOURCE_BRANCH }} + ${{ steps.construct-registry-url.outputs.url }}:build_${{ env.TARGET_BRANCH }} + cache-to: type=inline + builder: ${{ steps.buildx.outputs.name }} + target: build + + - name: Security Sanitation for Deployment + uses: docker/build-push-action@v5 + with: + context: . + file: docker/${{ matrix.module }}/${{ matrix.service }}/${{ matrix.service }}.Dockerfile + push: true + tags: | + ${{ steps.construct-registry-url.outputs.url }}:${{ env.SOURCE_BRANCH }} + cache-from: | + ${{ steps.construct-registry-url.outputs.url }}:build_${{ env.SOURCE_BRANCH }} + ${{ steps.construct-registry-url.outputs.url }}:${{ env.SOURCE_BRANCH }} + ${{ steps.construct-registry-url.outputs.url }}:${{ env.TARGET_BRANCH }} + cache-to: type=inline + builder: ${{ steps.buildx.outputs.name }} + target: deploy + + - name: Run testing suite + uses: "./.github/templates/test" + env: + DOCKER_BUILDKIT: 1 + COMPOSE_DOCKER_CLI_BUILD: 1 + BUILDKIT_INLINE_CACHE: 1 + with: + module: ${{ matrix.module }} + service: ${{ matrix.service }} + source_branch: ${{ env.SOURCE_BRANCH }} diff --git a/src/action/test.txt b/src/action/test.txt index 56a6051c..d8263ee9 100644 --- a/src/action/test.txt +++ b/src/action/test.txt @@ -1 +1 @@ -1 \ No newline at end of file +2 \ No newline at end of file diff --git a/src/interfacing/test2.txt b/src/interfacing/test2.txt index e440e5c8..bf0d87ab 100644 --- a/src/interfacing/test2.txt +++ b/src/interfacing/test2.txt @@ -1 +1 @@ -3 \ No newline at end of file +4 \ No newline at end of file