# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) Contributors to the OpenEXR Project.
#
# GitHub Actions workflow file
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions

name: CI-vfx

#
# Build against VFX reference platform container images
#

on:
  push:
    paths:
      - '**'
      - '!**.md'
      - '!share/ci/install_manifest/**'
      - '!.github/workflows/**'
      - '.github/workflows/ci_workflow_vfx.yml'
  pull_request:
    paths:
      - '**'
      - '!**.md'
      - '!share/ci/install_manifest/**'
      - '!.github/workflows/**'
      - '.github/workflows/ci_workflow_vfx.yml'

permissions:
  contents: read

jobs:

  linux:

    name: 'Linux vfx${{ matrix.vfx-cy }}'
    runs-on: ubuntu-latest
    container:
      image: aswf/ci-openexr:${{ matrix.vfx-cy }}

    defaults:
      run:
        shell: bash

    strategy:
      matrix:
        include:

          - build: 2025
            vfx-cy: 2025

          - build: 2024
            vfx-cy: 2024

          - build: 2023
            vfx-cy: 2023

    steps:

      - name: Checkout
        uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

      - name: Configure
        run: |
          BUILD_DIR=$GITHUB_WORKSPACE/_build
          echo BUILD_DIR="$BUILD_DIR" >> $GITHUB_ENV

          INSTALL_DIR=$GITHUB_WORKSPACE/_install
          echo INSTALL_DIR="$INSTALL_DIR" >> $GITHUB_ENV

          cmake -B $BUILD_DIR -S $GITHUB_WORKSPACE \
                -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \
                -DCMAKE_VERBOSE_MAKEFILE:BOOL='ON'

      - name: Build
        run: |
          cmake --build $BUILD_DIR --target install --config Release

      - name: Test
        run: |
          ctest -T Test -C Release \
            --test-dir $BUILD_DIR \
            --timeout 7200 \
            --output-on-failure \
            -VV

  linux-nodejs20:

    #
    # Build for VFX reference platform prior to 2023, which requires a
    # workaround to run an old version of glibc required by the ASWF Docker
    # images.
    #
    # This doesn't easily integrate with the existing CI workflow, and it
    # can be depreciated entirely once we've moved beyond support for the
    # old CentOS-based VFX reference platform years.
    #
    # See this discussion for details:
    # https://academysoftwarefdn.slack.com/archives/C0169RX7MMK/p1732574400981949

    name: 'Linux vfx${{ matrix.vfx-cy }}'
    runs-on: ubuntu-latest
    container:
      image: aswf/ci-openexr:${{ matrix.vfx-cy }}
      volumes:
        - /node20217:/node20217:rw,rshared
        - /node20217:/__e/node20:ro,rshared

    env:
      ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true

    defaults:
      run:
        shell: bash

    strategy:
      matrix:
        include:

          - build: 2022
            vfx-cy: 2022

          - build: 2021
            vfx-cy: 2021

    steps:

      - name: install nodejs20glibc2.17
        run: |
          curl --silent https://unofficial-builds.nodejs.org/download/release/v20.18.1/node-v20.18.1-linux-x64-glibc-217.tar.xz | tar -xJ --strip-components 1 -C /node20217 -f -

      - name: Checkout
        uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0

      - name: Configure
        run: |
          BUILD_DIR=$GITHUB_WORKSPACE/_build
          echo BUILD_DIR="$BUILD_DIR" >> $GITHUB_ENV

          INSTALL_DIR=$GITHUB_WORKSPACE/_install
          echo INSTALL_DIR="$INSTALL_DIR" >> $GITHUB_ENV

          cmake -B $BUILD_DIR -S $GITHUB_WORKSPACE \
                -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \
                -DCMAKE_VERBOSE_MAKEFILE:BOOL='ON'

      - name: Build
        run: |
          cmake --build $BUILD_DIR --target install --config Release

      - name: Test
        run: |
          ctest -T Test -C Release \
            --test-dir $BUILD_DIR \
            --timeout 7200 \
            --output-on-failure \
            -VV

