diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 9ab7afff8f..6edf5eb03b 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,30 @@ jobs: experimental: true steps: + - name: Calculate SKIP_UNSTABLE + if: matrix.experimental + 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 + $B = $ImagesAreEqual -eq 1 + + # Calculate the logical expression + $Result = ($A -or $B).ToString().ToLower() + + # Export it as an environment variable with true/false value + Write-Output "SKIP_UNSTABLE=$Result" | Out-File -FilePath $env:GITHUB_ENV -Append + Write-Output "SKIP_UNSTABLE will be: $Result" + - uses: actions/checkout@v4 if: env.SKIP_UNSTABLE == 'false' @@ -329,11 +404,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 +419,28 @@ jobs: experimental: true steps: + - name: Calculate SKIP_UNSTABLE + if: matrix.experimental + 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) + B=$([[ "$ImagesAreEqual" == "1" ]] && echo true || echo false) + + # Calculate the logical expression + Result=$([[ "$A" == true || "$B" == true ]] && echo true || echo false) + + # Export it as an environment variable with true/false value + echo "SKIP_UNSTABLE=$Result" >> $GITHUB_ENV + echo "SKIP_UNSTABLE will be: $Result" + - name: Login in Github Container registry if: env.SKIP_UNSTABLE == 'false' uses: docker/login-action@v3 diff --git a/.github/workflows/nightly_docker_test.yml b/.github/workflows/nightly_docker_test.yml index 2b6b278dbe..af3131626c 100644 --- a/.github/workflows/nightly_docker_test.yml +++ b/.github/workflows/nightly_docker_test.yml @@ -35,13 +35,65 @@ concurrency: jobs: + 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 + # ================================================================================================= # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUNNING ON SELF-HOSTED RUNNER ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ # ================================================================================================= windows-dms-tests: name: Windows DMS - if: vars.SKIP_UNSTABLE_CONTAINERS_TEMPORARILY != 1 + needs: manifests + if: needs.manifests.outputs.skip_dms == 0 runs-on: [self-hosted, Windows, pygeometry] env: PYVISTA_OFF_SCREEN: true @@ -146,7 +198,8 @@ jobs: windows-core-tests: name: Windows Core Service - if: vars.SKIP_UNSTABLE_CONTAINERS_TEMPORARILY != 1 + needs: manifests + if: needs.manifests.outputs.skip_core_windows == 0 # runs-on: [self-hosted, Windows, pygeometry] runs-on: # TODO: Waiting for ansys-network runner to be updated group: pyansys-self-hosted @@ -259,7 +312,8 @@ jobs: linux-tests: name: Linux Core Service - if: vars.SKIP_UNSTABLE_CONTAINERS_TEMPORARILY != 1 + needs: manifests + if: needs.manifests.outputs.skip_core_linux == 0 runs-on: ubuntu-latest steps: diff --git a/doc/changelog.d/1592.maintenance.md b/doc/changelog.d/1592.maintenance.md new file mode 100644 index 0000000000..ef7b20ec82 --- /dev/null +++ b/doc/changelog.d/1592.maintenance.md @@ -0,0 +1 @@ +skip unnecessary stages when containers are the same \ No newline at end of file