Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GraalPy support #694

Merged
merged 18 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
format, lint and build
  • Loading branch information
timfel committed Aug 21, 2023
commit 6db14b26fdb3f52ccb29f8d8d1eb74aac5e84c31
24 changes: 12 additions & 12 deletions __tests__/find-graalpy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ import * as path from 'path';
import * as semver from 'semver';

import * as finder from '../src/find-graalpy';
import {
IGraalPyManifestRelease,
} from '../src/utils';
import {IGraalPyManifestRelease} from '../src/utils';

import manifestData from './data/graalpy.json';

let architecture = 'x64';
const architecture = 'x64';

const toolDir = path.join(__dirname, 'runner', 'tools');
const tempDir = path.join(__dirname, 'runner', 'temp');
Expand All @@ -25,7 +23,7 @@ describe('parseGraalPyVersion', () => {
it.each([
['graalpy-23', '23'],
['graalpy-23.0', '23.0'],
['graalpy23.0', '23.0'],
['graalpy23.0', '23.0']
])('%s -> %s', (input, expected) => {
expect(finder.parseGraalPyVersion(input)).toEqual(expected);
});
Expand Down Expand Up @@ -308,9 +306,7 @@ describe('findGraalPyVersion', () => {
)
).resolves.toEqual('23.0.0');

expect(infoSpy).toHaveBeenCalledWith(
'Resolved as GraalPy 23.0.0'
);
expect(infoSpy).toHaveBeenCalledWith('Resolved as GraalPy 23.0.0');
});

it('check-latest enabled version found and install successfully', async () => {
Expand All @@ -329,9 +325,7 @@ describe('findGraalPyVersion', () => {
false
)
).resolves.toEqual('23.0.0');
expect(infoSpy).toHaveBeenCalledWith(
'Resolved as GraalPy 23.0.0'
);
expect(infoSpy).toHaveBeenCalledWith('Resolved as GraalPy 23.0.0');
});

it('check-latest enabled version is not found and used from toolcache', async () => {
Expand Down Expand Up @@ -366,7 +360,13 @@ describe('findGraalPyVersion', () => {
spyChmodSync = jest.spyOn(fs, 'chmodSync');
spyChmodSync.mockImplementation(() => undefined);
await expect(
finder.findGraalPyVersion('graalpy23.1', architecture, false, false, false)
finder.findGraalPyVersion(
'graalpy23.1',
architecture,
false,
false,
false
)
).rejects.toThrow();
await expect(
finder.findGraalPyVersion('graalpy23.1', architecture, false, false, true)
Expand Down
50 changes: 11 additions & 39 deletions __tests__/install-graalpy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {

import manifestData from './data/graalpy.json';

let architecture: string = 'x64';
const architecture = 'x64';

const toolDir = path.join(__dirname, 'runner', 'tools');
const tempDir = path.join(__dirname, 'runner', 'temp');
Expand All @@ -36,7 +36,7 @@ describe('findRelease', () => {
const result = JSON.stringify(manifestData);
const releases = JSON.parse(result) as IGraalPyManifestRelease[];
const extension = 'tar.gz';
const arch = architecture === 'x64' ? 'amd64' : 'aarch64';
const arch = architecture === 'x64' ? 'amd64' : 'aarch64';
const extensionName = IS_WINDOWS
? `windows-${arch}.${extension}`
: `${process.platform}-${arch}.${extension}`;
Expand Down Expand Up @@ -67,24 +67,14 @@ describe('findRelease', () => {
it("GraalPy version doesn't match", () => {
const graalpyVersion = '12.0.0';
expect(
installer.findRelease(
releases,
graalpyVersion,
architecture,
false
)
installer.findRelease(releases, graalpyVersion, architecture, false)
).toEqual(null);
});

it('GraalPy version matches', () => {
const graalpyVersion = '23.0.0';
expect(
installer.findRelease(
releases,
graalpyVersion,
architecture,
false
)
installer.findRelease(releases, graalpyVersion, architecture, false)
).toMatchObject({
foundAsset: files,
resolvedGraalPyVersion: graalpyVersion
Expand All @@ -94,12 +84,7 @@ describe('findRelease', () => {
it('Preview version of GraalPy is found', () => {
const graalpyVersion = installer.graalPyTagToVersion('vm-23.1.0a1');
expect(
installer.findRelease(
releases,
graalpyVersion,
architecture,
false
)
installer.findRelease(releases, graalpyVersion, architecture, false)
).toMatchObject({
foundAsset: {
name: `graalpython-23.1.0a1-${extensionName}`,
Expand All @@ -112,12 +97,7 @@ describe('findRelease', () => {
it('Latest GraalPy is found', () => {
const graalpyVersion = 'x';
expect(
installer.findRelease(
releases,
graalpyVersion,
architecture,
false
)
installer.findRelease(releases, graalpyVersion, architecture, false)
).toMatchObject({
foundAsset: files,
resolvedGraalPyVersion: '23.0.0'
Expand All @@ -127,20 +107,10 @@ describe('findRelease', () => {
it('GraalPy version matches semver (pre-release)', () => {
const graalpyVersion = '23.1.x';
expect(
installer.findRelease(
releases,
graalpyVersion,
architecture,
false
)
installer.findRelease(releases, graalpyVersion, architecture, false)
).toBeNull();
expect(
installer.findRelease(
releases,
graalpyVersion,
architecture,
true
)
installer.findRelease(releases, graalpyVersion, architecture, true)
).toMatchObject({
foundAsset: filesRC1,
resolvedGraalPyVersion: '23.1.0-a.1'
Expand All @@ -167,7 +137,9 @@ describe('installGraalPy', () => {

beforeEach(() => {
tcFind = jest.spyOn(tc, 'find');
tcFind.mockImplementation(() => path.join('GraalPy', '3.6.12', architecture));
tcFind.mockImplementation(() =>
path.join('GraalPy', '3.6.12', architecture)
);

spyDownloadTool = jest.spyOn(tc, 'downloadTool');
spyDownloadTool.mockImplementation(() => path.join(tempDir, 'GraalPy'));
Expand Down
Loading