diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5c67371..ae623dd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,7 +28,7 @@ jobs: needs: release strategy: matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] + os: [ubuntu-latest, windows-latest, macOS-12] steps: - name: Setup conda v1 uses: s-weigand/setup-conda@v1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b158e35..d06a102 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -49,7 +49,7 @@ jobs: CONDA_CHANNELS: 'defaults' strategy: matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] + os: [ubuntu-latest, windows-latest, macOS-12] steps: - uses: actions/checkout@v4 - name: Prepare tests @@ -88,7 +88,7 @@ jobs: ENV_PYTHON: 3.8 strategy: matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] + os: [ubuntu-latest, windows-latest, macOS-12] steps: - uses: actions/checkout@v4 - name: Prepare tests @@ -131,7 +131,7 @@ jobs: ENV_PYTHON: 3.8 strategy: matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] + os: [ubuntu-latest, windows-latest, macOS-12] steps: - uses: actions/checkout@v4 - name: Prepare tests @@ -174,7 +174,7 @@ jobs: needs: jest-tests strategy: matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] + os: [ubuntu-latest, windows-latest, macOS-12] steps: - uses: actions/checkout@v4 - name: Prepare tests @@ -212,7 +212,7 @@ jobs: needs: jest-tests strategy: matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] + os: [ubuntu-latest, windows-latest, macOS-12] steps: - uses: actions/checkout@v4 - name: Prepare tests @@ -250,7 +250,7 @@ jobs: needs: jest-tests strategy: matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] + os: [ubuntu-latest, windows-latest, macOS-12] steps: - uses: actions/checkout@v4 - name: Prepare tests @@ -286,7 +286,7 @@ jobs: needs: jest-tests strategy: matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] + os: [ubuntu-latest, windows-latest, macOS-12] steps: - uses: actions/checkout@v4 - name: Download built dist @@ -325,7 +325,7 @@ jobs: PYPY_TEST: true strategy: matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] + os: [ubuntu-latest, windows-latest, macOS-12] pypy-ver: ['pypy3.7'] include: - os: ubuntu-latest @@ -354,5 +354,5 @@ jobs: - name: Run tests run: | pypy -m ensurepip - pypy -m pip install -q pytest + pypy -m pip install --trusted-host pypi.python.org -q pytest pypy -m pytest -v integrationtests/test_python_version.py diff --git a/README.md b/README.md index 75e3e36..8f3de62 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,9 @@ This action adds the [`conda`](https://conda.io/projects/conda/en/latest/user-guide/tasks/index.html) command from the on the worker preinstalled miniconda version to the known shell commands. +> [!CAUTION] +> This action [is known to currently not work with macOS runner-images newer than `macOS-12` (i.e. `macOS-latest`)](https://github.com/s-weigand/setup-conda/issues/432). + ## Inputs | Name | Requirement | Default | Description | diff --git a/__tests__/conda_actions.test.ts b/__tests__/conda_actions.test.ts index 9c5eb96..fb70c23 100644 --- a/__tests__/conda_actions.test.ts +++ b/__tests__/conda_actions.test.ts @@ -1,6 +1,10 @@ +import { EOL } from 'os' import { readFileSync } from 'fs' import { resolve } from 'path' -import { parseActivationScriptOutput } from '../src/conda_actions' +import { + parseActivationScriptOutput, + addCondaToPath, +} from '../src/conda_actions' describe('Parse env activation output', () => { it('Parse linux activation', async () => { @@ -65,3 +69,46 @@ describe('Parse env activation output', () => { expect(envVars['CONDA_PYTHON_EXE']).toBe('C:\\Miniconda\\python.exe') }) }) + +const testConfig = { + activate_conda: false, + update_conda: false, + python_version: '', + conda_channels: [], + os: 'linux', +} + +describe("Throw error if CONDA env var isn't set", () => { + const OLD_ENV = process.env + + beforeEach(() => { + process.env = {} + }) + + afterAll(() => { + process.env = OLD_ENV + }) + + it.each(['linux', 'win32', 'darwin'])( + `General error %p`, + async (os: string) => { + await expect(addCondaToPath({ ...testConfig, os })).rejects.toThrow( + 'Could not determine conda base path, it seams conda is not installed.', + ) + }, + ) + + it('MacOs > 12 error', async () => { + process.env.ImageOS = 'macos13' + await expect( + addCondaToPath({ ...testConfig, os: 'darwin' }), + ).rejects.toThrow( + [ + 'Could not determine conda base path, it seams conda is not installed.', + 'MacOS images newer than "macos-12" (i.e. "macOS-latest") are known to be ' + + 'incompatible with this action due to a missing miniconda installation.', + 'See: https://github.com/s-weigand/setup-conda/issues/432', + ].join(EOL), + ) + }) +}) diff --git a/src/conda_actions.ts b/src/conda_actions.ts index 408a885..df6b9e9 100644 --- a/src/conda_actions.ts +++ b/src/conda_actions.ts @@ -56,10 +56,29 @@ const add_bin_dir = (python_dist_dir: string, config: ConfigObject): void => { * * @param config Configuration of the action */ -const addCondaToPath = async (config: ConfigObject): Promise => { +export const addCondaToPath = async (config: ConfigObject): Promise => { startGroup('Adding conda path to PATH') - console.log(`${process.env.CONDA}`) - const conda_base_path = process.env.CONDA as string + console.log('The CONDA env var is:', process.env.CONDA) + const conda_base_path = process.env.CONDA + let errorMessageAppendix: string[] = [] + if (conda_base_path === undefined) { + if (config.os === 'darwin' && process.env.ImageOS !== undefined) { + const macImageVersion = Number(process.env.ImageOS.replace('macos', '')) + if (macImageVersion > 12) { + errorMessageAppendix = [ + 'MacOS images newer than "macos-12" (i.e. "macOS-latest") are known to be ' + + 'incompatible with this action due to a missing miniconda installation.', + 'See: https://github.com/s-weigand/setup-conda/issues/432', + ] + } + } + throw new Error( + [ + 'Could not determine conda base path, it seams conda is not installed.', + ...errorMessageAppendix, + ].join(EOL), + ) + } sane_add_path(conda_base_path) add_bin_dir(conda_base_path, config) endGroup() @@ -250,7 +269,7 @@ const chown_conda_macOs = async (config: ConfigObject): Promise => { */ const update_conda = async (config: ConfigObject): Promise => { if (config.update_conda) { - startGroup('Updateing conda:') + startGroup('Updating conda:') await exec('conda', [ 'update', '-y',