Skip to content
Closed

e2e WIP #3220

Show file tree
Hide file tree
Changes from all commits
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
14 changes: 7 additions & 7 deletions .github/workflows/e2e-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:
strategy:
matrix:
kubernetes_version:
- v1.27.3
- v1.28.0
- v1.35.0
- v1.34.3
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout repo
Expand All @@ -36,11 +36,11 @@ jobs:
with:
version: ${{ matrix.kubernetes_version }}

# Creates KinD with using k8s versions from the matrix above
- name: Set up kind with K8s version v1.22.4
# Creates kind using the Kubernetes versions from the matrix above
- name: Set up kind cluster
uses: engineerd/setup-kind@v0.5.0
with:
version: "v0.20.0"
version: "v0.31.0"
image: kindest/node:${{ matrix.kubernetes_version }}

- name: Testing kind cluster set-up
Expand All @@ -53,8 +53,8 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.24"
go-version: "1.25"

- name: Build devspacehelper
run: |
mkdir -p ~/.devspace/devspacehelper/latest
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22"
- uses: actions/checkout@v3
go-version: "1.25"
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3.2.0
uses: golangci/golangci-lint-action@v7
with:
version: v2.11.4
args:
-v
--config=.golangci.yml
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/npm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 12
node-version: 20
registry-url: https://registry.npmjs.org/
- run: |
npm install -g
Expand All @@ -35,10 +35,10 @@ jobs:
windows:
runs-on: windows-2019
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 12
node-version: 20
registry-url: https://registry.npmjs.org/
- run: |
npm install -g
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22"
go-version: "1.25"
- id: get_version
run: |
RELEASE_VERSION=$(echo $GITHUB_REF | sed -nE 's!refs/tags/!!p')
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.24"
go-version: "1.25"

- name: Check out code into the Go module directory
uses: actions/checkout@v1
Expand All @@ -40,12 +40,12 @@ jobs:
test-unit-windows:
runs-on: windows-latest
name: unit-test-windows-latest

steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.24"
go-version: "1.25"

- name: Check out code into the Go module directory
uses: actions/checkout@v1
Expand Down
26 changes: 11 additions & 15 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
version: "2"

run:
timeout: 10m

issues:
exclude-dirs:
- hack/
- docs/

linters:
disable-all: true
default: none
enable:
# - deadcode # deprecated https://github.com/golangci/golangci-lint/issues/1841
- gosimple
- govet
- ineffassign
- misspell
- unused
# - varcheck # deprecated https://github.com/golangci/golangci-lint/issues/1841
- staticcheck
- staticcheck # includes gosimple and stylecheck in v2
- errcheck
# - goimports
- dupl
- nakedret
- stylecheck
# - gofmt
# - golint
# - structcheck # deprecated https://github.com/golangci/golangci-lint/issues/1841

linters-settings:
gofmt:
simplify: true
dupl:
threshold: 400
settings:
dupl:
threshold: 400
exclusions:
paths:
- hack/
- docs/
83 changes: 65 additions & 18 deletions assets/assets.go

Large diffs are not rendered by default.

104 changes: 49 additions & 55 deletions dist/npm/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/usr/bin/env node
const fs = require("fs");
const https = require("https");
const path = require("path");
const execSync = require("child_process").execSync;
const fetch = require("node-fetch");
const Spinner = require("cli-spinner").Spinner;
const inquirer = require('inquirer');
const findProcess = require('find-process');

const getFetch = () => require("node-fetch");
const getSpinner = () => require("cli-spinner").Spinner;
const getInquirer = () => require("inquirer");
const getFindProcess = () => require("find-process");

