From b59828933b5acbaffd7128194c3371591dff85ec Mon Sep 17 00:00:00 2001 From: Puneet Behl Date: Thu, 17 Nov 2022 22:38:26 +0530 Subject: [PATCH] Use the pre-installed Chrome driver when running on GitHub 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. --- examples/functional-test-app/build.gradle | 9 ++------- .../grails-spring-security-group/build.gradle | 1 + .../build.gradle | 1 + gradle.properties | 2 +- gradle/geb.gradle | 18 ++++++++++++++++-- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/examples/functional-test-app/build.gradle b/examples/functional-test-app/build.gradle index 8638b6992..8c7e6d405 100644 --- a/examples/functional-test-app/build.gradle +++ b/examples/functional-test-app/build.gradle @@ -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" } } @@ -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" @@ -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') diff --git a/examples/misc-functional-test-app/grails-spring-security-group/build.gradle b/examples/misc-functional-test-app/grails-spring-security-group/build.gradle index a81e42d95..7cec60814 100644 --- a/examples/misc-functional-test-app/grails-spring-security-group/build.gradle +++ b/examples/misc-functional-test-app/grails-spring-security-group/build.gradle @@ -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 { diff --git a/examples/misc-functional-test-app/grails-spring-security-hierarchical-roles/build.gradle b/examples/misc-functional-test-app/grails-spring-security-hierarchical-roles/build.gradle index 0a6ec8bdd..32f44277c 100644 --- a/examples/misc-functional-test-app/grails-spring-security-hierarchical-roles/build.gradle +++ b/examples/misc-functional-test-app/grails-spring-security-hierarchical-roles/build.gradle @@ -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 { diff --git a/gradle.properties b/gradle.properties index 136b2f237..f71107646 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/gradle/geb.gradle b/gradle/geb.gradle index 7ebbbf6bd..8d5d23c60 100644 --- a/gradle/geb.gradle +++ b/gradle/geb.gradle @@ -1,3 +1,5 @@ +apply plugin: "com.energizedwork.webdriver-binaries" + dependencies { testCompile("org.grails.plugins:geb") { exclude group: 'org.gebish', module: 'geb-spock' @@ -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" + } }