Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lizardruss committed Oct 4, 2023
1 parent 95f9119 commit 842abf4
Show file tree
Hide file tree
Showing 23 changed files with 11,273 additions and 162 deletions.
38 changes: 29 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,41 @@ jobs:
id: npm-ci-test
run: npm run ci-test

test-action:
name: GitHub Actions Test
runs-on: ubuntu-latest

test-vcluster:
name: Install vcluster CLI Test
strategy:
matrix:
os:
- windows-latest
- ubuntu-latest
- macos-latest
version:
- v0.16.0
- 0.16.0
- latest
- ~
kubectl-install:
- true
- false
kubectl-version:
- v1.28.2
- 1.28.2
- latest
- ~
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Test Local Action
- name: Test Setup vCluster Action
id: test-action
uses: ./
with:
milliseconds: 1000
version: ${{ matrix.version }}
kubectl-install: ${{ matrix.kubectl-install }}
kubectl-version: ${{ matrix.kubectl-version }}

- name: Print Output
id: output
run: echo "${{ steps.test-action.outputs.time }}"
- name: Print Version
id: print-version
run: vcluster version
46 changes: 46 additions & 0 deletions __tests__/kubectl.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { expect, test } from '@jest/globals'

import { binaryUrl } from '../src/kubectl'

test('binaryUrl(platform: string, architecture: string, version: string)', async () => {
await expect(binaryUrl('darwin', 'arm64', '1.23.0-alpha.2')).resolves.toEqual(
'https://dl.k8s.io/release/v1.23.0-alpha.2/bin/darwin/arm64/kubectl'
)
await expect(binaryUrl('darwin', 'amd64', '1.23.0-alpha.2')).resolves.toEqual(
`https://dl.k8s.io/release/v1.23.0-alpha.2/bin/darwin/amd64/kubectl`
)
await expect(binaryUrl('darwin', 'x64', 'v1.23.0-alpha.2')).resolves.toEqual(
`https://dl.k8s.io/release/v1.23.0-alpha.2/bin/darwin/amd64/kubectl`
)
await expect(binaryUrl('darwin', 'amd64', '1.23.0-alpha.2')).resolves.toEqual(
`https://dl.k8s.io/release/v1.23.0-alpha.2/bin/darwin/amd64/kubectl`
)
await expect(
binaryUrl('darwin', 'amd64', 'v1.23.0-alpha.2')
).resolves.toEqual(
`https://dl.k8s.io/release/v1.23.0-alpha.2/bin/darwin/amd64/kubectl`
)

await expect(binaryUrl('linux', 'arm64', '1.21.0')).resolves.toEqual(
`https://dl.k8s.io/release/v1.21.0/bin/linux/arm64/kubectl`
)
await expect(binaryUrl('linux', 'amd64', '1.21.0')).resolves.toEqual(
`https://dl.k8s.io/release/v1.21.0/bin/linux/amd64/kubectl`
)
await expect(binaryUrl('linux', 'x64', '1.21.0')).resolves.toEqual(
`https://dl.k8s.io/release/v1.21.0/bin/linux/amd64/kubectl`
)
await expect(binaryUrl('linux', 'amd64', 'v1.21.0')).resolves.toEqual(
`https://dl.k8s.io/release/v1.21.0/bin/linux/amd64/kubectl`
)

await expect(binaryUrl('win32', 'amd64', '1.21.0')).resolves.toEqual(
`https://dl.k8s.io/release/v1.21.0/bin/windows/amd64/kubectl.exe`
)
await expect(binaryUrl('win32', 'amd64', 'v1.21.0')).resolves.toEqual(
`https://dl.k8s.io/release/v1.21.0/bin/windows/amd64/kubectl.exe`
)
await expect(binaryUrl('win32', 'x64', 'v1.21.0')).resolves.toEqual(
`https://dl.k8s.io/release/v1.21.0/bin/windows/amd64/kubectl.exe`
)
})
80 changes: 0 additions & 80 deletions __tests__/main.test.ts

This file was deleted.

15 changes: 15 additions & 0 deletions __tests__/util.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { expect, test } from '@jest/globals'

import { binaryName, isWindows } from '../src/util'

test('isWindows(platform: string)', () => {
expect(isWindows('win32')).toEqual(true)
expect(isWindows('darwin')).toEqual(false)
expect(isWindows('linux')).toEqual(false)
})

test('binaryName(platform: string, name: string)', () => {
expect(binaryName('win32', 'devspace')).toEqual('devspace.exe')
expect(binaryName('darwin', 'devspace')).toEqual('devspace')
expect(binaryName('linux', 'devspace')).toEqual('devspace')
})
51 changes: 51 additions & 0 deletions __tests__/vcluster.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { expect, test } from '@jest/globals'

