Skip to content

Commit

Permalink
Use the pre-installed Chrome driver when running on GitHub
Browse files Browse the repository at this point in the history
The GitHub virtual environment already provides a Chrome and a matching Chrome driver.

For installed software see:
https://github.com/actions/virtual-environments/blob/ubuntu20/20220207.1/images/linux/Ubuntu2004-Readme.md#environment-variables-1

For available environment variables see:
https://docs.github.com/en/actions/learn-github-actions/environment-variables

Thanks to @darxriggs for suggesting the same in grails/grails-cache#123 plugin.
  • Loading branch information
puneetbehl committed Nov 17, 2022
1 parent cf87f21 commit b598289
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
9 changes: 2 additions & 7 deletions examples/functional-test-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ buildscript {
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath "org.grails.plugins:hibernate5:${gormVersion-".RELEASE"}"
classpath "gradle.plugin.com.energizedwork.webdriver-binaries:webdriver-binaries-gradle-plugin:$webdriverBinariesVersion"
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:$assetPipelineVersion"
classpath "gradle.plugin.com.energizedwork.webdriver-binaries:webdriver-binaries-gradle-plugin:$webdriverBinariesVersion"
}
}

Expand All @@ -18,7 +18,6 @@ apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin:"org.grails.grails-web"
apply plugin:"com.energizedwork.webdriver-binaries"
apply plugin:"asset-pipeline"
apply plugin:"org.grails.grails-gsp"

Expand Down Expand Up @@ -69,13 +68,9 @@ dependencies {
compile project(':spring-security-core')
}

webdriverBinaries {
chromedriver '77.0.3865.40'
geckodriver '0.23.0'
}

apply from: "${rootProject.projectDir}/gradle/integrationTest.gradle"
apply from: "${rootProject.projectDir}/gradle/testVerbose.gradle"
apply from: "${rootProject.projectDir}/gradle/geb.gradle"

bootRun {
jvmArgs('-Dspring.output.ansi.enabled=always')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ dependencies {
}

apply from: "${rootProject.projectDir}/gradle/ssc.gradle"
apply from: "${rootProject.projectDir}/gradle/geb.gradle"
apply from: "${rootProject.projectDir}/gradle/testVerbose.gradle"

bootRun {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ dependencies {
compile project(':spring-security-core')
}

apply from: "${rootProject.projectDir}/gradle/geb.gradle"
apply from: "${rootProject.projectDir}/gradle/testVerbose.gradle"

bootRun {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ assetPipelineVersion=2.14.2
gebVersion=2.2
seleniumVersion=3.12.0
webdriverBinariesVersion=1.4
chromeDriverVersion=77.0.3865.40
chromeDriverVersion=107.0.5304.62
geckodriverVersion=0.23.0
seleniumSafariDriverVersion=3.14.0
micronautVersion=1.0.1
Expand Down
18 changes: 16 additions & 2 deletions gradle/geb.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
apply plugin: "com.energizedwork.webdriver-binaries"

dependencies {
testCompile("org.grails.plugins:geb") {
exclude group: 'org.gebish', module: 'geb-spock'
Expand All @@ -16,9 +18,21 @@ dependencies {
tasks.withType(Test) {
systemProperty "geb.env", System.getProperty('geb.env')
systemProperty "geb.build.reportsDir", reporting.file("geb/integrationTest")
if (!System.getenv().containsKey('CI')) {
systemProperty 'webdriver.chrome.driver', System.getProperty('webdriver.chrome.driver')
systemProperty 'webdriver.gecko.driver', System.getProperty('webdriver.gecko.driver')
} else {
systemProperty 'webdriver.chrome.driver', "${System.getenv('CHROMEWEBDRIVER')}/chromedriver"
systemProperty 'webdriver.gecko.driver', "${System.getenv('GECKOWEBDRIVER')}/geckodriver"
}
}

webdriverBinaries {
chromedriver "$chromeDriverVersion"
geckodriver "$geckodriverVersion"
if (!System.getenv().containsKey('CI')) {
chromedriver System.getProperty('webdriver.chrome.driver') ?: "${chromeDriverVersion}"
geckodriver System.getProperty('webdriver.gecko.driver') ?: "${geckodriverVersion}"
} else {
chromedriver "${System.getenv('CHROMEWEBDRIVER')}/chromedriver"
geckodriver "${System.getenv('GECKOWEBDRIVER')}/geckodriver"
}
}

0 comments on commit b598289

Please sign in to comment.