Skip to content

Commit 9f35ae8

Browse files
authored
Upgrade 212 profile to stable SDKs (#2746)
* Fix go tests by making the image version configurable
1 parent 2ae561e commit 9f35ae8

File tree

7 files changed

+38
-40
lines changed

7 files changed

+38
-40
lines changed

buildSrc/src/main/kotlin/software/aws/toolkits/gradle/intellij/IdeVersions.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,37 +125,37 @@ object IdeVersions {
125125
name = "2021.2",
126126
community = ProductProfile(
127127
sdkFlavor = IdeFlavor.IC,
128-
sdkVersion = "212.4638.7-EAP-SNAPSHOT",
128+
sdkVersion = "2021.2",
129129
plugins = commonPlugins + listOf(
130130
"java",
131131
"com.intellij.gradle",
132132
"org.jetbrains.idea.maven",
133-
"PythonCore:212.4638.10",
134-
"Docker:212.4638.7"
133+
"PythonCore:212.4746.96",
134+
"Docker:212.4746.92"
135135
)
136136
),
137137
ultimate = ProductProfile(
138138
sdkFlavor = IdeFlavor.IU,
139-
sdkVersion = "212.4638.7-EAP-SNAPSHOT",
139+
sdkVersion = "2021.2",
140140
plugins = commonPlugins + listOf(
141141
"JavaScript",
142142
// Transitive dependency needed for javascript
143143
// Can remove when https://github.com/JetBrains/gradle-intellij-plugin/issues/608 is fixed
144144
"com.intellij.css",
145145
"JavaScriptDebugger",
146146
"com.intellij.database",
147-
"Pythonid:212.4638.7",
148-
"org.jetbrains.plugins.go:212.4638.7"
147+
"Pythonid:212.4746.96",
148+
"org.jetbrains.plugins.go:212.4746.92"
149149
)
150150
),
151151
rider = RiderProfile(
152-
sdkVersion = "2021.2-SNAPSHOT",
152+
sdkVersion = "2021.2",
153153
plugins = commonPlugins + listOf(
154154
"rider-plugins-appender" // Workaround for https://youtrack.jetbrains.com/issue/IDEA-179607
155155
),
156156
netFrameworkTarget = "net472",
157157
rdGenVersion = "0.212.315",
158-
nugetVersion = "2021.2.0-eap05"
158+
nugetVersion = "2021.2.0"
159159
)
160160
),
161161
).associateBy { it.name }

jetbrains-core/tst/software/aws/toolkits/jetbrains/utils/RunConfigTestUtils.kt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,23 @@ fun checkBreakPointHit(project: Project, callback: () -> Unit = {}): Ref<Boolean
162162
return debuggerIsHit
163163
}
164164

