Skip to content

Commit 7f2af3f

Browse files
Merge branch 'main' into fix/1058-faulty-java-home
2 parents bfe3860 + 0d9b336 commit 7f2af3f

22 files changed

+524
-55
lines changed

.github/workflows/check-for-updates.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,16 @@ jobs:
3434
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
3535
https://api.github.com/repos/${{ github.repository }}/actions/workflows/nightly-build.yml/dispatches \
3636
-d '{"ref":"main"}'
37+
# Starts integration-tests workflow when new commits were found and nightly build was successful
38+
trigger_integration_tests:
39+
runs-on: ubuntu-latest
40+
needs: trigger_build
41+
if: ${{ needs.verify_commit.outputs.RUN_BUILD == 'true' }}
42+
steps:
43+
- name: Trigger Nightly Integration test Workflow
44+
run: |
45+
curl -X POST \
46+
-H "Accept: application/vnd.github.v3+json" \
47+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
48+
https://api.github.com/repos/${{ github.repository }}/actions/workflows/integration-tests.yml/dispatches \
49+
-d '{"ref":"main"}'
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Integration Tests
2+
on:
3+
workflow_dispatch
4+
5+
jobs:
6+
# Runs integration tests for each os
7+
run-integration-tests:
8+
name: Run integration test
9+
runs-on: ${{ matrix.os }}
10+
strategy:
11+
matrix:
12+
os: [ windows-latest, ubuntu-latest, macos-latest, macos-13 ]
13+
steps:
14+
- uses: actions/checkout@v3
15+
with:
16+
submodules: recursive
17+
- name: Run integration tests
18+
shell: bash
19+
run: |
20+
cd cli/src/test
21+
./all-tests.sh ${{ matrix.os }}

README.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ image:https://img.shields.io/maven-central/v/com.devonfw.tools.IDEasy/ide-cli.sv
1111
image:https://github.com/devonfw/IDEasy/actions/workflows/build.yml/badge.svg["Build Status",link="https://github.com/devonfw/IDEasy/actions/workflows/build.yml"]
1212
image:https://github.com/devonfw/IDEasy/actions/workflows/update-urls.yml/badge.svg["Update URLS Status",link="https://github.com/devonfw/IDEasy/actions/workflows/update-urls.yml"]
1313
image:https://github.com/devonfw/IDEasy/actions/workflows/nightly-build.yml/badge.svg["Nightly Release",link="https://github.com/devonfw/IDEasy/actions/workflows/nightly-build.yml"]
14+
image:https://github.com/devonfw/IDEasy/actions/workflows/integration-tests.yml/badge.svg["Integration Tests",link="https://github.com/devonfw/IDEasy/actions/workflows/integration-tests.yml"]
1415
image:https://coveralls.io/repos/github/devonfw/IDEasy/badge.svg?branch=main["Coverage Status",link="https://coveralls.io/github/devonfw/IDEasy?branch=main"]
1516

1617
toc::[]

