diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 9ab7afff8f..934e834448 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -102,20 +102,71 @@ jobs: directory: docker recursive: true + manifests: + name: Check Docker manifests + runs-on: ubuntu-latest + outputs: + skip_dms: ${{ steps.services.outputs.skip_dms }} + skip_core_windows: ${{ steps.services.outputs.skip_core_windows }} + skip_core_linux: ${{ steps.services.outputs.skip_core_linux }} + strategy: + matrix: + include: + - container-stable: "windows-latest" + container-unstable: "windows-latest-unstable" + service: "dms" + service-name: "Windows DMS" + - container-stable: "core-windows-latest" + container-unstable: "core-windows-latest-unstable" + service: "core_windows" + service-name: "Windows Core Service" + - container-stable: "core-linux-latest" + container-unstable: "core-linux-latest-unstable" + service: "core_linux" + service-name: "Linux Core Service" + steps: + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Check ${{ matrix.service-name }} manifest + id: services + run: | + docker manifest inspect ghcr.io/ansys/geometry:${{ matrix.container-stable }} > ${{ matrix.container-stable }}.json + docker manifest inspect ghcr.io/ansys/geometry:${{ matrix.container-unstable }} > ${{ matrix.container-unstable }}.json || true + + # Verify that the unstable manifest exists - otherwise create an empty file + if [ ! -f ${{ matrix.container-unstable }}.json ]; then + touch ${{ matrix.container-unstable }}.json + fi + + + # Check if the manifests are the same (and if so, create an output that will skip the next job) + if diff ${{ matrix.container-stable }}.json ${{ matrix.container-unstable }}.json; then + echo "${{ matrix.service-name }} container manifests are the same... skipping" + echo "skip_${{ matrix.service }}=1" >> "$GITHUB_OUTPUT" + else + echo "${{ matrix.service-name }} container manifests are different" + echo "skip_${{ matrix.service }}=0" >> "$GITHUB_OUTPUT" + fi + # ================================================================================================= # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv # ================================================================================================= testing-windows: name: Testing and coverage (Windows) - needs: [smoke-tests] + needs: [smoke-tests, manifests] # runs-on: [self-hosted, Windows, pygeometry] runs-on: # TODO: Waiting for ansys-network runner to be updated group: pyansys-self-hosted labels: [self-hosted, Windows, pygeometry] continue-on-error: ${{ matrix.experimental }} env: - SKIP_UNSTABLE: ${{ vars.SKIP_UNSTABLE_CONTAINERS_TEMPORARILY == 1 && matrix.experimental }} + SKIP_UNSTABLE: false PYVISTA_OFF_SCREEN: true strategy: fail-fast: false @@ -131,6 +182,35 @@ jobs: experimental: true steps: + - name: Calculate SKIP_UNSTABLE + if: matrix.experimental == 'true' + run: | + # Choose the manifests output to consider (for DMS or Core service) + # based on the matrix value + if ("${{ matrix.docker-image }}" -eq "windows-latest-unstable") { + $ImagesAreEqual = ${{ needs.manifests.outputs.skip_dms }} + } elseif ("${{ matrix.docker-image }}" -eq "core-windows-latest-unstable") { + $ImagesAreEqual = ${{ needs.manifests.outputs.skip_core_windows }} + } else { + Write-Output "Unknown docker image" + exit 1 + } + + $A = $env:SKIP_UNSTABLE_CONTAINERS_TEMPORARILY -eq 1 + $C = $ImagesAreEqual -eq 1 + $B = ${{ matrix.experimental }} + + # Calculate the logical expression + $Result = (($A -or $B) -and $C).ToString().ToLower() + + # Export it as an environment variable with true/false value + Write-Output "SKIP_UNSTABLE=$Result" | Out-File -FilePath $env:GITHUB_ENV -Append + + - name: Print SKIP_UNSTABLE + if: matrix.experimental == 'true' + run: | + Write-Output "SKIP_UNSTABLE is $env:SKIP_UNSTABLE" + - uses: actions/checkout@v4 if: env.SKIP_UNSTABLE == 'false' @@ -329,11 +409,11 @@ jobs: testing-linux: name: Testing and coverage (Linux) - needs: [smoke-tests] + needs: [smoke-tests, manifests] runs-on: ubuntu-latest continue-on-error: ${{ matrix.experimental }} env: - SKIP_UNSTABLE: ${{ vars.SKIP_UNSTABLE_CONTAINERS_TEMPORARILY == 1 && matrix.experimental }} + SKIP_UNSTABLE: false strategy: fail-fast: false matrix: @@ -344,6 +424,33 @@ jobs: experimental: true steps: + - name: Calculate SKIP_UNSTABLE + if: matrix.experimental == 'true' + run: | + # Choose the manifests output to consider (for Core service) + # based on the matrix value + if [[ "${{ matrix.docker-image }}" == "core-linux-latest-unstable" ]]; then + ImagesAreEqual=${{ needs.manifests.outputs.skip_core_linux }} + else + echo "Unknown docker image" + exit 1 + fi + + A=$([[ "$SKIP_UNSTABLE_CONTAINERS_TEMPORARILY" == "1" ]] && echo true || echo false) + C=$([[ "$ImagesAreEqual" == "1" ]] && echo true || echo false) + B=${{ matrix.experimental }} + + # Calculate the logical expression + Result=$([[ "$A" == true || "$B" == true ]] && [[ "$C" == true ]] && echo true || echo false) + + # Export it as an environment variable with true/false value + echo "SKIP_UNSTABLE=$Result" >> $GITHUB_ENV + + - name: Print SKIP_UNSTABLE + if: matrix.experimental == 'true' + run: | + echo "SKIP_UNSTABLE is $SKIP_UNSTABLE" + - name: Login in Github Container registry if: env.SKIP_UNSTABLE == 'false' uses: docker/login-action@v3