import { binaryUrl } from '../src/vcluster'

test('binaryUrl(platform: string, architecture: string, version: string)', async () => {
await expect(binaryUrl('darwin', 'arm64', '5.14.4')).resolves.toEqual(
'https://github.com/loft-sh/vcluster/releases/download/v5.14.4/vcluster-darwin-arm64'
)
await expect(binaryUrl('darwin', 'amd64', '5.14.4')).resolves.toEqual(
'https://github.com/loft-sh/vcluster/releases/download/v5.14.4/vcluster-darwin-amd64'
)
await expect(binaryUrl('darwin', 'x64', '5.14.4')).resolves.toEqual(
'https://github.com/loft-sh/vcluster/releases/download/v5.14.4/vcluster-darwin-amd64'
)
await expect(binaryUrl('darwin', 'amd64', '5.14.4')).resolves.toEqual(
'https://github.com/loft-sh/vcluster/releases/download/v5.14.4/vcluster-darwin-amd64'
)
await expect(binaryUrl('darwin', 'amd64', 'v5.14.4')).resolves.toEqual(
'https://github.com/loft-sh/vcluster/releases/download/v5.14.4/vcluster-darwin-amd64'
)
await expect(binaryUrl('linux', 'arm64', '5.14.4')).resolves.toEqual(
'https://github.com/loft-sh/vcluster/releases/download/v5.14.4/vcluster-linux-arm64'
)
await expect(binaryUrl('linux', 'amd64', '5.14.4')).resolves.toEqual(
'https://github.com/loft-sh/vcluster/releases/download/v5.14.4/vcluster-linux-amd64'
)
await expect(binaryUrl('linux', 'x64', '5.14.4')).resolves.toEqual(
'https://github.com/loft-sh/vcluster/releases/download/v5.14.4/vcluster-linux-amd64'
)
await expect(binaryUrl('linux', 'amd64', 'v5.14.4')).resolves.toEqual(
'https://github.com/loft-sh/vcluster/releases/download/v5.14.4/vcluster-linux-amd64'
)
await expect(binaryUrl('win32', 'amd64', '5.14.4')).resolves.toEqual(
'https://github.com/loft-sh/vcluster/releases/download/v5.14.4/vcluster-windows-amd64.exe'
)
await expect(binaryUrl('win32', 'amd64', 'v5.14.4')).resolves.toEqual(
'https://github.com/loft-sh/vcluster/releases/download/v5.14.4/vcluster-windows-amd64.exe'
)
await expect(binaryUrl('win32', 'x64', 'v5.14.4')).resolves.toEqual(
'https://github.com/loft-sh/vcluster/releases/download/v5.14.4/vcluster-windows-amd64.exe'
)
await expect(binaryUrl('darwin', 'amd64', 'latest')).resolves.toMatch(
/https:\/\/github.com\/loft-sh\/vcluster\/releases\/download\/v\d+\.\d+\.\d+(-.*)?\/vcluster-darwin-amd64/
)
await expect(binaryUrl('linux', 'amd64', 'latest')).resolves.toMatch(
/https:\/\/github.com\/loft-sh\/vcluster\/releases\/download\/v\d+\.\d+\.\d+(-.*)?\/vcluster-linux-amd64/
)
await expect(binaryUrl('win32', 'amd64', 'latest')).resolves.toMatch(
/https:\/\/github.com\/loft-sh\/vcluster\/releases\/download\/v\d+\.\d+\.\d+(-.*)?\/vcluster-windows-amd64/
)
})
25 changes: 0 additions & 25 deletions __tests__/wait.test.ts

This file was deleted.

33 changes: 17 additions & 16 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
name: 'The name of your action here'
description: 'Provide a description here'
author: 'Your name or organization here'

# Define your inputs here.
name: vCluster CLI Install
author: loft.sh
description: Installs the vcluster CLI
inputs:
milliseconds:
description: 'Your input description here'
required: true
default: '1000'

# Define your outputs here.
outputs:
time:
description: 'Your output description here'

version:
description: 'The version of vcluster to install'
required: false
default: 'latest'
kubectl-install:
description: 'Install kubectl if not already installed'
required: false
default: 'true'
kubectl-version:
description: 'The version of the kubectl to install'
required: false
default: 'latest'
runs:
using: node20
main: dist/index.js
main: 'dist/main/index.js'
post: 'dist/cleanup/index.js'
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 842abf4

Please sign in to comment.