cli/src/main/java/com/devonfw/tools/ide/commandlet/CreateCommandlet.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public void run() {
6161

6262
initializeProject(newProjectPath);
6363
this.context.setIdeHome(newProjectPath);
64+
this.context.verifyIdeMinVersion(true);
6465
super.run();
6566
this.context.getFileAccess().writeFileContent(IdeVersion.getVersionString(), newProjectPath.resolve(IdeContext.FILE_SOFTWARE_VERSION));
6667
this.context.success("Successfully created new project '{}'.", newProjectName);

cli/src/main/java/com/devonfw/tools/ide/context/AbstractIdeContext.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.devonfw.tools.ide.context;
22

3+
import static com.devonfw.tools.ide.variable.IdeVariables.IDE_MIN_VERSION;
4+
35
import java.io.BufferedReader;
46
import java.io.InputStreamReader;
57
import java.net.URL;
@@ -67,6 +69,7 @@
6769
import com.devonfw.tools.ide.validation.ValidationResultValid;
6870
import com.devonfw.tools.ide.validation.ValidationState;
6971
import com.devonfw.tools.ide.variable.IdeVariables;
72+
import com.devonfw.tools.ide.version.IdeVersion;
7073
import com.devonfw.tools.ide.version.VersionIdentifier;
7174

7275
/**
@@ -899,6 +902,7 @@ public int run(CliArguments arguments) {
899902
}
900903
}
901904
this.startContext.activateLogging();
905+
verifyIdeMinVersion(false);
902906
if (result != null) {
903907
error(result.getErrorMessage());
904908
}
@@ -1061,6 +1065,23 @@ private void verifyIdeRoot() {
10611065
}
10621066
}
10631067

1068+
public void verifyIdeMinVersion(boolean throwException) {
1069+
if (IDE_MIN_VERSION.get(this) == null) {
1070+
return;
1071+
}
1072+
if (IdeVersion.getVersionIdentifier().compareVersion(IDE_MIN_VERSION.get(this)).isLess()) {
1073+
String message = String.format("Your version of IDEasy is currently %s\n"
1074+
+ "However, this is too old as your project requires at latest version %s\n"
1075+
+ "Please run the following command to update to the latest version of IDEasy and fix the problem:\n"
1076+
+ "ide upgrade", IdeVersion.getVersionIdentifier().toString(), IDE_MIN_VERSION.get(this).toString());
1077+
if (throwException) {
1078+
throw new CliException(message);
1079+
} else {
1080+
warning(message);
1081+
}
1082+
}
1083+
}
1084+
10641085
/**
10651086
* @param arguments the {@link CliArguments#ofCompletion(String...) completion arguments}.
10661087
* @param includeContextOptions to include the options of {@link ContextCommandlet}.

cli/src/main/java/com/devonfw/tools/ide/context/IdeContext.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,4 +725,11 @@ default String findBashRequired() {
725725
*/
726726
void writeVersionFile(VersionIdentifier version, Path installationPath);
727727

728+
/**
729+
* checks if the ide version is at least IDE_MIN_VERSION
730+
*
731+
* @param throwException whether to throw a CliException or just log a warning
732+
*/
733+
void verifyIdeMinVersion(boolean throwException);
734+
728735
}

