From c701d81b5473d1a62f355498bb3af7df15e54062 Mon Sep 17 00:00:00 2001 From: s-weigand Date: Fri, 17 May 2024 11:36:14 +0200 Subject: [PATCH 1/6] =?UTF-8?q?=F0=9F=A7=B9=20Fix=20typo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/conda_actions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conda_actions.ts b/src/conda_actions.ts index 408a885..b7bfe33 100644 --- a/src/conda_actions.ts +++ b/src/conda_actions.ts @@ -250,7 +250,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', From af970471f20253f42ee43696bc7a7ae4e19bbdb7 Mon Sep 17 00:00:00 2001 From: s-weigand Date: Fri, 17 May 2024 11:38:59 +0200 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=91=8C=20Raise=20error=20if=20CONDA?= =?UTF-8?q?=20env=20var=20isn't=20set?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 👌 Reference issue in error for macOs > 12 --- src/conda_actions.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/conda_actions.ts b/src/conda_actions.ts index b7bfe33..221f51d 100644 --- a/src/conda_actions.ts +++ b/src/conda_actions.ts @@ -59,7 +59,26 @@ const add_bin_dir = (python_dist_dir: string, config: ConfigObject): void => { 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 + 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() From 54b76423215b875e1cb506eeeb59b84d07a905d0 Mon Sep 17 00:00:00 2001 From: s-weigand Date: Fri, 17 May 2024 11:48:17 +0200 Subject: [PATCH 3/6] =?UTF-8?q?=F0=9F=9A=87=F0=9F=A9=B9=20Use=20macOS-12?= =?UTF-8?q?=20instead=20of=20macOS-latest=20in=20CI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 2 +- .github/workflows/test.yml | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) 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..58106d4 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 From 04f4334d9a6ab2a7352ab8c6e013951477241223 Mon Sep 17 00:00:00 2001 From: s-weigand Date: Fri, 17 May 2024 12:17:09 +0200 Subject: [PATCH 4/6] =?UTF-8?q?=F0=9F=9A=87=F0=9F=A9=B9=20Fix=20failing=20?= =?UTF-8?q?integration=20test=20for=20pypy2.7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The problem was that pip 9 (latest available pip for pypy2.7) uses outdated SSL certs resulting in the following error: Collecting pytest Could not fetch URL https://pypi.python.org/simple/pytest/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed - skipping Could not find a version that satisfies the requirement pytest (from versions: ) No matching distribution found for pytest --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 58106d4..d06a102 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 From e66608abb732b8e2abf1351c6c8f51726b4c5c43 Mon Sep 17 00:00:00 2001 From: s-weigand Date: Fri, 17 May 2024 14:05:20 +0200 Subject: [PATCH 5/6] =?UTF-8?q?=F0=9F=A7=AA=20Add=20unit=20tests=20for=20h?= =?UTF-8?q?andling=20of=20missing=20CONDA=20env=20var?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __tests__/conda_actions.test.ts | 49 ++++++++++++++++++++++++++++++++- src/conda_actions.ts | 6 ++-- 2 files changed, 51 insertions(+), 4 deletions(-) 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 221f51d..df6b9e9 100644 --- a/src/conda_actions.ts +++ b/src/conda_actions.ts @@ -56,13 +56,13 @@ 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}`) + 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) { + if (config.os === 'darwin' && process.env.ImageOS !== undefined) { const macImageVersion = Number(process.env.ImageOS.replace('macos', '')) if (macImageVersion > 12) { errorMessageAppendix = [ From ee2c7f371096ff18c725bccf12d117e412b3a29f Mon Sep 17 00:00:00 2001 From: s-weigand Date: Fri, 17 May 2024 14:20:23 +0200 Subject: [PATCH 6/6] =?UTF-8?q?=F0=9F=93=9A=20Add=20disclaimer=20about=20n?= =?UTF-8?q?ot=20working=20with=20macOS=20>=2012?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 +++ 1 file changed, 3 insertions(+) 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 |