Skip to content

Commit

Permalink
Move to GitHub actions
Browse files Browse the repository at this point in the history
We now have good coverage across OSes, code coverage checking, better
lint checking, feature combination checking, and msrv/minimal-versions
checks.
  • Loading branch information
jonhoo committed Feb 10, 2022
1 parent 05e6b29 commit 857611f
Show file tree
Hide file tree
Showing 19 changed files with 216 additions and 61 deletions.
15 changes: 15 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
coverage:
range: 90..100 # set a high standard for ourselves
round: down
precision: 2
status:
project:
default:
threshold: 1%
ignore:
- "ci"
- "tests"
# Make less noisy comments
comment:
layout: "files"
require_changes: yes
24 changes: 24 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
on: [push]
name: coverage
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install browsers
run: |
./ci/ubuntu-latest-firefox
./ci/ubuntu-latest-chrome
- name: Install cargo-tarpaulin
uses: actions-rs/install@v0.1
with:
crate: cargo-tarpaulin
version: latest
use-tool-cache: true
- name: Generate code coverage
run: |
cargo tarpaulin --verbose --timeout 120 --out Xml
- name: Upload to codecov.io
uses: codecov/codecov-action@v2
with:
fail_ci_if_error: true
22 changes: 22 additions & 0 deletions .github/workflows/features.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
on: [push]
name: cargo hack
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- uses: actions/checkout@v2
- name: Install cargo-hack
uses: actions-rs/install@v0.1
with:
crate: cargo-hack
version: latest
use-tool-cache: true
- name: cargo hack
uses: actions-rs/cargo@v1
with:
command: hack
args: --feature-powerset --exclude-features bench_private check
29 changes: 29 additions & 0 deletions .github/workflows/minimal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
on: [push]
name: With dependencies at minimal versions
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- uses: actions/checkout@v2
- name: Install browsers
run: |
./ci/ubuntu-latest-firefox
./ci/ubuntu-latest-chrome
- name: cargo update -Zminimal-versions
uses: actions-rs/cargo@v1
with:
command: update
toolchain: nightly
args: -Zminimal-versions
- name: cargo test
uses: actions-rs/cargo@v1
with:
command: test
16 changes: 16 additions & 0 deletions .github/workflows/msrv.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
on: [push]
name: Minimum Supported Rust Version
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.53.0 # or patterns
override: true
- uses: actions/checkout@v2
- name: cargo +1.52.0 check
uses: actions-rs/cargo@v1
with:
command: check
33 changes: 33 additions & 0 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
on: [push]
name: lint
jobs:
style:
runs-on: ubuntu-latest
name: ${{ matrix.toolchain }}
strategy:
fail-fast: false
matrix:
toolchain: [stable, beta]
steps:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.toolchain }}
components: rustfmt, clippy
- uses: actions/checkout@v2
- name: cargo fmt --check
uses: actions-rs/cargo@v1
with:
command: fmt
args: --check
- name: cargo doc
uses: actions-rs/cargo@v1
if: always()
with:
command: doc
args: --no-deps --all-features
- name: cargo clippy
uses: actions-rs/clippy-check@v1
if: always()
with:
token: ${{ secrets.GITHUB_TOKEN }}
33 changes: 33 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
on: [push]
name: cargo test
jobs:
test:
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} / ${{ matrix.browser }} (${{ matrix.toolchain }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
browser: [firefox, chrome]
toolchain: [stable]
include:
- os: ubuntu-latest
browser: chrome
toolchain: beta
- os: ubuntu-latest
browser: chrome
toolchain: nightly
steps:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.toolchain }}
- uses: actions/checkout@v2
- name: Install ${{ matrix.browser }}
run: |
./ci/${{ matrix.os }}-${{ matrix.browser }}
- name: cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: ${{ matrix.browser }}
32 changes: 0 additions & 32 deletions .travis.yml

This file was deleted.

8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ rustls-tls = ["hyper-rustls"]
[dependencies]
webdriver = { version = "0.44", default-features = false }
url = "2.2.2"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde = { version = "1.0.103", features = ["derive"] }
serde_json = "1.0.25"
futures-core = "0.3"
futures-util = "0.3"
tokio = { version = "1", features = ["sync", "rt"] }
Expand All @@ -39,6 +39,10 @@ mime = "0.3.9"
http = "0.2"
time = "0.3"

