Skip to content

Commit e453d5e

Browse files
committed
[DO NOT LAND] Try to debug Mac CI failure
ghstack-source-id: a5c4445 Pull Request resolved: #5844
1 parent d34cc4e commit e453d5e

File tree

3 files changed

+402
-840
lines changed

3 files changed

+402
-840
lines changed

.github/workflows/macos-job.yml

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
name: Run a macOS 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: "macos-12"
17+
type: string
18+
python-version:
19+
description: If set to any value, dont use sudo to clean the workspace
20+
required: false
21+
type: string
22+
default: "3.9"
23+
upload-artifact:
24+
description: 'Name to give artifacts uploaded from ${RUNNER_ARTIFACT_DIR}'
25+
default: ""
26+
type: string
27+
download-artifact:
28+
description: 'Name to download artifacts to ${RUNNER_ARTIFACT_DIR}'
29+
default: ""
30+
type: string
31+
repository:
32+
description: 'Repository to checkout, defaults to ""'
33+
default: ""
34+
type: string
35+
fetch-depth:
36+
description: 'Number of commits to fetch, defaults to 1 similar to actions/checkout'
37+
default: 1
38+
type: number
39+
submodules:
40+
description:
41+
Same as actions/checkout, set to `true` to checkout submodules or `recursive` to
42+
recursively checkout everything
43+
default: ""
44+
type: string
45+
ref:
46+
description: 'Reference to checkout, defaults to "nightly"'
47+
default: ""
48+
type: string
49+
test-infra-repository:
50+
description: "Test infra repository to use"
51+
default: "pytorch/test-infra"
52+
type: string
53+
test-infra-ref:
54+
description: "Test infra reference to use"
55+
default: ""
56+
type: string
57+
job-name:
58+
description: "Name for the job, which is displayed in the GitHub UI"
59+
default: "macos-job"
60+
type: string
61+
continue-on-error:
62+
description: "Prevents a job from failing when a step fails. Set to true to allow a job to pass when exec script step fails."
63+
default: false
64+
type: boolean
65+
binary-matrix:
66+
description: "If we are calling this workflow with binary build matrix entry, will initialize matrix entries and env vars"
67+
required: false
68+
default: ''
69+
type: string
70+
71+
jobs:
72+
job:
73+
name: ${{ inputs.job-name }}
74+
env:
75+
REPOSITORY: ${{ inputs.repository || github.repository }}
76+
SCRIPT: ${{ inputs.script }}
77+
runs-on: ${{ inputs.runner }}
78+
timeout-minutes: ${{ inputs.timeout }}
79+
steps:
80+
- name: Clean workspace
81+
run: |
82+
echo "::group::Cleanup debug output"
83+
rm -rfv "${GITHUB_WORKSPACE}"
84+
mkdir -p "${GITHUB_WORKSPACE}"
85+
echo "::endgroup::"
86+
87+
- name: Checkout repository (${{ inputs.test-infra-repository }}@${{ inputs.test-infra-ref }})
88+
uses: actions/checkout@v3
89+
with:
90+
# Support the use case where we need to checkout someone's fork
91+
repository: ${{ inputs.test-infra-repository }}
92+
ref: ${{ inputs.test-infra-ref }}
93+
path: test-infra
94+
95+
- name: Setup miniconda
96+
uses: ./test-infra/.github/actions/setup-miniconda
97+
98+
- name: Checkout repository (${{ inputs.repository || github.repository }}@${{ inputs.ref }})
99+
uses: actions/checkout@v3
100+
with:
101+
# Support the use case where we need to checkout someone's fork
102+
repository: ${{ inputs.repository || github.repository }}
103+
ref: ${{ inputs.ref || github.ref }}
104+
path: ${{ inputs.repository || github.repository }}
105+
fetch-depth: ${{ inputs.fetch-depth }}
106+
submodules: ${{ inputs.submodules }}
107+
108+
- name: Setup useful environment variables
109+
working-directory: ${{ inputs.repository }}
110+
run: |
111+
RUNNER_ARTIFACT_DIR="${RUNNER_TEMP}/artifacts"
112+
mkdir -p "${RUNNER_ARTIFACT_DIR}"
113+
echo "RUNNER_ARTIFACT_DIR=${RUNNER_ARTIFACT_DIR}" >> "${GITHUB_ENV}"
114+
115+
RUNNER_TEST_RESULTS_DIR="${RUNNER_TEMP}/test-results"
116+
mkdir -p "${RUNNER_TEST_RESULTS_DIR}"
117+
echo "RUNNER_TEST_RESULTS_DIR=${RUNNER_TEST_RESULTS_DIR}" >> "${GITHUB_ENV}"
118+
119+
- name: Download artifacts (if any)
120+
uses: actions/download-artifact@v3
121+
if: ${{ inputs.download-artifact != '' }}
122+
with:
123+
name: ${{ inputs.download-artifact }}
124+
path: ${{ runner.temp }}/artifacts/
125+
126+
- name: Run script
127+
shell: bash -l {0}
128+
continue-on-error: ${{ inputs.continue-on-error }}
129+
working-directory: ${{ inputs.repository }}
130+
run: |
131+
{
132+
echo "#!/usr/bin/env bash";
133+
echo "set -eou pipefail";
134+
# Source conda so it's available to the script environment
135+
echo 'eval "$(conda shell.bash hook)"';
136+
echo "${SCRIPT}";
137+
} > "${RUNNER_TEMP}/exec_script"
138+
while read line; do
139+
eval "export ${line}"
140+
done < "${RUNNER_TEMP}/github_env_${GITHUB_RUN_ID}"
141+
bash "${RUNNER_TEMP}/exec_script"
142+
143+
- name: Surface failing tests
144+
if: always()
145+
uses: pmeier/[email protected]
146+
with:
147+
path: ${{ env.RUNNER_TEST_RESULTS_DIR }}
148+
fail-on-empty: false
149+
150+
- name: Setup upterm session
151+
uses: owenthereal/action-upterm@v1
152+
with:
153+
limit-access-to-actor: true
154+
155+
- name: Check if there are potential artifacts and move them to the correct artifact location
156+
shell: bash -l {0}
157+
working-directory: ${{ inputs.repository }}
158+
id: check-artifacts
159+
if: ${{ inputs.upload-artifact != '' }}
160+
env:
161+
UPLOAD_ARTIFACT_NAME: ${{ inputs.upload-artifact }}
162+
run: |
163+
# If the default execution path is followed then we should get a wheel in the dist/ folder
164+
# attempt to just grab whatever is in there and scoop it all up
165+
if find "dist/" -name "*.whl" >/dev/null 2>/dev/null; then
166+
mv -v dist/*.whl "${RUNNER_ARTIFACT_DIR}/"
167+
fi
168+
# Set to fail upload step if there are no files for upload and expected files for upload
169+
echo 'if-no-files-found=error' >> "${GITHUB_OUTPUT}"
170+
171+
- name: Upload artifacts to GitHub (if any)
172+
uses: actions/upload-artifact@v3
173+
if: ${{ inputs.upload-artifact != '' }}
174+
with:
175+
name: ${{ inputs.upload-artifact }}
176+
path: ${{ runner.temp }}/artifacts/
177+
if-no-files-found: ${{ steps.check-artifacts.outputs.if-no-files-found }}

0 commit comments

Comments
 (0)