const downloadPathTemplate =
"https://github.com/devspace-sh/devspace/releases/download/v{{version}}/devspace-{{platform}}-{{arch}}";
Expand Down Expand Up @@ -80,43 +82,27 @@ const sanitizeVersion = function(version) {

const getLatestVersion = function (callback) {
const releasesURL = "https://github.com/devspace-sh/devspace/releases/latest";
https.get(releasesURL, { headers: requestHeaders }, function (res) {
const redirectUrl = res.headers.location;
const matches = redirectUrl && /\/tag\/(.*)$/.exec(redirectUrl);

fetch(releasesURL, { headers: requestHeaders, redirect: false })
.then(function (res) {
if (!res.ok) {
console.error(
"Error requesting URL " +
releasesURL +
" (Status Code: " +
res.status +
")"
);
process.exit(1);
}

const redirectUrl = res.url
if (redirectUrl == null) {
throw new Error('Error fetching latest version')
}

const matches = /\/tag\/(.*)$/.exec(redirectUrl)
if (!matches || matches.length !== 2) {
throw new Error('Error fetching latest version')
}

const latestVersion = matches[1].replace('v', '')
if (latestVersion) {
callback(latestVersion);
} else {
console.error("Unable to identify latest devspace version");
process.exit(2);
}
})
.catch(function (err) {
if (!matches || matches.length !== 2) {
console.error("Error requesting URL " + releasesURL);
console.error(err)
process.exit(1);
})
}

const latestVersion = matches[1].replace('v', '')
if (latestVersion) {
callback(latestVersion);
} else {
console.error("Unable to identify latest devspace version");
process.exit(2);
}
}).on("error", function (err) {
console.error("Error requesting URL " + releasesURL);
console.error(err)
process.exit(1);
})
};

if (action === "update-version") {
Expand Down Expand Up @@ -311,6 +297,7 @@ let continueProcess = function (askRemoveGlobalFolder) {
removeScripts(true);

if (askRemoveGlobalFolder && process.stdout.isTTY) {
const inquirer = getInquirer();
let removeGlobalFolder = function () {
try {
let homedir = require('os').homedir();
Expand Down Expand Up @@ -366,6 +353,7 @@ let continueProcess = function (askRemoveGlobalFolder) {
};

const downloadRelease = function (version) {
const fetch = getFetch();
let downloadPath = downloadPathTemplate
.replace("{{version}}", version)
.replace("{{platform}}", platform)
Expand All @@ -377,6 +365,7 @@ let continueProcess = function (askRemoveGlobalFolder) {

console.log("Download DevSpace CLI release: " + downloadPath + "\n");

const Spinner = getSpinner();
const spinner = new Spinner(
"%s Downloading DevSpace CLI... (this may take a minute)"
);
Expand Down Expand Up @@ -466,25 +455,30 @@ let continueProcess = function (askRemoveGlobalFolder) {
}

if (process.ppid > 1) {
findProcess('pid', process.ppid)
.then(function (list) {
if (list.length === 1 && list[0].ppid > 1) {
findProcess('pid', list[0].ppid)
.then(function (list) {
if (list.length === 1 && /((npm-cli.js("|')\s+up(date)?)|(yarn.js("|')\s+(global\s+)?upgrade))\s+.*((\/)|(\\)|(\s))devspace((\/)|(\\)|(\s)|$)/.test(list[0].cmd)) {
continueProcess(false);
} else {
try {
const findProcess = getFindProcess();
findProcess('pid', process.ppid)
.then(function (list) {
if (list.length === 1 && list[0].ppid > 1) {
findProcess('pid', list[0].ppid)
.then(function (list) {
if (list.length === 1 && /((npm-cli.js("|')\s+up(date)?)|(yarn.js("|')\s+(global\s+)?upgrade))\s+.*((\/)|(\\)|(\s))devspace((\/)|(\\)|(\s)|$)/.test(list[0].cmd)) {
continueProcess(false);
} else {
continueProcess(true);
}
}, function () {
continueProcess(true);
}
}, function () {
continueProcess(true);
})
} else {
})
} else {
continueProcess(true);
}
}, function () {
continueProcess(true);
}
}, function () {
continueProcess(true);
})
})
} catch (e) {
continueProcess(true);
}
} else {
continueProcess(true);
}
11 changes: 11 additions & 0 deletions e2e/framework/env.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package framework

import "os"

func Setenv(key, value string) {
ExpectNoError(os.Setenv(key, value))
}

func Unsetenv(key string) {
ExpectNoError(os.Unsetenv(key))
}
8 changes: 4 additions & 4 deletions e2e/framework/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ func ExpectRemoteFileContents(imageSelector string, namespace string, filePath s
ExpectNoErrorWithOffset(1, err)
}

func ExpectLocalCurlContents(urlString string, contents string) {
func ExpectLocalCurlContains(urlString string, contents string) {
client := resty.New()
err := wait.PollUntilContextTimeout(context.TODO(), time.Second, time.Minute*2, true, func(_ context.Context) (done bool, err error) {
resp, _ := client.R().
EnableTrace().
Get(urlString)
return strings.TrimSpace(string(resp.Body())) == strings.TrimSpace(contents), nil
return strings.Contains(strings.TrimSpace(string(resp.Body())), strings.TrimSpace(contents)), nil
})
ExpectNoErrorWithOffset(1, err)
}
Expand All @@ -118,15 +118,15 @@ func ExpectContainerNameAndImageEqual(namespace, deploymentName, containerImage,
ExpectNoErrorWithOffset(1, err)
}

func ExpectRemoteCurlContents(imageSelector string, namespace string, urlString string, contents string) {
func ExpectRemoteCurlContains(imageSelector string, namespace string, urlString string, contents string) {
kubeClient, err := kube.NewKubeHelper()
ExpectNoErrorWithOffset(1, err)
err = wait.PollUntilContextTimeout(context.TODO(), time.Second, time.Minute*2, true, func(_ context.Context) (done bool, err error) {
out, err := kubeClient.ExecByImageSelector(imageSelector, namespace, []string{"curl", urlString})
if err != nil {
return false, nil
}
return strings.TrimSpace(out) == strings.TrimSpace(contents), nil
return strings.Contains(strings.TrimSpace(out), strings.TrimSpace(contents)), nil
})
ExpectNoErrorWithOffset(1, err)
}
Expand Down
Loading
Loading