Skip to content

Commit fd648a4

Browse files
seemethereejguan
authored andcommitted
ci: Don't install things to home directory, add workflow to test release pipelines (#706)
Summary: Noticed we were getting extra conda packges from the home directory on the M1 runners. Making this PR to reduce the amount that we're using the home directory. Will probably make it unwritable in the future so this is a pre-emptive step to that. Also adds a workflow to test the release pipelines without actually releasing a new binary. Signed-off-by: Eli Uriegas <[email protected]> Pull Request resolved: #706 Reviewed By: ejguan Differential Revision: D38406845 Pulled By: seemethere fbshipit-source-id: 1d312c3e1db34497c546a9b842ac7ba01d2a7ee3
1 parent 9375899 commit fd648a4

File tree

2 files changed

+56
-28
lines changed

2 files changed

+56
-28
lines changed

.github/workflows/_build_test_upload.yml

+35-28
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ on:
1212
pytorch_version:
1313
required: true
1414
type: string
15+
do-upload:
16+
required: false
17+
default: true
18+
type: boolean
1519
secrets:
1620
PYTORCH_BINARY_AWS_ACCESS_KEY_ID:
1721
required: true
@@ -28,24 +32,18 @@ on:
2832

2933
jobs:
3034
get_release_type:
31-
if: inputs.branch != ''
3235
runs-on: ubuntu-latest
3336
outputs:
3437
type: ${{ steps.get_release_type.outputs.type }}
3538
steps:
3639
- name: Get Release Type
3740
run: |
38-
if [[ ${{ inputs.branch }} == v* ]] && [[ ${{ inputs.pre_dev_release }} == false ]]; then
41+
if [[ "${{ inputs.branch }}" == v* ]] && [[ ${{ inputs.pre_dev_release }} == false ]]; then
3942
RELEASE_TYPE=official
40-
elif [[ ${{ inputs.branch }} == release/* ]] && [[ ${{ inputs.pre_dev_release }} == true ]]; then
43+
elif [[ "${{ inputs.branch }}" == release/* ]] && [[ ${{ inputs.pre_dev_release }} == true ]]; then
4144
RELEASE_TYPE=test
42-
elif [[ ${{ inputs.branch }} == main ]] && [[ ${{ inputs.pre_dev_release }} == true ]]; then
43-
RELEASE_TYPE=nightly
4445
else
45-
echo "Invalid combination of inputs!"
46-
echo " branch: ${{ inputs.branch }}"
47-
echo " pre_dev_release: ${{ inputs.pre_dev_release }}"
48-
exit 1
46+
RELEASE_TYPE=nightly
4947
fi
5048
echo "Release Type: $RELEASE_TYPE"
5149
echo "::set-output name=type::$RELEASE_TYPE"
@@ -83,19 +81,23 @@ jobs:
8381
uses: actions/setup-python@v2
8482
with:
8583
python-version: ${{ matrix.python-version }}
84+
- name: Add temp runner environment variables
85+
shell: bash -l {0}
86+
run: |
87+
echo "MINICONDA_INSTALL_PATH_MACOS=${RUNNER_TEMP}/miniconda" >> "${GITHUB_ENV}"
8688
- name: Install Conda on MacOS
8789
if: ${{ startsWith( matrix.os, 'macos' ) }}
8890
shell: bash -l {0}
8991
run: |
90-
mkdir -p ~/miniconda3
92+
mkdir -p "${MINICONDA_INSTALL_PATH_MACOS}"
9193
if ${{ startsWith( matrix.os, 'macos-m1' ) }}; then
92-
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh -o ~/miniconda3/miniconda.sh
94+
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh -o "${MINICONDA_INSTALL_PATH_MACOS}/miniconda.sh"
9395
else
94-
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -o ~/miniconda3/miniconda.sh
96+
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -o "${MINICONDA_INSTALL_PATH_MACOS}/miniconda.sh"
9597
fi
96-
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
97-
rm -rf ~/miniconda3/miniconda.sh
98-
echo "$(dirname ~)/$(basename ~)/miniconda3/bin" >> $GITHUB_PATH
98+
bash "${MINICONDA_INSTALL_PATH_MACOS}/miniconda.sh" -b -u -p "${MINICONDA_INSTALL_PATH_MACOS}"
99+
rm -rf "${MINICONDA_INSTALL_PATH_MACOS}/miniconda.sh"
100+
echo "${MINICONDA_INSTALL_PATH_MACOS}/bin" >> $GITHUB_PATH
99101
- name: Setup Python ${{ matrix.python-version }} on MacOS
100102
if: ${{ startsWith( matrix.os, 'macos' ) }}
101103
shell: bash -l {0}
@@ -211,7 +213,7 @@ jobs:
211213
path: dist/torchdata*.whl
212214

213215
wheel_upload:
214-
if: always() && inputs.branch != ''
216+
if: always() && inputs.branch != '' && inputs.do-upload == true
215217
needs: [get_release_type, wheel_build_test]
216218
runs-on: ubuntu-latest
217219
outputs:
@@ -289,31 +291,36 @@ jobs:
289291
with:
290292
ref: ${{ inputs.branch }}
291293
submodules: recursive
294+
- name: Add temp runner environment variables
295+
shell: bash -l {0}
296+
run: |
297+
echo "MINICONDA_INSTALL_PATH_MACOS=${RUNNER_TEMP}/miniconda" >> "${GITHUB_ENV}"
298+
echo "CONDA_ENV_PATH=${RUNNER_TEMP}/conda_build_env" >> "${GITHUB_ENV}"
292299
- name: Create Conda Env
293300
if: ${{ ! startsWith( matrix.os, 'macos' ) }}
294301
uses: conda-incubator/setup-miniconda@v2
295302
with:
296303
python-version: ${{ matrix.python-version }}
297-
activate-environment: conda_build_env
304+
activate-environment: ${{ env.CONDA_ENV_PATH }}
298305
- name: Install Conda on MacOS
299306
if: ${{ startsWith( matrix.os, 'macos' ) }}
300307
shell: bash -l {0}
301308
run: |
302-
mkdir -p ~/miniconda3
309+
mkdir -p "${MINICONDA_INSTALL_PATH_MACOS}"
303310
if ${{ startsWith( matrix.os, 'macos-m1' ) }}; then
304-
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh -o ~/miniconda3/miniconda.sh
311+
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh -o "${MINICONDA_INSTALL_PATH_MACOS}/miniconda.sh"
305312
else
306-
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -o ~/miniconda3/miniconda.sh
313+
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -o "${MINICONDA_INSTALL_PATH_MACOS}/miniconda.sh"
307314
fi
308-
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
309-
rm -rf ~/miniconda3/miniconda.sh
310-
echo "$(dirname ~)/$(basename ~)/miniconda3/bin" >> $GITHUB_PATH
315+
bash "${MINICONDA_INSTALL_PATH_MACOS}/miniconda.sh" -b -u -p "${MINICONDA_INSTALL_PATH_MACOS}"
316+
rm -rf "${MINICONDA_INSTALL_PATH_MACOS}/miniconda.sh"
317+
echo "${MINICONDA_INSTALL_PATH_MACOS}/bin" >> $GITHUB_PATH
311318
- name: Create Conda Env on MacOS
312319
if: ${{ startsWith( matrix.os, 'macos' ) }}
313320
shell: bash -l {0}
314321
run: |
315322
conda init bash
316-
conda create -y --name conda_build_env python=${{ matrix.python-version }}
323+
conda create -y -p "${CONDA_ENV_PATH}" python=${{ matrix.python-version }}
317324
- name: Setup additional system libraries
318325
if: startsWith( matrix.os, 'ubuntu' )
319326
run: |
@@ -338,14 +345,14 @@ jobs:
338345
BUILD_S3: ${{ steps.build_s3.outputs.value }}
339346
run: |
340347
set -ex
341-
conda activate conda_build_env
348+
conda activate "${CONDA_ENV_PATH}"
342349
conda install -yq conda-build -c conda-forge
343350
packaging/build_conda.sh
344351
conda index ./conda-bld
345352
- name: Install TorchData Conda Package
346353
shell: bash -l {0}
347354
run: |
348-
conda activate conda_build_env
355+
conda activate "${CONDA_ENV_PATH}"
349356
if [[ ${{ needs.get_release_type.outputs.type }} == 'official' ]]; then
350357
CONDA_CHANNEL=pytorch
351358
else
@@ -355,7 +362,7 @@ jobs:
355362
- name: Run DataPipes Tests with pytest
356363
shell: bash -l {0}
357364
run: |
358-
conda activate conda_build_env
365+
conda activate "${CONDA_ENV_PATH}"
359366
pip3 install -r test/requirements.txt
360367
pytest --no-header -v test --ignore=test/test_period.py --ignore=test/test_text_examples.py --ignore=test/test_audio_examples.py
361368
- name: Upload Conda Package to Github
@@ -366,7 +373,7 @@ jobs:
366373
path: conda-bld/*/torchdata-*.tar.bz2
367374

368375
conda_upload:
369-
if: always() && inputs.branch != ''
376+
if: always() && inputs.branch != '' && inputs.do-upload == true
370377
needs: [get_release_type, conda_build_test]
371378
runs-on: ubuntu-latest
372379
container: continuumio/miniconda3

.github/workflows/pull_release.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Test Release Pipelines
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- .github/workflows/pull_release.yml
7+
- .github/workflows/_build_test_upload.yml
8+
9+
jobs:
10+
build_test_upload:
11+
if: github.repository == 'pytorch/data'
12+
uses: ./.github/workflows/_build_test_upload.yml
13+
with:
14+
branch: ""
15+
pre_dev_release: true
16+
pytorch_version: ""
17+
do-upload: false
18+
secrets:
19+
PYTORCH_BINARY_AWS_ACCESS_KEY_ID: ""
20+
PYTORCH_BINARY_AWS_SECRET_ACCESS_KEY: ""
21+
CONDA_TEST_PYTORCHBOT_TOKEN: ""

0 commit comments

Comments
 (0)