cli/src/main/java/com/devonfw/tools/ide/variable/IdeVariables.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public interface IdeVariables {
3838

3939
/** {@link VariableDefinition} for minimum IDE product version. */
4040
// TODO define initial IDEasy version as default value
41-
VariableDefinitionVersion IDE_MIN_VERSION = new VariableDefinitionVersion("IDE_MIN_VERSION", "DEVON_IDE_MIN_VERSION");
41+
VariableDefinitionVersion IDE_MIN_VERSION = new VariableDefinitionVersion("IDE_MIN_VERSION");
4242

4343
/** {@link VariableDefinition} for version of maven (mvn). */
4444
VariableDefinitionVersion MVN_VERSION = new VariableDefinitionVersion("MVN_VERSION", "MAVEN_VERSION");
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
#!/bin/bash
2+
#set -e
3+
#set -o pipefail
4+
5+
WORK_DIR_INTEG_TEST="${HOME}/tmp/ideasy-integration-test-debug/IDEasy_snapshot"
6+
IDEASY_COMPRESSED_NAME="ideasy_latest.tar.gz"
7+
IDEASY_COMPRESSED_FILE="${WORK_DIR_INTEG_TEST}/${IDEASY_COMPRESSED_NAME}"
8+
TEST_PROJECT_NAME="tmp-integ-test"
9+
10+
function doIdeCreate () {
11+
#TODO: determine the name of the currently executed script
12+
# If first argument is given, then it is the url for the ide create command (default is '-').
13+
local settings_url=${1:--}
14+
echo "Running ide --batch create ${TEST_PROJECT_NAME} ${settings_url}"
15+
ide --batch -d create "${TEST_PROJECT_NAME}" "${settings_url}"
16+
17+
echo "Switching to directory: ${IDE_ROOT}/${TEST_PROJECT_NAME}"
18+
cd "${IDE_ROOT}/${TEST_PROJECT_NAME}" || exit
19+
}
20+
21+
function doIdeCreateCleanup () {
22+
rm -rf "${IDE_ROOT:?}/${TEST_PROJECT_NAME}"
23+
}
24+
25+
function doDownloadSnapshot () {
26+
mkdir -p "$WORK_DIR_INTEG_TEST"
27+
if [ "$1" != "" ]; then
28+
if [ -f "$1" ] && [[ $1 == *.tar.gz ]]; then
29+
echo "Local snapshot given. Copying to directory: ${WORK_DIR_INTEG_TEST}"
30+
cp "$1" "$IDEASY_COMPRESSED_FILE"
31+
else
32+
echo "Expected a file ending with tar.gz - Given: ${1}"
33+
exit 1
34+
fi
35+
else
36+
local urlIdeasyLatest="https://github.com/devonfw/IDEasy/releases/latest"
37+
echo "Trying to download latest IDEasy release from ${urlIdeasyLatest} ..."
38+
local pageHtmlLocal="${WORK_DIR_INTEG_TEST}/integ_test_gh_latest.html"
39+
40+
curl -L "$urlIdeasyLatest" > "$pageHtmlLocal"
41+
# TODO: A bit of a workaround. But works for the time being...
42+
# Note: Explanation for cryptic argument "\"" of 'cut': delimiting char after url link from href is char '"'
43+
local url
44+
# Change OS type based on github workflow matrix.os name
45+
local osType
46+
if [ "${MATRIX_OS}" == "windows-latest" ]; then
47+
osType="windows-x64"
48+
elif [ "${MATRIX_OS}" == "ubuntu-latest" ]; then
49+
osType="linux-x64"
50+
elif [ "${MATRIX_OS}" == "macos-latest" ]; then
51+
osType="mac-arm64"
52+
elif [ "${MATRIX_OS}" == "macos-13" ]; then
53+
osType="mac-x64"
54+
fi
55+
url=$(grep "href=\"https://.*${osType}.tar.gz" "$pageHtmlLocal" | grep -o "https://.*${osType}.tar.gz" | cut -f1 -d"\"")
56+
echo "Trying to download IDEasy for OS: ${osType} from: ${url} to: ${IDEASY_COMPRESSED_FILE:?} ..."
57+
curl -o "${IDEASY_COMPRESSED_FILE:?}" "$url"
58+
rm "${pageHtmlLocal:?}"
59+
fi
60+
}
61+
62+
63+
function doExtract() {
64+
echo "Extracting IDEasy archive: ${IDEASY_COMPRESSED_FILE} to: ${IDEASY_DIR}"
65+
if [ -f "${IDEASY_COMPRESSED_FILE:?}" ]; then
66+
tar xfz "${IDEASY_COMPRESSED_FILE:?}" --directory "${IDEASY_DIR:?}" || exit 1
67+
else
68+
echo "Could not find and extract release ${IDEASY_COMPRESSED_FILE:?}"
69+
exit 1
70+
fi
71+
}
72+
73+
# $@: success message
74+
function doSuccess() {
75+
echo -e "\033[92m${*}\033[39m"
76+
}
77+
78+
# $@: warning message
79+
function doWarning() {
80+
echo -e "\033[93m${*}\033[39m"
81+
}
82+
83+
# $@: messages to input
84+
function doError() {
85+
echo -e "\033[91m${1}\033[39m"
86+
}
87+
88+
function doIsMacOs() {
89+
if [ "${OSTYPE:0:6}" = "darwin" ]
90+
then
91+
return
92+
fi
93+
return 255
94+
}
95+
96+
function doIsWindows() {
97+
if [ "${OSTYPE}" = "cygwin" ] || [ "${OSTYPE}" = "msys" ]
98+
then
99+
return
100+
fi
101+
return 255
102+
}
103+
104+
# supports assertion types like contains and equals
105+
# TODO: add more assertion types
106+
assertThat() {
107+
local input="$1"
108+
local assertionType="$2"
109+
local expected="$3"
110+
111+
case "$assertionType" in
112+
contains)
113+
if echo "$input" | grep -q -e "$expected"; then
114+
echo "Assertion passed: '$expected' found in input"
115+
return 0
116+
else
117+
echo "Assertion failed: '$expected' not found in input"
118+
return 1
119+
fi
120+
;;
121+
equals)
122+
if [[ "$input" == "$expected" ]]; then
123+
echo "Assertion passed: input equals '$expected'"
124+
return 0
125+
else
126+
echo "Assertion failed: input does not equal '$expected'"
127+
return 1
128+
fi
129+
;;
130+
exists)
131+
if [[ -f "$input" ]]; then
132+
echo "Assertion passed: file '$input' exists"
133+
return 0
134+
else
135+
echo "Assertion failed: file '$input' does not exist"
136+
return 1
137+
fi
138+
;;
139+
*)
140+
echo "Unknown assertion type: '$assertionType'"
141+
return 2
142+
;;
143+
esac
144+
}

0 commit comments

Comments
 (0)