|
| 1 | +--- |
| 2 | +name: Conda |
| 3 | +env: |
| 4 | + DEFAULT_KHIOPS_REVISION: dev |
| 5 | + DEFAULT_SAMPLES_REVISION: main |
| 6 | +on: |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + khiops-revision: |
| 10 | + default: dev |
| 11 | + description: khiops repo revision |
| 12 | + samples-revision: |
| 13 | + default: main |
| 14 | + description: khiops-samples repo revision |
| 15 | + push: |
| 16 | + tags: [v*] |
| 17 | + pull_request: |
| 18 | + paths: [.github/workflows/build-conda-package.yml] |
| 19 | +defaults: |
| 20 | + run: |
| 21 | + shell: bash -el {0} |
| 22 | +concurrency: |
| 23 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 24 | + cancel-in-progress: true |
| 25 | +jobs: |
| 26 | + build-packages: |
| 27 | + name: Build Packages |
| 28 | + strategy: |
| 29 | + fail-fast: false |
| 30 | + matrix: |
| 31 | + # Use the oldest supported Mac OS and Ubuntu versions for GLIBC compatibility |
| 32 | + os: [ubuntu-20.04, windows-latest, macos-11] |
| 33 | + runs-on: ${{ matrix.os }} |
| 34 | + outputs: |
| 35 | + pkg-version: ${{ steps.get-pkg-version.outputs.pkg-version }} |
| 36 | + steps: |
| 37 | + - name: Checkout Sources |
| 38 | + uses: actions/checkout@v3 |
| 39 | + with: |
| 40 | + # Checkout the full repository to have the tags so versioneer works properly |
| 41 | + # See issue https://github.com/actions/checkout/issues/701 |
| 42 | + fetch-depth: 0 |
| 43 | + # We move KHIOPS_REVISION to the environment so that we can use |
| 44 | + # them in both push and workflow_dispatch events |
| 45 | + - name: Move KHIOPS_REVISION to the environment (push/PR) |
| 46 | + if: github.event_name == 'push' || github.event_name == 'pull_request' |
| 47 | + run: echo "KHIOPS_REVISION=${DEFAULT_KHIOPS_REVISION}" >> "$GITHUB_ENV" |
| 48 | + - name: Move KHIOPS_REVISION to the environment (workflow_dispatch) |
| 49 | + if: github.event_name == 'workflow_dispatch' |
| 50 | + run: echo "KHIOPS_REVISION=${{ inputs.khiops-revision }}" >> "$GITHUB_ENV" |
| 51 | + - name: Install Miniconda |
| 52 | + uses: conda-incubator/setup-miniconda@v3 |
| 53 | + with: |
| 54 | + activate-environment: khiops-python-env |
| 55 | + - name: Install Dependency Requirements for Building Conda Packages |
| 56 | + run: conda install conda-build=3.27.0 conda-verify |
| 57 | + # We need MacOS SDK 10.10 to build on Big Sur |
| 58 | + - name: Install Mac OS SDK 10.10 |
| 59 | + if: runner.os == 'macOS' |
| 60 | + run: | |
| 61 | + wget https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX10.10.sdk.tar.xz |
| 62 | + sudo tar -zxvf MacOSX10.10.sdk.tar.xz -C /opt |
| 63 | + - name: Build Khiops Conda Package (Windows) |
| 64 | + if: runner.os == 'Windows' |
| 65 | + run: | |
| 66 | + mkdir khiops-conda |
| 67 | + conda build --output-folder khiops-conda ./packaging/conda |
| 68 | + # In Linux/macOS we need the conda-forge channel to install their pinned versions |
| 69 | + - name: Build Khiops Conda Package (Linux/macOS) |
| 70 | + if: runner.os != 'Windows' |
| 71 | + run: | |
| 72 | + mkdir khiops-conda |
| 73 | + conda build --channel conda-forge --output-folder khiops-conda ./packaging/conda |
| 74 | + - name: Extract Khiops Package Version |
| 75 | + id: get-pkg-version |
| 76 | + run: | |
| 77 | + PKG_VERSION=$(\ |
| 78 | + conda search --override-channels --channel ./khiops-conda/ khiops \ |
| 79 | + | awk '!/#|channels/ {print $2}' \ |
| 80 | + | sort -u \ |
| 81 | + ) |
| 82 | + echo "pkg-version=$PKG_VERSION" >> "$GITHUB_OUTPUT" |
| 83 | + - name: Upload Khiops Conda Package |
| 84 | + uses: actions/upload-artifact@v3 |
| 85 | + with: |
| 86 | + name: khiops-${{ steps.get-pkg-version.outputs.pkg-version }}-conda |
| 87 | + path: ./khiops-conda |
| 88 | + retention-days: 7 |
| 89 | + # Test Conda package on brand new environments |
| 90 | + test-packages: |
| 91 | + needs: build-packages |
| 92 | + strategy: |
| 93 | + fail-fast: false |
| 94 | + matrix: |
| 95 | + os: |
| 96 | + - ubuntu-20.04 |
| 97 | + - ubuntu-22.04 |
| 98 | + - windows-2019 |
| 99 | + - windows-2022 |
| 100 | + - macos-11 |
| 101 | + - macos-12 |
| 102 | + - macos-13 |
| 103 | + python-version: ['3.8', '3.9', '3.10', '3.11'] |
| 104 | + runs-on: ${{ matrix.os }} |
| 105 | + env: |
| 106 | + KHIOPS_SAMPLES_DIR: ./khiops-samples-repo |
| 107 | + steps: |
| 108 | + # We move SAMPLES_REVISION to the environment so that we can use |
| 109 | + # them in both push and workflow_dispatch events |
| 110 | + - name: Move SAMPLES_REVISION to the environment (push event) |
| 111 | + if: github.event_name == 'push' |
| 112 | + run: echo "SAMPLES_REVISION=${DEFAULT_SAMPLES_REVISION}" >> "$GITHUB_ENV" |
| 113 | + - name: Move SAMPLES_REVISION to the environment (workflow_dispatch event) |
| 114 | + if: github.event_name == 'workflow_dispatch' |
| 115 | + run: echo "SAMPLES_REVISION=${{ inputs.samples-revision }}" >> "$GITHUB_ENV" |
| 116 | + - name: Checkout Khiops samples |
| 117 | + uses: actions/checkout@v3 |
| 118 | + with: |
| 119 | + repository: khiopsml/khiops-samples |
| 120 | + ref: ${{ env.SAMPLES_REVISION }} |
| 121 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 122 | + path: ${{ env.KHIOPS_SAMPLES_DIR }} |
| 123 | + - name: Install Miniconda |
| 124 | + uses: conda-incubator/setup-miniconda@v3 |
| 125 | + with: |
| 126 | + miniconda-version: latest # needed for Mac OS 13 |
| 127 | + python-version: ${{ matrix.python-version }} |
| 128 | + activate-environment: khiops-python-env |
| 129 | + - name: Download Conda Package Artifact |
| 130 | + uses: actions/download-artifact@v3 |
| 131 | + with: |
| 132 | + name: khiops-${{ needs.build-packages.outputs.pkg-version }}-conda |
| 133 | + path: khiops-conda |
| 134 | + - name: Install the Khiops Conda pagkage (Windows) |
| 135 | + if: runner.os == 'Windows' |
| 136 | + run: conda install -c ./khiops-conda/ khiops |
| 137 | + # In Linux/macOS we need the conda-forge channel to install their pinned versions |
| 138 | + - name: Install the Khiops Conda package (Linux/macOS) |
| 139 | + if: runner.os != 'Windows' |
| 140 | + run: conda install -c conda-forge -c ./khiops-conda/ khiops |
| 141 | + - name: Test Khiops Installation Status |
| 142 | + run: kh-status |
| 143 | + - name: Test Conda Package Installation on Samples |
| 144 | + run: | |
| 145 | + kh-samples core -i train_predictor -e |
| 146 | + kh-samples core -i train_predictor_error_handling -e |
| 147 | + kh-samples core -i train_coclustering -e |
| 148 | + kh-samples sklearn -i khiops_classifier -e |
| 149 | + kh-samples sklearn -i khiops_coclustering -e |
| 150 | + # Build and push Conda package release archive |
| 151 | + release-packages: |
| 152 | + # We need `build-packages` because we use its output |
| 153 | + needs: [build-packages, test-packages] |
| 154 | + runs-on: ubuntu-latest |
| 155 | + permissions: |
| 156 | + contents: write |
| 157 | + packages: read |
| 158 | + steps: |
| 159 | + - name: Release the zip archive |
| 160 | + if: github.event_name == 'push' |
| 161 | + uses: ncipollo/release-action@v1 |
| 162 | + with: |
| 163 | + artifacts: khiops-${{ needs.build-packages.outputs.pkg-version }}-conda |
0 commit comments