|
| 1 | +name: Run a Windows job |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + script: |
| 7 | + description: 'Script to utilize' |
| 8 | + default: "python setup.py bdist_wheel" |
| 9 | + type: string |
| 10 | + timeout: |
| 11 | + description: 'Timeout for the job (in minutes)' |
| 12 | + default: 30 |
| 13 | + type: number |
| 14 | + runner: |
| 15 | + description: 'Runner type to utilize' |
| 16 | + default: "windows.4xlarge" |
| 17 | + type: string |
| 18 | + upload-artifact: |
| 19 | + description: 'Name to give artifacts uploaded from ${RUNNER_ARTIFACT_DIR}' |
| 20 | + default: '' |
| 21 | + type: string |
| 22 | + download-artifact: |
| 23 | + description: 'Name to download artifacts to ${RUNNER_ARTIFACT_DIR}' |
| 24 | + default: '' |
| 25 | + type: string |
| 26 | + repository: |
| 27 | + description: 'Repository to checkout, defaults to ""' |
| 28 | + default: "" |
| 29 | + type: string |
| 30 | + ref: |
| 31 | + description: 'Reference to checkout, defaults to "nightly"' |
| 32 | + default: "" |
| 33 | + type: string |
| 34 | + test-infra-repository: |
| 35 | + description: "Test infra repository to use" |
| 36 | + default: "pytorch/test-infra" |
| 37 | + type: string |
| 38 | + test-infra-ref: |
| 39 | + description: "Test infra reference to use" |
| 40 | + default: "" |
| 41 | + type: string |
| 42 | + |
| 43 | +jobs: |
| 44 | + job: |
| 45 | + env: |
| 46 | + REPOSITORY: ${{ inputs.repository || github.repository }} |
| 47 | + SCRIPT: ${{ inputs.script }} |
| 48 | + runs-on: ${{ inputs.runner }} |
| 49 | + timeout-minutes: ${{ inputs.timeout }} |
| 50 | + steps: |
| 51 | + - name: Checkout repository (${{ inputs.test-infra-repository }}@${{ inputs.test-infra-ref }}) |
| 52 | + uses: actions/checkout@v3 |
| 53 | + with: |
| 54 | + # Support the use case where we need to checkout someone's fork |
| 55 | + repository: ${{ inputs.test-infra-repository }} |
| 56 | + ref: ${{ inputs.test-infra-ref }} |
| 57 | + path: test-infra |
| 58 | + |
| 59 | + - name: Setup Windows |
| 60 | + uses: ./test-infra/.github/actions/setup-windows |
| 61 | + |
| 62 | + - name: Setup SSH |
| 63 | + uses: ./test-infra/.github/actions/setup-ssh |
| 64 | + |
| 65 | + - name: Checkout repository (${{ inputs.repository || github.repository }}@${{ inputs.ref }}) |
| 66 | + uses: actions/checkout@v3 |
| 67 | + with: |
| 68 | + # Support the use case where we need to checkout someone's fork |
| 69 | + repository: ${{ inputs.repository || github.repository }} |
| 70 | + ref: ${{ inputs.ref || github.ref }} |
| 71 | + path: ${{ inputs.repository || github.repository }} |
| 72 | + |
| 73 | + - name: Download artifacts (if any) |
| 74 | + uses: actions/download-artifact@v3 |
| 75 | + if: ${{ inputs.download-artifact != '' }} |
| 76 | + with: |
| 77 | + name: ${{ inputs.download-artifact }} |
| 78 | + path: ${{ runner.temp }}/artifacts/ |
| 79 | + |
| 80 | + - name: Run script |
| 81 | + shell: bash -l {0} |
| 82 | + working-directory: ${{ inputs.repository }} |
| 83 | + run: | |
| 84 | + { |
| 85 | + echo "#!/usr/bin/env bash"; |
| 86 | + echo "set -eou pipefail"; |
| 87 | + # Without this specific version of pywin32 conda the default conda installation does not work |
| 88 | + # See https://github.com/conda/conda/issues/11503 |
| 89 | + echo "/c/Jenkins/Miniconda3/python.exe -m pip install --upgrade pywin32==304" |
| 90 | + # Source conda so it's available to the script environment |
| 91 | + echo "source /c/Jenkins/Miniconda3/etc/profile.d/conda.sh"; |
| 92 | + echo "${SCRIPT}"; |
| 93 | + } > "${RUNNER_TEMP}/exec_script" |
| 94 | + bash "${RUNNER_TEMP}/exec_script" |
| 95 | +
|
| 96 | + - name: Check if there are potential artifacts and move them to the correct artifact location |
| 97 | + shell: bash -l {0} |
| 98 | + working-directory: ${{ inputs.repository }} |
| 99 | + id: check-artifacts |
| 100 | + if: ${{ inputs.upload-artifact != '' }} |
| 101 | + env: |
| 102 | + UPLOAD_ARTIFACT_NAME: ${{ inputs.upload-artifact }} |
| 103 | + run: | |
| 104 | + # If the default execution path is followed then we should get a wheel in the dist/ folder |
| 105 | + # attempt to just grab whatever is in there and scoop it all up |
| 106 | + if find "dist/" -name "*.whl" >/dev/null 2>/dev/null; then |
| 107 | + mv -v dist/*.whl "${RUNNER_ARTIFACT_DIR}/" |
| 108 | + fi |
| 109 | + # Set to fail upload step if there are no files for upload and expected files for upload |
| 110 | + echo '::set-output name=if-no-files-found::error' |
| 111 | +
|
| 112 | + - name: Upload artifacts to GitHub (if any) |
| 113 | + uses: actions/upload-artifact@v3 |
| 114 | + if: ${{ inputs.upload-artifact != '' }} |
| 115 | + with: |
| 116 | + name: ${{ inputs.upload-artifact }} |
| 117 | + path: ${{ runner.temp }}/artifacts/ |
| 118 | + if-no-files-found: ${{ steps.check-artifacts.outputs.if-no-files-found }} |
| 119 | + |
| 120 | + - name: Teardown Windows |
| 121 | + if: ${{ always() }} |
| 122 | + uses: ./test-infra/.github/actions/teardown-windows |
0 commit comments