Skip to content

Commit

Permalink
Pin the pnpm versions on GitHub and in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
deepy committed Apr 18, 2023
1 parent b18c04c commit a8fe98e
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions src/test/groovy/com/github/gradle/node/Versions.groovy
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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)

Expand All @@ -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
})
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit a8fe98e

Please sign in to comment.