# to make -Zminimal-versions happy
# remove gcc and winapi 0.0.1 from build tree
_time01 = { version = "0.1.34", package = "time" }

[dev-dependencies]
tokio = { version = "1", features = ["full"] }
hyper = { version = "0.14", features = ["server", "tcp"] }
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

[![Crates.io](https://img.shields.io/crates/v/fantoccini.svg)](https://crates.io/crates/fantoccini)
[![Documentation](https://docs.rs/fantoccini/badge.svg)](https://docs.rs/fantoccini/)
[![Build Status](https://travis-ci.com/jonhoo/fantoccini.svg?branch=master)](https://travis-ci.com/jonhoo/fantoccini)
[![cargo test](https://github.com/jonhoo/fantoccini/actions/workflows/test.yml/badge.svg)](https://github.com/jonhoo/fantoccini/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/jonhoo/fantoccini/branch/master/graph/badge.svg?token=NteBJ0F7Ok)](https://codecov.io/gh/jonhoo/fantoccini)
[![Gitter chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/fantoccini-rs/Lobby)

A high-level API for programmatically interacting with web pages through WebDriver.
Expand Down
17 changes: 0 additions & 17 deletions README.tpl

This file was deleted.

4 changes: 4 additions & 0 deletions ci/macos-latest-chrome
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
brew install --cask google-chrome
brew install --cask chromedriver
chromedriver &
4 changes: 4 additions & 0 deletions ci/macos-latest-firefox
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
brew install --cask firefox
brew install geckodriver
geckodriver &
4 changes: 4 additions & 0 deletions ci/ubuntu-latest-chrome
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
sudo apt-get update
sudo apt-get install chromium-chromedriver
chromedriver &
4 changes: 4 additions & 0 deletions ci/ubuntu-latest-firefox
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
sudo apt-get update
sudo apt-get install firefox-geckodriver
geckodriver &
3 changes: 3 additions & 0 deletions ci/windows-latest-chrome.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
choco install googlechrome
choco install chromedriver
Start-Process -FilePath chromedriver
4 changes: 4 additions & 0 deletions ci/windows-latest-firefox.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
choco install firefox
Invoke-WebRequest -Uri "https://github.com/mozilla/geckodriver/releases/download/v0.30.0/geckodriver-v0.30.0-win64.zip" -OutFile geckodriver.zip
Expand-Archive -LiteralPath geckodriver.zip -DestinationPath .
Start-Process -FilePath geckodriver
8 changes: 2 additions & 6 deletions src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,17 +317,13 @@ where
Err(error::NewSessionError::NotW3C(Json::String(v)))
}
Err(error::CmdError::Standard(
e
@
error::WebDriver {
e @ error::WebDriver {
error: ErrorStatus::SessionNotCreated,
..
},
)) => Err(error::NewSessionError::SessionNotCreated(e)),
Err(error::CmdError::Standard(
e
@
error::WebDriver {
e @ error::WebDriver {
error: ErrorStatus::UnknownError,
..
},
Expand Down
14 changes: 11 additions & 3 deletions tests/elements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ async fn element_tag_name(mut c: Client, port: u16) -> Result<(), error::CmdErro
c.goto(&sample_url).await?;
let mut elem = c.find(Locator::Id("checkbox-option-1")).await?;
let tag_name = elem.tag_name().await?;
assert!(tag_name.eq_ignore_ascii_case("input"), "{} != input", tag_name);
assert!(
tag_name.eq_ignore_ascii_case("input"),
"{} != input",
tag_name
);
Ok(())
}

Expand Down Expand Up @@ -95,9 +99,13 @@ async fn element_send_keys(mut c: Client, port: u16) -> Result<(), error::CmdErr
assert_eq!(elem.prop("value").await?.unwrap(), "");
elem.send_keys("fantoccini").await?;
assert_eq!(elem.prop("value").await?.unwrap(), "fantoccini");
let ctrl_a = Key::Control + "a";
let select_all = if cfg!(target_os = "macos") {
Key::Command + "a"
} else {
Key::Control + "a"
};
let backspace = Key::Backspace.to_string();
elem.send_keys(&ctrl_a).await?;
elem.send_keys(&select_all).await?;
elem.send_keys(&backspace).await?;
assert_eq!(elem.prop("value").await?.unwrap(), "");

Expand Down

0 comments on commit 857611f

Please sign in to comment.