From 5568553d28f0ca7bf7da480b066cc2f001fe9598 Mon Sep 17 00:00:00 2001 From: Jeremy Woertink Date: Sat, 1 Jul 2023 10:26:09 -0700 Subject: [PATCH] Updating the workflow to include Windows. (#156) * Updating the workflow to include Windows. Fixing Linting issues, and updating shards * Fixing how env is setup so it works on Windows --- .github/workflows/ci.yml | 57 +++++++++++++++++------- shard.yml | 14 +++--- spec/lucky_flow_spec.cr | 6 +-- src/lucky_flow.cr | 2 +- src/lucky_flow/driver.cr | 2 +- src/lucky_flow/element.cr | 2 +- src/lucky_flow/selenium/chrome/driver.cr | 2 +- src/lucky_flow/webless/element.cr | 2 +- 8 files changed, 57 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 61b671a..5a030ab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,33 +10,60 @@ jobs: check_format: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: crystal-lang/install-crystal@v1 with: - crystal: 1.4.1 + crystal: latest - run: shards install - run: crystal tool format --check - run: ./bin/ameba webless_specs: strategy: + fail-fast: false matrix: - crystal_version: - - 1.4.0 - - latest - - nightly - runs-on: ubuntu-latest + include: + - os: ubuntu-latest + crystal: latest + - os: windows-latest + crystal: latest + - os: macos-latest + crystal: latest + runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + - uses: browser-actions/setup-chrome@v1 + with: + chrome-version: stable + if: matrix.os == 'windows-latest' - uses: crystal-lang/install-crystal@v1 with: crystal: ${{matrix.crystal_version}} - - run: shards install - - run: LUCKYFLOW_DRIVER=webless crystal spec --tag ~headless_chrome + - run: shards install --ignore-crystal-version --skip-executables --skip-postinstall + - run: crystal spec --tag ~headless_chrome + env: + LUCKYFLOW_DRIVER: webless selenium_specs: - runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + crystal: latest + - os: windows-latest + crystal: latest + - os: macos-latest + crystal: latest + runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + - uses: browser-actions/setup-chrome@v1 + with: + chrome-version: stable + if: matrix.os == 'windows-latest' - uses: crystal-lang/install-crystal@v1 - - run: shards install - - run: LUCKYFLOW_DRIVER=headless_chrome crystal spec --tag ~webless - + with: + crystal: ${{matrix.crystal_version}} + - run: shards install --ignore-crystal-version --skip-executables --skip-postinstall + - run: crystal spec --tag ~webless + env: + LUCKYFLOW_DRIVER: headless_chrome diff --git a/shard.yml b/shard.yml index 05db093..b0a4091 100644 --- a/shard.yml +++ b/shard.yml @@ -10,21 +10,21 @@ license: MIT dependencies: selenium: - github: matthewmcgarvey/selenium.cr - version: ~> 0.10.0 + github: crystal-loot/selenium.cr + version: ~> 0.12.0 webdrivers: - github: matthewmcgarvey/webdrivers.cr - version: ~> 0.4.1 + github: crystal-loot/webdrivers.cr + version: ~> 0.4.2 habitat: github: luckyframework/habitat version: ~> 0.4.7 webless: - github: matthewmcgarvey/webless + github: crystal-loot/webless version: ~> 0.1.0 html5: github: naqvis/crystal-html5 - version: ~> 0.4.0 + version: ~> 0.5.0 development_dependencies: ameba: github: crystal-ameba/ameba - version: ~> 1.1.0 + version: ~> 1.4.3 diff --git a/spec/lucky_flow_spec.cr b/spec/lucky_flow_spec.cr index 3d3a112..4e92afc 100644 --- a/spec/lucky_flow_spec.cr +++ b/spec/lucky_flow_spec.cr @@ -129,7 +129,7 @@ describe LuckyFlow do it "can submit form" do handle_route("/foo") do |context| <<-HTML -

#{context.request.body.not_nil!.gets_to_end}

+

#{context.request.body.as(IO).gets_to_end}

HTML end @@ -170,7 +170,7 @@ describe LuckyFlow do it "submits dates appropriately", tags: "headless_chrome" do handle_route("/foo") do |context| <<-HTML -

#{context.request.body.not_nil!.gets_to_end}

+

#{context.request.body.as(IO).gets_to_end}

HTML end @@ -444,7 +444,7 @@ private class FakeProcess end end -private def expect_to_raise_without_suggestion +private def expect_to_raise_without_suggestion(&) error = expect_raises LuckyFlow::ElementNotFoundError do yield end diff --git a/src/lucky_flow.cr b/src/lucky_flow.cr index 33c7447..c3cc8bd 100644 --- a/src/lucky_flow.cr +++ b/src/lucky_flow.cr @@ -71,7 +71,7 @@ class LuckyFlow driver.maximize_window end - def with_fullsized_page(&block) + def with_fullsized_page(&) original_size = driver.window_size expand_page_to_fullsize yield diff --git a/src/lucky_flow/driver.cr b/src/lucky_flow/driver.cr index 053cd16..f7e550b 100644 --- a/src/lucky_flow/driver.cr +++ b/src/lucky_flow/driver.cr @@ -19,6 +19,6 @@ abstract class LuckyFlow::Driver macro unsupported method_name = \{{ @def.name.stringify }} - raise NotSupportedByDriverError.new("#{self.class}##{ method_name }") + raise NotSupportedByDriverError.new("#{self.class}##{method_name}") end end diff --git a/src/lucky_flow/element.cr b/src/lucky_flow/element.cr index 6567ba1..d6c9c7d 100644 --- a/src/lucky_flow/element.cr +++ b/src/lucky_flow/element.cr @@ -73,6 +73,6 @@ abstract class LuckyFlow::Element macro unsupported method_name = \{{ @def.name.stringify }} - raise NotSupportedByElementError.new("#{self.class}##{ method_name }") + raise NotSupportedByElementError.new("#{self.class}##{method_name}") end end diff --git a/src/lucky_flow/selenium/chrome/driver.cr b/src/lucky_flow/selenium/chrome/driver.cr index 8bffda7..6cae6e8 100644 --- a/src/lucky_flow/selenium/chrome/driver.cr +++ b/src/lucky_flow/selenium/chrome/driver.cr @@ -5,7 +5,7 @@ module LuckyFlow::Selenium ::Selenium::Driver.for(:chrome, service: service) end - def initialize(&block) + def initialize(&) super ::Selenium::Chrome::Capabilities.new yield @capabilities.as(::Selenium::Chrome::Capabilities) end diff --git a/src/lucky_flow/webless/element.cr b/src/lucky_flow/webless/element.cr index f7a6aac..b43f27d 100644 --- a/src/lucky_flow/webless/element.cr +++ b/src/lucky_flow/webless/element.cr @@ -29,7 +29,7 @@ class LuckyFlow::Webless::Element < LuckyFlow::Element def click if link? method = attribute("data-method") || "get" - driver.as(LuckyFlow::Webless::Driver).follow(method, attribute("href").not_nil!) + driver.as(LuckyFlow::Webless::Driver).follow(method, attribute("href").to_s) elsif submits? && (f = form) LuckyFlow::Webless::Form.new(f, @inner_element).submit(driver.as(LuckyFlow::Webless::Driver)) elsif checkable?