165-
fun readProject(relativePath: String, sourceFileName: String, projectRule: CodeInsightTestFixtureRule): Pair<VirtualFile, VirtualFile> {
165+
fun readProject(
166+
relativePath: String,
167+
sourceFileName: String,
168+
projectRule: CodeInsightTestFixtureRule,
169+
templatePatches: Map<String, String> = emptyMap()
170+
): Pair<VirtualFile, VirtualFile> {
166171
val testDataPath = Paths.get(System.getProperty("testDataPath"), relativePath).toFile()
167172
val (source, template) = testDataPath.walk().fold<File, Pair<VirtualFile?, VirtualFile?>>(Pair(null, null)) { acc, file ->
168173
// skip directories which are part of the walk
169174
if (!file.isFile) {
170175
return@fold acc
171176
}
172-
val virtualFile = projectRule.fixture.addFileToModule(projectRule.module, file.relativeTo(testDataPath).path, file.readText()).virtualFile
177+
178+
var fileText = file.readText()
179+
templatePatches.forEach { (search, replace) -> fileText = fileText.replace(search, replace) }
180+
181+
val virtualFile = projectRule.fixture.addFileToModule(projectRule.module, file.relativeTo(testDataPath).path, fileText).virtualFile
173182
when (virtualFile.name) {
174183
"template.yaml" -> {
175184
acc.first to virtualFile
@@ -197,6 +206,7 @@ fun readProject(relativePath: String, sourceFileName: String, projectRule: CodeI
197206
fun samImageRunDebugTest(
198207
projectRule: CodeInsightTestFixtureRule,
199208
relativePath: String,
209+
templatePatches: Map<String, String> = emptyMap(),
200210
sourceFileName: String,
201211
runtime: LambdaRuntime,
202212
mockCredentialsId: String,
@@ -205,7 +215,7 @@ fun samImageRunDebugTest(
205215
addBreakpoint: (() -> Unit)? = null
206216
) {
207217
assumeImageSupport()
208-
val (_, template) = readProject(relativePath, sourceFileName, projectRule)
218+
val (_, template) = readProject(relativePath, sourceFileName, projectRule, templatePatches)
209219

210220
addBreakpoint?.let { it() }
211221

jetbrains-ultimate/it/software/aws/toolkits/jetbrains/services/lambda/go/GoLocalRunConfigurationIntegrationTest.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import software.aws.toolkits.jetbrains.utils.checkBreakPointHit
3737
import software.aws.toolkits.jetbrains.utils.executeRunConfigurationAndWait
3838
import software.aws.toolkits.jetbrains.utils.rules.HeavyGoCodeInsightTestFixtureRule
3939
import software.aws.toolkits.jetbrains.utils.rules.addGoModFile
40+
import software.aws.toolkits.jetbrains.utils.rules.compatibleGoForIde
4041
import software.aws.toolkits.jetbrains.utils.rules.ensureCorrectGoVersion
4142
import software.aws.toolkits.jetbrains.utils.rules.runGoModTidy
4243
import software.aws.toolkits.jetbrains.utils.samImageRunDebugTest
@@ -272,6 +273,7 @@ class GoLocalRunConfigurationIntegrationTest(private val runtime: LambdaRuntime)
272273
fun samIsExecutedImage(): Unit = samImageRunDebugTest(
273274
projectRule = projectRule,
274275
relativePath = "samProjects/image/$runtime",
276+
templatePatches = mapOf("[GoVersion]" to (compatibleGoForIde() ?: "1")),
275277
sourceFileName = "main.go",
276278
runtime = runtime,
277279
mockCredentialsId = mockId,
@@ -284,6 +286,7 @@ class GoLocalRunConfigurationIntegrationTest(private val runtime: LambdaRuntime)
284286
samImageRunDebugTest(
285287
projectRule = projectRule,
286288
relativePath = "samProjects/image/$runtime",
289+
templatePatches = mapOf("[GoVersion]" to (compatibleGoForIde() ?: "1")),
287290
sourceFileName = "main.go",
288291
runtime = runtime,
289292
mockCredentialsId = mockId,

jetbrains-ultimate/tst/software/aws/toolkits/jetbrains/utils/rules/GoCodeInsightTestFixtureRule.kt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,23 @@ fun runGoModTidy(goModFile: VirtualFile) {
100100
}
101101
}
102102

103+
fun compatibleGoForIde() = when (ApplicationInfo.getInstance().build.baselineVersion) {
104+
202 -> "1.14.15" // TODO: FIX_WHEN_MIN_IS_202
105+
203 -> "1.15.14" // TODO: FIX_WHEN_MIN_IS_203
106+
else -> null
107+
}
108+
103109
fun CodeInsightTestFixture.ensureCorrectGoVersion(disposable: Disposable) {
104-
val versionCmd = GeneralCommandLine("goenv").withParameters("--version")
105-
if (ExecUtil.execAndGetOutput(versionCmd).exitCode != 0) {
110+
val versionCmd = GeneralCommandLine("goenv").withParameters("version")
111+
val output = ExecUtil.execAndGetOutput(versionCmd)
112+
if (output.exitCode != 0) {
106113
println("WARNING: goenv not found, can't switch Go SDK!!!!")
107114
return
115+
} else {
116+
println("Current Go version: ${output.stdout}")
108117
}
109118

110-
val goVersionOverride = when (ApplicationInfo.getInstance().build.baselineVersion) {
111-
202 -> "1.14.15" // TODO: FIX_WHEN_MIN_IS_202
112-
203 -> "1.15.14" // TODO: FIX_WHEN_MIN_IS_203
113-
else -> null
114-
}
115-
119+
val goVersionOverride = compatibleGoForIde()
116120
goVersionOverride?.let {
117121
val overrideLocation = this.tempDirPath
118122

testdata/samProjects/image/go1.x/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
FROM golang:1.14 as build-image
1+
FROM golang:[GoVersion] as build-image
22

33
ENV GOPROXY direct
44

55
WORKDIR /go/src
66
COPY go.mod main.go ./
77

8+
RUN go mod tidy
89
RUN go build -o ../bin
910

1011
FROM public.ecr.aws/lambda/go:1
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
require github.com/aws/aws-lambda-go v1.13.3
22

33
module hello-world
4-
5-
go 1.16

testdata/samProjects/image/go1.x/go.sum

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)