diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4f62148f..a0e1aae2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -61,3 +61,32 @@ jobs: - name: Run simple code run: python -c 'import math; print(math.factorial(5))' + + setup-pre-release-version-from-manifest: + name: Setup 3.9.0-beta.4 ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [macos-latest, windows-latest, ubuntu-16.04, ubuntu-18.04] + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: setup-python 3.9.0-beta.4 + uses: ./ + with: + python-version: '3.9.0-beta.4' + + - name: Validate version + run: | + $pythonVersion = (python --version) + if ("Python ${{ matrix.python }}" -ne "$pythonVersion"){ + Write-Host "The current version is $pythonVersion; expected version is ${{ matrix.python }}" + exit 1 + } + $pythonVersion + shell: pwsh + + - name: Run simple code + run: python -c 'import math; print(math.factorial(5))' diff --git a/README.md b/README.md index b7146fdb..8cec2221 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,6 @@ steps: - uses: actions/setup-python@v2 with: python-version: '3.9.0-beta.4' - stable: false # optional true or false. Defaults to true if not specified - run: python my_script.py ``` @@ -110,7 +109,6 @@ steps: - uses: actions/setup-python@v2 with: python-version: '3.9.0-alpha - 3.9.0' # SemVer's version range syntax - stable: false # optional true or false. Defaults to true if not specified - run: python my_script.py ``` diff --git a/__tests__/finder.test.ts b/__tests__/finder.test.ts index b3a8df13..54bf3cf8 100644 --- a/__tests__/finder.test.ts +++ b/__tests__/finder.test.ts @@ -35,7 +35,7 @@ describe('Finder tests', () => { await io.mkdirP(pythonDir); fs.writeFileSync(`${pythonDir}.complete`, 'hello'); // This will throw if it doesn't find it in the cache and in the manifest (because no such version exists) - await finder.findPythonVersion('3.x', 'x64', true); + await finder.findPythonVersion('3.x', 'x64'); }); it('Finds stable Python version if it is not installed, but exists in the manifest', async () => { @@ -52,7 +52,7 @@ describe('Finder tests', () => { fs.writeFileSync(`${pythonDir}.complete`, 'hello'); }); // This will throw if it doesn't find it in the cache and in the manifest (because no such version exists) - await finder.findPythonVersion('1.2.3', 'x64', true); + await finder.findPythonVersion('1.2.3', 'x64'); }); it('Finds pre-release Python version in the manifest', async () => { @@ -74,14 +74,14 @@ describe('Finder tests', () => { fs.writeFileSync(`${pythonDir}.complete`, 'hello'); }); // This will throw if it doesn't find it in the manifest (because no such version exists) - await finder.findPythonVersion('1.2.3-beta.2', 'x64', false); + await finder.findPythonVersion('1.2.3-beta.2', 'x64'); }); it('Errors if Python is not installed', async () => { // This will throw if it doesn't find it in the cache and in the manifest (because no such version exists) let thrown = false; try { - await finder.findPythonVersion('3.300000', 'x64', true); + await finder.findPythonVersion('3.300000', 'x64'); } catch { thrown = true; } @@ -93,6 +93,6 @@ describe('Finder tests', () => { await io.mkdirP(pythonDir); fs.writeFileSync(`${pythonDir}.complete`, 'hello'); // This will throw if it doesn't find it in the cache (because no such version exists) - await finder.findPythonVersion('pypy2', 'x64', true); + await finder.findPythonVersion('pypy2', 'x64'); }); }); diff --git a/action.yml b/action.yml index 4d1098f1..b5dcf476 100644 --- a/action.yml +++ b/action.yml @@ -8,9 +8,6 @@ inputs: default: '3.x' architecture: description: 'The target architecture (x86, x64) of the Python interpreter.' - stable: - description: 'Whether to download only stable versions' - default: 'true' token: description: Used to pull python distributions from actions/python-versions. Since there's a default, this is typically not supplied by the user. default: ${{ github.token }} diff --git a/dist/index.js b/dist/index.js index bd08caa9..5ff593ff 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1143,10 +1143,10 @@ const MANIFEST_REPO_NAME = 'python-versions'; const MANIFEST_REPO_BRANCH = 'main'; exports.MANIFEST_URL = `https://raw.githubusercontent.com/${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}/${MANIFEST_REPO_BRANCH}/versions-manifest.json`; const IS_WINDOWS = process.platform === 'win32'; -function findReleaseFromManifest(semanticVersionSpec, architecture, stable) { +function findReleaseFromManifest(semanticVersionSpec, architecture) { return __awaiter(this, void 0, void 0, function* () { const manifest = yield tc.getManifestFromRepo(MANIFEST_REPO_OWNER, MANIFEST_REPO_NAME, AUTH, MANIFEST_REPO_BRANCH); - return yield tc.findFromManifest(semanticVersionSpec, stable, manifest, architecture); + return yield tc.findFromManifest(semanticVersionSpec, false, manifest, architecture); }); } exports.findReleaseFromManifest = findReleaseFromManifest; @@ -1627,8 +1627,7 @@ function run() { let version = core.getInput('python-version'); if (version) { const arch = core.getInput('architecture') || os.arch(); - let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE'; - const installed = yield finder.findPythonVersion(version, arch, stable); + const installed = yield finder.findPythonVersion(version, arch); core.info(`Successfully setup ${installed.impl} (${installed.version})`); } const matchersPath = path.join(__dirname, '..', '.github'); @@ -2308,7 +2307,7 @@ function usePyPy(majorVersion, architecture) { core.setOutput('python-version', impl); return { impl: impl, version: versionFromPath(installDir) }; } -function useCpythonVersion(version, architecture, stable) { +function useCpythonVersion(version, architecture) { return __awaiter(this, void 0, void 0, function* () { const desugaredVersionSpec = desugarDevVersion(version); const semanticVersionSpec = pythonVersionToSemantic(desugaredVersionSpec); @@ -2316,7 +2315,7 @@ function useCpythonVersion(version, architecture, stable) { let installDir = tc.find('Python', semanticVersionSpec, architecture); if (!installDir) { core.info(`Version ${semanticVersionSpec} was not found in the local cache`); - const foundRelease = yield installer.findReleaseFromManifest(semanticVersionSpec, architecture, stable); + const foundRelease = yield installer.findReleaseFromManifest(semanticVersionSpec, architecture); if (foundRelease && foundRelease.files && foundRelease.files.length > 0) { core.info(`Version ${semanticVersionSpec} is available for downloading`); yield installer.installCpythonFromRelease(foundRelease); @@ -2374,7 +2373,7 @@ function pythonVersionToSemantic(versionSpec) { return versionSpec.replace(prereleaseVersion, '$1-$2'); } exports.pythonVersionToSemantic = pythonVersionToSemantic; -function findPythonVersion(version, architecture, stable) { +function findPythonVersion(version, architecture) { return __awaiter(this, void 0, void 0, function* () { switch (version.toUpperCase()) { case 'PYPY2': @@ -2382,7 +2381,7 @@ function findPythonVersion(version, architecture, stable) { case 'PYPY3': return usePyPy(3, architecture); default: - return yield useCpythonVersion(version, architecture, stable); + return yield useCpythonVersion(version, architecture); } }); } diff --git a/src/find-python.ts b/src/find-python.ts index 7deec7d0..db06230d 100644 --- a/src/find-python.ts +++ b/src/find-python.ts @@ -71,8 +71,7 @@ function usePyPy(majorVersion: 2 | 3, architecture: string): InstalledVersion { async function useCpythonVersion( version: string, - architecture: string, - stable: boolean + architecture: string ): Promise { const desugaredVersionSpec = desugarDevVersion(version); const semanticVersionSpec = pythonVersionToSemantic(desugaredVersionSpec); @@ -89,8 +88,7 @@ async function useCpythonVersion( ); const foundRelease = await installer.findReleaseFromManifest( semanticVersionSpec, - architecture, - stable + architecture ); if (foundRelease && foundRelease.files && foundRelease.files.length > 0) { @@ -173,8 +171,7 @@ export function pythonVersionToSemantic(versionSpec: string) { export async function findPythonVersion( version: string, - architecture: string, - stable: boolean + architecture: string ): Promise { switch (version.toUpperCase()) { case 'PYPY2': @@ -182,6 +179,6 @@ export async function findPythonVersion( case 'PYPY3': return usePyPy(3, architecture); default: - return await useCpythonVersion(version, architecture, stable); + return await useCpythonVersion(version, architecture); } } diff --git a/src/install-python.ts b/src/install-python.ts index 954d542d..1ec98d8d 100644 --- a/src/install-python.ts +++ b/src/install-python.ts @@ -15,8 +15,7 @@ const IS_WINDOWS = process.platform === 'win32'; export async function findReleaseFromManifest( semanticVersionSpec: string, - architecture: string, - stable: boolean + architecture: string ): Promise { const manifest: tc.IToolRelease[] = await tc.getManifestFromRepo( MANIFEST_REPO_OWNER, @@ -26,7 +25,7 @@ export async function findReleaseFromManifest( ); return await tc.findFromManifest( semanticVersionSpec, - stable, + false, manifest, architecture ); diff --git a/src/setup-python.ts b/src/setup-python.ts index d46b281b..c97f314c 100644 --- a/src/setup-python.ts +++ b/src/setup-python.ts @@ -8,8 +8,7 @@ async function run() { let version = core.getInput('python-version'); if (version) { const arch: string = core.getInput('architecture') || os.arch(); - let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE'; - const installed = await finder.findPythonVersion(version, arch, stable); + const installed = await finder.findPythonVersion(version, arch); core.info(`Successfully setup ${installed.impl} (${installed.version})`); } const matchersPath = path.join(__dirname, '..', '.github');