This repository has been archived by the owner on Jun 16, 2020. It is now read-only.
forked from nanasess/setup-chromedriver
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,342 additions
and
950 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,113 +1,26 @@ | ||
# Create a JavaScript Action using TypeScript | ||
# setup-chromedriver | ||
|
||
Use this template to bootstrap the creation of a JavaScript action.:rocket: | ||
<p align="left"> | ||
<a href="https://github.com/nanasess/setup-chromedriver"><img alt="GitHub Actions status" src="https://github.com/nanasess/setup-chromedriver/workflows/Main%20workflow/badge.svg"></a> | ||
<a href="https://github.com/nanasess/setup-chromedriver/blob/master/LICENSE"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg"></a> | ||
</p> | ||
|
||
This template includes compilication support, tests, a validation workflow, publishing, and versioning guidance. | ||
This action sets up a [ChromeDriver](https://chromedriver.chromium.org/) for use in actions | ||
|
||
If you are new, there's also a simpler introduction. See the [Hello World JavaScript Action](https://github.com/actions/hello-world-javascript-action) | ||
# Usage | ||
|
||
## Create an action from this template | ||
See [action.yml](action.yml) | ||
|
||
Click the `Use this Template` and provide the new repo details for your action | ||
``` yaml | ||
steps: | ||
- uses: actions/checkout@master | ||
- uses: nanasess/setup-chromedriver@master | ||
with: | ||
chromedriver-version: '77.0.3865.40' | ||
- run: | | ||
export DISPLAY=:99 | ||
chromedriver --url-base=/wd/hub & | ||
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & # optional | ||
``` | ||
## Code in Master | ||
Install the dependencies | ||
```bash | ||
$ npm install | ||
``` | ||
|
||
Build the typescript | ||
```bash | ||
$ npm run build | ||
``` | ||
|
||
Run the tests :heavy_check_mark: | ||
```bash | ||
$ npm test | ||
|
||
PASS ./index.test.js | ||
✓ throws invalid number (3ms) | ||
✓ wait 500 ms (504ms) | ||
✓ test runs (95ms) | ||
|
||
... | ||
``` | ||
|
||
## Change action.yml | ||
|
||
The action.yml contains defines the inputs and output for your action. | ||
|
||
Update the action.yml with your name, description, inputs and outputs for your action. | ||
|
||
See the [documentation](https://help.github.com/en/articles/metadata-syntax-for-github-actions) | ||
|
||
## Change the Code | ||
|
||
Most toolkit and CI/CD operations involve async operations so the action is run in an async function. | ||
|
||
```javascript | ||
import * as core from '@actions/core'; | ||
... | ||
|
||
async function run() { | ||
try { | ||
... | ||
} | ||
catch (error) { | ||
core.setFailed(error.message); | ||
} | ||
} | ||
|
||
run() | ||
``` | ||
|
||
See the [toolkit documentation](https://github.com/actions/toolkit/blob/master/README.md#packages) for the various packages. | ||
|
||
## Publish to a distribution branch | ||
|
||
Actions are run from GitHub repos. We will create a releases branch and only checkin production modules (core in this case). | ||
|
||
Comment out node_modules in .gitignore and create a releases/v1 branch | ||
```bash | ||
# comment out in distribution branches | ||
# node_modules/ | ||
``` | ||
|
||
```bash | ||
$ git checkout -b releases/v1 | ||
$ git commit -a -m "prod dependencies" | ||
``` | ||
|
||
```bash | ||
$ npm prune --production | ||
$ git add node_modules | ||
$ git commit -a -m "prod dependencies" | ||
$ git push origin releases/v1 | ||
``` | ||
|
||
Your action is now published! :rocket: | ||
|
||
See the [versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) | ||
|
||
## Validate | ||
|
||
You can now validate the action by referencing the releases/v1 branch | ||
|
||
```yaml | ||
uses: actions/typescript-action@releases/v1 | ||
with: | ||
milliseconds: 1000 | ||
``` | ||
See the [actions tab](https://github.com/actions/javascript-action/actions) for runs of this action! :rocket: | ||
## Usage: | ||
After testing you can [create a v1 tag](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) to reference the stable and tested action | ||
```yaml | ||
uses: actions/typescript-action@v1 | ||
with: | ||
milliseconds: 1000 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import time | ||
from selenium import webdriver | ||
|
||
driver = webdriver.Chrome() # Optional argument, if not specified will search path. | ||
driver.get('http://www.google.com/'); | ||
print(driver.title) | ||
time.sleep(5) # Let the user actually see something! | ||
search_box = driver.find_element_by_name('q') | ||
search_box.send_keys('ChromeDriver') | ||
search_box.submit() | ||
time.sleep(5) # Let the user actually see something! | ||
print(driver.title) | ||
driver.quit() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
describe('example tests', () => { | ||
it('testing', () => { | ||
expect(true).toBe(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
name: 'Your name here' | ||
description: 'Provide a description here' | ||
author: 'Your name or organization here' | ||
inputs: | ||
myInput: # change this | ||
description: 'input description here' | ||
default: 'default value if applicable' | ||
name: 'setup-chromedriver' | ||
description: 'Setup chromedriver' | ||
author: 'nanasess' | ||
runs: | ||
using: 'node12' | ||
main: 'lib/main.js' | ||
main: 'lib/setup-chromedriver.js' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Contributors | ||
|
||
### Checkin | ||
|
||
- Do checkin source (src) | ||
- Do checkin build output (lib) | ||
- Do checkin runtime node_modules | ||
- Do not checkin devDependency node_modules (husky can help see below) | ||
|
||
### devDependencies | ||
|
||
In order to handle correctly checking in node_modules without devDependencies, we run [Husky](https://github.com/typicode/husky) before each commit. | ||
This step ensures that formatting and checkin rules are followed and that devDependencies are excluded. To make sure Husky runs correctly, please use the following workflow: | ||
|
||
``` | ||
npm install # installs all devDependencies including Husky | ||
git add abc.ext # Add the files you've changed. This should include files in src, lib, and node_modules (see above) | ||
git commit -m "Informative commit message" # Commit. This will run Husky | ||
``` | ||
|
||
During the commit step, Husky will take care of formatting all files with [Prettier](https://github.com/prettier/prettier) as well as pruning out devDependencies using `npm prune --production`. | ||
It will also make sure these changes are appropriately included in your commit (no further work is needed) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
set -eo pipefail | ||
|
||
version=$1 | ||
arch=$2 | ||
|
||
sudo apt-fast install -y xvfb screen google-chrome-stable | ||
|
||
wget -c -nc --retry-connrefused --tries=0 https://chromedriver.storage.googleapis.com/${version}/chromedriver_${arch}.zip | ||
unzip -o -q chromedriver_${arch}.zip | ||
sudo mv chromedriver /usr/local/bin/chromedriver |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.