Skip to content

Commit

Permalink
feat: added extended resource classes (#145)
Browse files Browse the repository at this point in the history
* feat: added extended resource classes

* chore: linting
  • Loading branch information
Jaryt authored Sep 18, 2022
1 parent d37379e commit 46cb714
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/lib/Components/Executors/types/DockerExecutor.types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { StringParameter } from '../../Parameters/types';
import { DockerImageShape } from '../exports/DockerImage';
import { AnyResourceClass } from './Executor.types';
import { AnyResourceClassBase } from './Executor.types';
/**
* A JSON representation of the Docker Executor Schema
* To be converted to YAML
Expand All @@ -15,4 +15,4 @@ export type DockerImageMap = {
* The available Docker Resource Classes.
* @see {@link https://circleci.com/docs/2.0/configuration-reference/#docker-executor} for specifications of each class.
*/
export type DockerResourceClass = AnyResourceClass;
export type DockerResourceClass = AnyResourceClassBase;
22 changes: 20 additions & 2 deletions src/lib/Components/Executors/types/Executor.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import { CustomParametersList } from '../../Parameters';
import { ExecutorParameterLiteral } from '../../Parameters/types/CustomParameterLiterals.types';
import { ReusableExecutor } from '../exports/ReusableExecutor';
import { ExecutableProperties } from './ExecutorParameters.types';
import {
MachineResourceClassArm,
MachineResourceClassGPU,
} from './MachineExecutor.types';
import { MacOSResourceClassAdvanced } from './MacOSExecutor.types';
import { ReusedExecutorShape } from './ReusableExecutor.types';

export type UnknownExecutableShape = {
Expand All @@ -23,9 +28,9 @@ export type ExecutorShape = {
export type AnyExecutorShape = ExecutorShape | ReusedExecutorShape;

/**
* The valid resource classes found for an executor object
* All valid resource classes found for an executor object for standard use cases
*/
export type AnyResourceClass =
export type AnyResourceClassBase =
| 'small'
| 'medium'
| 'medium+'
Expand All @@ -34,6 +39,19 @@ export type AnyResourceClass =
| '2xlarge'
| '2xlarge+';

/**
* The valid resource classes for advanced use cases
*/
export type AnyResourceClassExtended =
| MachineResourceClassArm
| MachineResourceClassGPU
| MacOSResourceClassAdvanced;

/**
* All valid resource classes found for an executor object
*/
export type AnyResourceClass = AnyResourceClassBase | AnyResourceClassExtended;

/**
* The valid executors found on an executor object
* Windows is covered by the machine literal
Expand Down
9 changes: 8 additions & 1 deletion src/lib/Components/Executors/types/MacOSExecutor.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,11 @@ export type MacOSExecutorShape = {
* The available MacOS Resource Classes.
* @see {@link https://circleci.com/docs/2.0/configuration-reference/#macos-executor} for specifications of each class.
*/
export type MacOSResourceClass = Extract<AnyResourceClass, 'medium' | 'large'>;
export type MacOSResourceClass = Extract<
AnyResourceClass,
'medium' | 'large' | MacOSResourceClassAdvanced
>;

export type MacOSResourceClassAdvanced =
| 'macos.x86.metal.gen1'
| 'macos.x86.medium.gen2';
30 changes: 27 additions & 3 deletions src/lib/Components/Executors/types/MachineExecutor.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,34 @@ export type MachineExecutorShape = {
};

/**
* The available Machine(Linux) Resource Classes.
* @see {@link https://circleci.com/docs/2.0/configuration-reference/#machine-executor-linux} for specifications of each class.
* The available GPU Machine (Linux) Resource Classes.
* @see {@link https://circleci.com/docs/configuration-reference#arm-execution-environment-linux} for specifications of each class.
*/
export type MachineResourceClassArm =
| 'arm.medium'
| 'arm.large'
| 'arm.xlarge'
| 'arm.2xlarge';

/**
* The available Machine (Linux) Resource Classes.
* @see {@link https://circleci.com/docs/configuration-reference#gpu-execution-environment-linux} for specifications of each class.
*/
export type MachineResourceClassGPU =
| 'gpu.nvidia.small'
| 'gpu.nvidia.medium'
| 'gpu.nvidia.large';

/**
* The available Arm Machine (Linux) Resource Classes.
* @see {@link https://circleci.com/docs/configuration-reference#linuxvm-execution-environment} for specifications of each class.
*/
export type MachineResourceClass = Extract<
AnyResourceClass,
'medium' | 'large' | 'xlarge' | '2xlarge'
| 'medium'
| 'large'
| 'xlarge'
| '2xlarge'
| MachineResourceClassArm
| MachineResourceClassGPU
>;

0 comments on commit 46cb714

Please sign in to comment.