Skip to content

Commit 3eb826d

Browse files
committed
Use a better method of setting environment variables in the GitHub actions file
1 parent a13ee1b commit 3eb826d

File tree

2 files changed

+41
-36
lines changed

2 files changed

+41
-36
lines changed

.github/workflows/array-api-tests-torch.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ jobs:
1111
# https://github.com/data-apis/array-api-tests/pull/101
1212
pytest-extra-args: "--disable-extension linalg"
1313
extra-env-vars: |
14-
ARRAY_API_TESTS_SKIP_DTYPES: uint16,uint32,uint64
14+
ARRAY_API_TESTS_SKIP_DTYPES=uint16,uint32,uint64

.github/workflows/array-api-tests.yml

+40-35
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ on:
3030
extra-env-vars:
3131
required: false
3232
type: string
33-
description: 'Extra environment variables to set during the test run'
33+
description: "Multiline string of environment variables to set for the test run."
3434

3535
env:
3636
PYTEST_ARGS: "--max-examples 200 -v -rxXfE --ci ${{ inputs.pytest-extra-args }} --hypothesis-disable-deadline"
@@ -41,38 +41,43 @@ jobs:
4141
strategy:
4242
matrix:
4343
python-version: ['3.9', '3.10', '3.11', '3.12']
44+
4445
steps:
45-
- name: Checkout array-api-compat
46-
uses: actions/checkout@v4
47-
with:
48-
path: array-api-compat
49-
- name: Checkout array-api-tests
50-
uses: actions/checkout@v4
51-
with:
52-
repository: data-apis/array-api-tests
53-
submodules: 'true'
54-
path: array-api-tests
55-
- name: Set up Python ${{ matrix.python-version }}
56-
uses: actions/setup-python@v5
57-
with:
58-
python-version: ${{ matrix.python-version }}
59-
- name: Install dependencies
60-
# NumPy 1.21 doesn't support Python 3.11. There doesn't seem to be a way
61-
# to put this in the numpy 1.21 config file.
62-
if: "! ((matrix.python-version == '3.11' || matrix.python-version == '3.12') && inputs.package-name == 'numpy' && contains(inputs.package-version, '1.21'))"
63-
run: |
64-
python -m pip install --upgrade pip
65-
python -m pip install '${{ inputs.package-name }} ${{ inputs.package-version }}' ${{ inputs.extra-requires }}
66-
python -m pip install -r ${GITHUB_WORKSPACE}/array-api-tests/requirements.txt
67-
- name: Run the array API testsuite (${{ inputs.package-name }})
68-
if: "! ((matrix.python-version == '3.11' || matrix.python-version == '3.12') && inputs.package-name == 'numpy' && contains(inputs.package-version, '1.21'))"
69-
env:
70-
ARRAY_API_TESTS_MODULE: array_api_compat.${{ inputs.module-name || inputs.package-name }}
71-
# This enables the NEP 50 type promotion behavior (without it a lot of
72-
# tests fail on bad scalar type promotion behavior)
73-
NPY_PROMOTION_STATE: weak
74-
${{ inputs.extra-env-vars }}
75-
run: |
76-
export PYTHONPATH="${GITHUB_WORKSPACE}/array-api-compat"
77-
cd ${GITHUB_WORKSPACE}/array-api-tests
78-
pytest array_api_tests/ --xfails-file ${GITHUB_WORKSPACE}/array-api-compat/${{ inputs.package-name }}${{ inputs.xfails-file-extra }}-xfails.txt --skips-file ${GITHUB_WORKSPACE}/array-api-compat/${{ inputs.package-name }}${{ inputs.skips-file-extra}}-skips.txt ${PYTEST_ARGS}
46+
- name: Checkout array-api-compat
47+
uses: actions/checkout@v4
48+
with:
49+
path: array-api-compat
50+
- name: Checkout array-api-tests
51+
uses: actions/checkout@v4
52+
with:
53+
repository: data-apis/array-api-tests
54+
submodules: 'true'
55+
path: array-api-tests
56+
- name: Set up Python ${{ matrix.python-version }}
57+
uses: actions/setup-python@v5
58+
with:
59+
python-version: ${{ matrix.python-version }}
60+
- name: Set Extra Environment Variables
61+
# Set additional environment variables if provided
62+
if: inputs.extra-env-vars
63+
run: |
64+
echo "${{ inputs.extra-env-vars }}" >> $GITHUB_ENV
65+
- name: Install dependencies
66+
# NumPy 1.21 doesn't support Python 3.11. There doesn't seem to be a way
67+
# to put this in the numpy 1.21 config file.
68+
if: "! ((matrix.python-version == '3.11' || matrix.python-version == '3.12') && inputs.package-name == 'numpy' && contains(inputs.package-version, '1.21'))"
69+
run: |
70+
python -m pip install --upgrade pip
71+
python -m pip install '${{ inputs.package-name }} ${{ inputs.package-version }}' ${{ inputs.extra-requires }}
72+
python -m pip install -r ${GITHUB_WORKSPACE}/array-api-tests/requirements.txt
73+
- name: Run the array API testsuite (${{ inputs.package-name }})
74+
if: "! ((matrix.python-version == '3.11' || matrix.python-version == '3.12') && inputs.package-name == 'numpy' && contains(inputs.package-version, '1.21'))"
75+
env:
76+
ARRAY_API_TESTS_MODULE: array_api_compat.${{ inputs.module-name || inputs.package-name }}
77+
# This enables the NEP 50 type promotion behavior (without it a lot of
78+
# tests fail on bad scalar type promotion behavior)
79+
NPY_PROMOTION_STATE: weak
80+
run: |
81+
export PYTHONPATH="${GITHUB_WORKSPACE}/array-api-compat"
82+
cd ${GITHUB_WORKSPACE}/array-api-tests
83+
pytest array_api_tests/ --xfails-file ${GITHUB_WORKSPACE}/array-api-compat/${{ inputs.package-name }}${{ inputs.xfails-file-extra }}-xfails.txt --skips-file ${GITHUB_WORKSPACE}/array-api-compat/${{ inputs.package-name }}${{ inputs.skips-file-extra}}-skips.txt ${PYTEST_ARGS}

0 commit comments

Comments
 (0)