diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cde7fb94..4015e3ab 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,6 +24,8 @@ jobs: node-version: 16 - name: Install yarn run: npm install -g yarn@1.22.17 + - name: Install pnpm + run: npm install -g pnpm@4.12.1 - name: Setup Gradle uses: gradle/gradle-build-action@v2 with: diff --git a/src/test/groovy/com/github/gradle/node/Versions.groovy b/src/test/groovy/com/github/gradle/node/Versions.groovy new file mode 100644 index 00000000..0efa9563 --- /dev/null +++ b/src/test/groovy/com/github/gradle/node/Versions.groovy @@ -0,0 +1,6 @@ +package com.github.gradle.node + +class Versions { + static TEST_PNPM_DOWNLOAD_VERSION = "4.12.4" + static TEST_PNPM_LOCAL_VERSION = "4.12.1" +} diff --git a/src/test/groovy/com/github/gradle/node/pnpm/task/PnpmRule_integTest.groovy b/src/test/groovy/com/github/gradle/node/pnpm/task/PnpmRule_integTest.groovy index 0e398d65..b23bff1f 100644 --- a/src/test/groovy/com/github/gradle/node/pnpm/task/PnpmRule_integTest.groovy +++ b/src/test/groovy/com/github/gradle/node/pnpm/task/PnpmRule_integTest.groovy @@ -1,6 +1,7 @@ package com.github.gradle.node.pnpm.task import com.github.gradle.AbstractIntegTest +import com.github.gradle.node.Versions import org.gradle.testkit.runner.TaskOutcome import java.util.regex.Pattern @@ -32,19 +33,19 @@ class PnpmRule_integTest extends AbstractIntegTest { gv << GRADLE_VERSIONS_UNDER_TEST } - def 'Use downloaded pnpm version (#gv.version)'() + def 'DEUse downloaded pnpm version (#gv.version)'() { given: gradleVersion = gv - writeBuild( ''' + writeBuild( """ plugins { id 'com.github.node-gradle.node' } node { download = true - pnpmVersion = '4.12.4' + pnpmVersion = '${Versions.TEST_PNPM_DOWNLOAD_VERSION}' } - ''' ) + """ ) writeEmptyPackageJson() when: @@ -62,18 +63,18 @@ class PnpmRule_integTest extends AbstractIntegTest { { given: gradleVersion = gv - writeBuild( ''' + writeBuild( """ plugins { id 'com.github.node-gradle.node' } node { download = true } - ''' ) + """ ) writeEmptyPackageJson() when: - build( 'pnpm_install_pnpm@4.12.1' ) + build( "pnpm_install_pnpm@${Versions.TEST_PNPM_LOCAL_VERSION}" ) def result = build( 'pnpm_--version' ) then: @@ -133,7 +134,7 @@ class PnpmRule_integTest extends AbstractIntegTest { then: result.task(":pnpmInstall").outcome == TaskOutcome.SUCCESS result.task(":pnpm_run_pnpmVersion").outcome == TaskOutcome.SUCCESS - def versionPattern = Pattern.compile(".*Version\\s+4.12.1.*", Pattern.DOTALL) + def versionPattern = Pattern.compile(".*Version\\s+${Versions.TEST_PNPM_LOCAL_VERSION}.*", Pattern.DOTALL) versionPattern.matcher(result.output).find() where: @@ -181,16 +182,16 @@ class PnpmRule_integTest extends AbstractIntegTest { { given: gradleVersion = gv - writeBuild( ''' + writeBuild( """ plugins { id 'com.github.node-gradle.node' } node { download = true - pnpmVersion = '4.12.4' + pnpmVersion = '${Versions.TEST_PNPM_DOWNLOAD_VERSION}' nodeModulesDir = file("frontend") } - ''' ) + """ ) writeFile( 'frontend/package.json', """{ "name": "example", "dependencies": {}, diff --git a/src/test/groovy/com/github/gradle/node/pnpm/task/PnpmSetupTaskTest.groovy b/src/test/groovy/com/github/gradle/node/pnpm/task/PnpmSetupTaskTest.groovy index 8f38c1f0..667f3cdc 100644 --- a/src/test/groovy/com/github/gradle/node/pnpm/task/PnpmSetupTaskTest.groovy +++ b/src/test/groovy/com/github/gradle/node/pnpm/task/PnpmSetupTaskTest.groovy @@ -1,5 +1,6 @@ package com.github.gradle.node.pnpm.task +import com.github.gradle.node.Versions import com.github.gradle.node.task.AbstractTaskTest import org.gradle.process.ExecSpec @@ -27,7 +28,7 @@ class PnpmSetupTaskTest def "exec pnpmSetup task with pnpm version specified"() { given: - nodeExtension.pnpmVersion.set('4.12.4') + nodeExtension.pnpmVersion.set(Versions.TEST_PNPM_DOWNLOAD_VERSION) def task = project.tasks.create('simple', PnpmSetupTask) mockProjectApiHelperExec(task) @@ -38,8 +39,8 @@ class PnpmSetupTaskTest then: 1 * execSpec.setArgs({ args -> def expectedPnpmInstallPath = projectDir.toPath().resolve('.gradle').resolve('pnpm') - .resolve('pnpm-v4.12.4').toAbsolutePath().toString() - def expectedArgs = ['install', '--global', '--no-save', '--prefix', expectedPnpmInstallPath, 'pnpm@4.12.4'] + .resolve("pnpm-v${Versions.TEST_PNPM_DOWNLOAD_VERSION}").toAbsolutePath().toString() + def expectedArgs = ['install', '--global', '--no-save', '--prefix', expectedPnpmInstallPath, "pnpm@${Versions.TEST_PNPM_DOWNLOAD_VERSION}"] // Workaround a strange issue on Github actions macOS hosts return args.collect { it.replace("^/private/", "/") } == expectedArgs }) diff --git a/src/test/groovy/com/github/gradle/node/pnpm/task/PnpmTask_integTest.groovy b/src/test/groovy/com/github/gradle/node/pnpm/task/PnpmTask_integTest.groovy index d4972861..288da210 100644 --- a/src/test/groovy/com/github/gradle/node/pnpm/task/PnpmTask_integTest.groovy +++ b/src/test/groovy/com/github/gradle/node/pnpm/task/PnpmTask_integTest.groovy @@ -1,6 +1,7 @@ package com.github.gradle.node.pnpm.task import com.github.gradle.AbstractIntegTest +import com.github.gradle.node.Versions import org.gradle.testkit.runner.TaskOutcome import org.junit.Rule import org.junit.contrib.java.lang.system.EnvironmentVariables @@ -48,7 +49,7 @@ class PnpmTask_integTest extends AbstractIntegTest { then: result4.task(":version").outcome == TaskOutcome.SUCCESS - result4.output.contains("> Task :version${System.lineSeparator()}4.12.4") + result4.output.contains("> Task :version${System.lineSeparator()}${Versions.TEST_PNPM_DOWNLOAD_VERSION}") where: gv << GRADLE_VERSIONS_UNDER_TEST @@ -146,7 +147,7 @@ class PnpmTask_integTest extends AbstractIntegTest { then: result9.task(":version").outcome == TaskOutcome.SUCCESS - result9.output.contains("> Task :version${System.lineSeparator()}4.12.4") + result9.output.contains("> Task :version${System.lineSeparator()}${Versions.TEST_PNPM_DOWNLOAD_VERSION}") where: gv << GRADLE_VERSIONS_UNDER_TEST @@ -163,7 +164,7 @@ class PnpmTask_integTest extends AbstractIntegTest { then: result.task(":version").outcome == TaskOutcome.SUCCESS - result.output.contains("> Task :version${System.lineSeparator()}4.12.1") + result.output.contains("> Task :version${System.lineSeparator()}${Versions.TEST_PNPM_LOCAL_VERSION}") where: gv << GRADLE_VERSIONS_UNDER_TEST