Skip to content

Commit 661adfe

Browse files
Migrate to GitHub Actions (#6)
* Migrate to GitHub Actions and update installation instructions. * Update README.md * Run CI on push / pull_request to master * Upgrade psa to v0.8.0 * Update pulp to v0.15.0 * Update package.json * Bump dev dependency versions * Run (some) tests on CI Co-authored-by: Cyril Sobierajewicz <[email protected]>
1 parent b2844e1 commit 661adfe

File tree

10 files changed

+75
-55
lines changed

10 files changed

+75
-55
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
15+
- uses: purescript-contrib/setup-purescript@main
16+
17+
- uses: actions/setup-node@v1
18+
with:
19+
node-version: "10"
20+
21+
- name: Install dependencies
22+
run: |
23+
npm install -g bower
24+
npm install
25+
bower install --production
26+
27+
- name: Build source
28+
run: npm run-script build
29+
30+
- name: Run tests
31+
run: |
32+
bower install
33+
npm run-script test --if-present

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/.*
22
!/.gitignore
33
!/.eslintrc.json
4-
!/.travis.yml
4+
!/.github/
55
package-lock.json
66
/bower_components/
77
/node_modules/

.travis.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# purescript-web-xpath
22

33
[![Latest release](http://img.shields.io/github/release/purescript-web/purescript-web-dom-xpath.svg)](https://github.com/purescript-web/purescript-web-dom-xpath/releases)
4-
[![Build status](https://travis-ci.org/purescript-web/purescript-web-dom-xpath.svg?branch=master)](https://travis-ci.org/purescript-web/purescript-web-dom-xpath)
4+
[![Build status](https://github.com/purescript-web/purescript-web-dom-xpath/workflows/CI/badge.svg?branch=master)](https://github.com/purescript-web/purescript-web-dom-xpath/actions?query=workflow%3ACI+branch%3Amaster)
5+
[![Pursuit](https://pursuit.purescript.org/packages/purescript-web-dom-xpath/badge)](https://pursuit.purescript.org/packages/purescript-web-dom-xpath)
56

67
Type definitions and low level interface implementations for the [W3C DOM XPath API](https://www.w3.org/TR/DOM-Level-3-XPath/).
78

89
## Installation
910

1011
```
11-
bower install purescript-web-dom-xpath
12+
spago install web-dom-xpath
1213
```
1314

1415
## Documentation

package.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@
33
"private": true,
44
"scripts": {
55
"clean": "rimraf output && rimraf .pulp-cache",
6-
"build": "bower install && eslint src && pulp build -- --censor-lib --strict",
7-
"test": "npm run build && pulp test",
6+
"build": "eslint src && pulp build -- --censor-lib --strict",
7+
"test": "eslint src && pulp build -I \"test\" -- --censor-lib && node test/node.js",
88
"testbrowser": "./scripts/testbrowser"
99
},
1010
"devDependencies": {
11-
"bower": "^1.8.8",
12-
"eslint": "^4.19.1",
13-
"parcel-bundler": "^1.12.3",
14-
"pulp": "^13.0.0",
15-
"purescript": "^0.13.0",
16-
"purescript-psa": "^0.6.0",
17-
"rimraf": "^2.6.2"
11+
"eslint": "^7.15.0",
12+
"jsdom": "^16.4.0",
13+
"parcel-bundler": "^1.12.4",
14+
"pulp": "^15.0.0",
15+
"purescript-psa": "^0.8.0",
16+
"rimraf": "^3.0.2"
1817
}
1918
}

scripts/testbrowser

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env sh
22

3-
pulp build --main "Test.Main" --src-path "src" -I "test" \
4-
-- --censor-lib && \
3+
eslint src && \
4+
pulp build -I "test" -- --censor-lib && \
55
parcel build --public-url ./ test/index.html

test/Main.purs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ mkCdYear doc node = liftEffect $ XP.evaluateString
8080
Nothing
8181
doc
8282

83-
main :: Effect Unit
84-
main = runTest do
83+
main :: { browser :: Boolean } -> Effect Unit
84+
main { browser } = runTest do
8585
suite "non-namespaced tests" do
8686
test "note.xml and catalog.xml" do
8787
domParser <- liftEffect $ makeDOMParser
@@ -148,22 +148,23 @@ main = runTest do
148148
Assert.assertFalse "custom NS resolver shouldn't be null"
149149
(isNull $ unsafeToForeign customRes)
150150

151-
atomFeedDoc <-liftEffect $ parseAtomFeedDoc domParser
152-
atomFeed <- pure $ toNode atomFeedDoc
151+
when browser $ do
152+
atomFeedDoc <- liftEffect $ parseAtomFeedDoc domParser
153+
atomFeed <- pure $ toNode atomFeedDoc
153154

154-
createdNSResolver <- pure $ XP.createNSResolver atomFeed atomFeedDoc
155-
Assert.assertFalse "created NS resolver shouldn't be undefined"
156-
(isUndefined $ unsafeToForeign createdNSResolver)
157-
Assert.assertFalse "created NS resolver shouldn't be null"
158-
(isNull $ unsafeToForeign createdNSResolver)
155+
createdNSResolver <- pure $ XP.createNSResolver atomFeed atomFeedDoc
156+
Assert.assertFalse "created NS resolver shouldn't be undefined"
157+
(isUndefined $ unsafeToForeign createdNSResolver)
158+
Assert.assertFalse "created NS resolver shouldn't be null"
159+
(isNull $ unsafeToForeign createdNSResolver)
159160

160-
defNSResolver <- liftEffect $ XP.defaultNSResolver atomFeed atomFeedDoc
161-
Assert.assertFalse "default NS resolver shouldn't be undefined"
162-
(isUndefined $ unsafeToForeign defNSResolver)
163-
Assert.assertFalse "default NS resolver shouldn't be null"
164-
(isNull $ unsafeToForeign defNSResolver)
161+
defNSResolver <- liftEffect $ XP.defaultNSResolver atomFeed atomFeedDoc
162+
Assert.assertFalse "default NS resolver shouldn't be undefined"
163+
(isUndefined $ unsafeToForeign defNSResolver)
164+
Assert.assertFalse "default NS resolver shouldn't be null"
165+
(isNull $ unsafeToForeign defNSResolver)
165166

166-
test "atom.xml" do
167+
test "atom.xml" $ when browser do
167168
domParser <- liftEffect $ makeDOMParser
168169

169170
atomFeedDoc <-liftEffect $ parseAtomFeedDoc domParser
@@ -198,7 +199,7 @@ main = runTest do
198199
metajeloId <- liftEffect $ XP.stringValue metajeloIdRes
199200
tlog $ "got metajelo id" <> metajeloId
200201
Assert.equal RT.string_type (XP.resultType metajeloIdRes)
201-
Assert.equal "OjlTjf" metajeloId
202+
when browser $ Assert.equal "OjlTjf" metajeloId
202203

203204
prod0pol0xpath <- pure $
204205
"/x:record/x:supplementaryProducts/x:supplementaryProduct[1]" <>
@@ -214,7 +215,7 @@ main = runTest do
214215
mjProd0Pol0 <- liftEffect $ XP.stringValue mjProd0Pol0Res
215216
tlog $ "got metajelo ref policy " <> mjProd0Pol0
216217
Assert.equal RT.string_type (XP.resultType mjProd0Pol0Res)
217-
Assert.equal "http://skGHargw/" mjProd0Pol0
218+
when browser $ Assert.equal "http://skGHargw/" mjProd0Pol0
218219
--
219220
mjProd0Pol0AppliesRes <- liftEffect $ XP.evaluate
220221
(prod0pol0xpath <> "/@appliesToProduct")
@@ -226,7 +227,7 @@ main = runTest do
226227
mjProd0Pol0Applies <- liftEffect $ XP.stringValue mjProd0Pol0AppliesRes
227228
tlog $ "got metajelo policy appliesToProduct: " <> (show mjProd0Pol0Applies)
228229
Assert.equal RT.string_type (XP.resultType mjProd0Pol0AppliesRes)
229-
Assert.equal "0" mjProd0Pol0Applies
230+
when browser $ Assert.equal "0" mjProd0Pol0Applies
230231

231232
tlog :: forall a. Show a => a -> Aff Unit
232233
tlog = liftEffect <<< logShow
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
import Main from "../output/Test.Main/index.js";
2-
Main.main();
2+
3+
Main.main({ browser: true })();

test/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<body>
88
<script
99
type="application/javascript"
10-
src="./index.js"
10+
src="./browser.js"
1111
charset="utf-8"></script>
1212
<p>To see test output: open your browser's web console and reload the page.</p>
1313
</body>

test/node.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const { JSDOM } = require("jsdom");
2+
const { XPathResult, DOMParser } = new JSDOM().window;
3+
4+
Object.assign(global, { XPathResult, DOMParser })
5+
6+
require("../output/Test.Main/index.js").main({ browser: false })();

0 commit comments

Comments
 (0)