Skip to content

Commit

Permalink
feat!: remove support for Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
theoludwig committed Nov 14, 2023
1 parent e0ca31b commit bb20b7f
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 157 deletions.
33 changes: 2 additions & 31 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,7 @@ jobs:
- name: 'Unit Test'
run: 'npm run test:unit'

test-e2e-docker:
runs-on: 'ubuntu-latest'
timeout-minutes: 15
steps:
- uses: 'actions/checkout@v4.1.1'

- name: 'Setup Docker'
uses: 'actions-hub/docker/cli@master'
env:
SKIP_LOGIN: true

- name: 'Setup Node.js'
uses: 'actions/setup-node@v4.0.0'
with:
node-version: 'lts/*'
cache: 'npm'

- name: 'Install dependencies'
run: 'npm clean-install'

- name: 'Build'
run: 'npm run build'

- name: 'Install leon'
run: 'npm install --global'

- name: 'End To End (e2e) Test with Docker'
run: 'npm run test:e2e-docker'

test-e2e-classic:
test-e2e:
runs-on: ${{ matrix.os }}
timeout-minutes: 15

Expand Down Expand Up @@ -87,4 +58,4 @@ jobs:
run: 'npm install --global'

- name: 'End To End (e2e) Test'
run: 'npm run test:e2e-classic'
run: 'npm run test:e2e'
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"files": [
"build",
"!**/*.test.js",
"!**/*.test.d.ts",
"!**/*.map"
],
"imports": {
Expand All @@ -58,8 +59,7 @@
"lint:prettier": "prettier . --check",
"lint:staged": "lint-staged",
"test:unit": "cross-env NODE_ENV=test node --enable-source-maps --test build/",
"test:e2e-docker": "cross-env NODE_ENV=test node --enable-source-maps --test ./build/e2e/docker.test.e2e.js",
"test:e2e-classic": "cross-env NODE_ENV=test node --enable-source-maps --test ./build/e2e/classic.test.e2e.js",
"test:e2e": "cross-env NODE_ENV=test node --enable-source-maps --test ./build/e2e/classic.test.e2e.js",
"release": "semantic-release",
"postinstall": "husky install",
"prepublishOnly": "pinst --disable",
Expand Down
1 change: 0 additions & 1 deletion src/commands/__test__/delete.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ await test('leon delete', async (t) => {
const leonInstanceOptions: LeonInstanceOptions = {
name: 'random-name',
birthDate: 'birthDate',
mode: 'docker',
path: '/path'
}
const leonInstance = new LeonInstance(leonInstanceOptions)
Expand Down
3 changes: 0 additions & 3 deletions src/commands/__test__/info.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { isExistingPath } from '#src/utils/isExistingPath.js'
const leonInstanceOptions: LeonInstanceOptions = {
name: 'random-name',
birthDate: '2022-02-20T10:11:33.315Z',
mode: 'docker',
path: '/path'
}

Expand Down Expand Up @@ -65,7 +64,6 @@ await test('leon info', async (t) => {
let infoResult = table([
[chalk.bold('Name'), leonInstance.name],
[chalk.bold('Path'), leonInstance.path],
[chalk.bold('Mode'), leonInstance.mode],
[chalk.bold('Birth date'), birthDayString],
[chalk.bold('Version'), version]
])
Expand Down Expand Up @@ -151,7 +149,6 @@ await test('leon info', async (t) => {
let infoResult = table([
[chalk.bold('Name'), leonInstance.name],
[chalk.bold('Path'), leonInstance.path],
[chalk.bold('Mode'), leonInstance.mode],
[chalk.bold('Birth date'), birthDayString],
[chalk.bold('Version'), '0.0.0']
])
Expand Down
1 change: 0 additions & 1 deletion src/commands/__test__/start.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { isExistingPath } from '#src/utils/isExistingPath.js'
const leonInstanceOptions: LeonInstanceOptions = {
name: 'random-name',
birthDate: '2022-02-20T10:11:33.315Z',
mode: 'docker',
path: '/path'
}

Expand Down
5 changes: 0 additions & 5 deletions src/commands/create/birth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ export class CreateBirthCommand extends Command {
description: 'Install Leon from the `develop` Git branch.'
})

public useDocker = Option.Boolean('--docker', false, {
description: 'Install Leon with Docker.'
})

public birthPath = Option.String('--path', {
description: 'Location of your Leon instance.'
})
Expand All @@ -37,7 +33,6 @@ export class CreateBirthCommand extends Command {
useDevelopGitBranch: this.useDevelopGitBranch,
birthPath: this.birthPath,
version: this.version,
useDocker: this.useDocker,
name: this.name
})
await leon.createBirth()
Expand Down
1 change: 0 additions & 1 deletion src/commands/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export class UpdateCommand extends Command {
useDevelopGitBranch: this.useDevelopGitBranch,
birthPath: leonInstance.path,
version: this.version,
useDocker: leonInstance.mode === 'docker',
name: leonInstance.name
})
const oldVersion = await leonInstance.getVersion()
Expand Down
9 changes: 0 additions & 9 deletions src/e2e/docker.test.e2e.ts

This file was deleted.

54 changes: 16 additions & 38 deletions src/e2e/tests/1-create-birth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,19 @@ import { execa } from 'execa'
import { Leon } from '#src/services/Leon.js'
import { isExistingPath } from '#src/utils/isExistingPath.js'

interface Options {
useDocker?: boolean
}

const TWENTY_MINUTES = 20 * 60 * 1000

export const test1CreateBirth = async (
options: Options = {}
): Promise<void> => {
const { useDocker = false } = options

export const test1CreateBirth = async (): Promise<void> => {
await test(
'leon create birth',
{
timeout: TWENTY_MINUTES
},
async () => {
const commandOptions = useDocker ? ['--docker'] : []
assert.strictEqual(await isExistingPath(Leon.DEFAULT_BIRTH_PATH), false)
const result = await execa(
'leon',
['create', 'birth', ...commandOptions],
{
stdio: 'inherit'
}
)
const result = await execa('leon', ['create', 'birth'], {
stdio: 'inherit'
})
assert.strictEqual(result.exitCode, 0)
assert.strictEqual(await isExistingPath(Leon.DEFAULT_BIRTH_PATH), true)
assert.strictEqual(
Expand All @@ -41,27 +28,18 @@ export const test1CreateBirth = async (
),
true
)
if (!useDocker) {
assert.strictEqual(
await isExistingPath(
path.join(Leon.DEFAULT_BIRTH_PATH, 'node_modules')
),
true
)
assert.strictEqual(
await isExistingPath(
path.join(Leon.DEFAULT_BIRTH_PATH, 'server', 'dist')
),
true
)
} else {
const dockerResult = await execa('docker', [
'image',
'inspect',
'leon-ai/leon'
])
assert.strictEqual(dockerResult.exitCode, 0)
}
assert.strictEqual(
await isExistingPath(
path.join(Leon.DEFAULT_BIRTH_PATH, 'node_modules')
),
true
)
assert.strictEqual(
await isExistingPath(
path.join(Leon.DEFAULT_BIRTH_PATH, 'server', 'dist')
),
true
)
}
)
}
7 changes: 0 additions & 7 deletions src/services/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,11 @@ import { Type } from '@sinclair/typebox'

import { packageJSON } from '#src/packageJSON.js'

export const instanceModes = [Type.Literal('classic'), Type.Literal('docker')]

const instanceMode = Type.Union(instanceModes)

export type InstanceMode = Static<typeof instanceMode>

export const configSchema = {
instances: Type.Array(
Type.Object({
name: Type.String({ examples: ['Office'] }),
path: Type.String({ examples: ['/home/user/.leon'] }),
mode: instanceMode,
birthDate: Type.String({ examples: ['2021-04-26T13:47:41.319Z'] })
}),
{ default: [] }
Expand Down
8 changes: 1 addition & 7 deletions src/services/Leon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export interface LeonOptions {
useDevelopGitBranch?: boolean
birthPath?: string
version?: string
useDocker?: boolean
name?: string
}

Expand All @@ -29,22 +28,19 @@ export class Leon implements LeonOptions {
public useDevelopGitBranch: boolean
public birthPath: string
public version?: string
public useDocker: boolean
public name: string

constructor(options: LeonOptions) {
const {
useDevelopGitBranch = false,
birthPath,
version,
useDocker = false,
name = crypto.randomUUID()
} = options
this.useDevelopGitBranch = useDevelopGitBranch
this.birthPath =
birthPath != null ? path.resolve(birthPath) : Leon.DEFAULT_BIRTH_PATH
this.version = version
this.useDocker = useDocker
this.name = name
}

Expand Down Expand Up @@ -101,7 +97,6 @@ export class Leon implements LeonOptions {
message: `${this.name} already exists, please provide another instance name.`
})
}
const mode = this.useDocker ? 'docker' : 'classic'
if (!cwdIsLeonCore) {
const requirements = Requirements.getInstance()
const loader = ora(`Downloading Leon source code`).start()
Expand All @@ -126,8 +121,7 @@ export class Leon implements LeonOptions {
}
const leonInstance = await LeonInstance.create({
name: this.name,
path: this.birthPath,
mode
path: this.birthPath
})
await leonInstance.configure()
}
Expand Down

0 comments on commit bb20b7f

Please sign in to comment.