Skip to content

Commit

Permalink
set up github actions CI instead of Travis (#503)
Browse files Browse the repository at this point in the history
* set up github actions CI instead of Travis

* switch purpleMarker.json purpleLayer.json ???

* modify purpleairmarker code

this should be broken into its own file!

* revert purpleMarker/purpleLayer change

* Update layercode.js

* set longer 10000 timeout for Skytruth tests in cypress...?

* Update cypress.json

* Update skytruth.spec.js
  • Loading branch information
jywarren authored Feb 16, 2021
1 parent cc57e0f commit f3b4a50
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 13 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: tests
on: [pull_request]
jobs:
jasmine-tests:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: '10'
check-latest: true
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Dependencies
run: npm install
- name: "Build dist files"
run: grunt build
- name: "Transpile"
run: grunt transpile
- name: "Run tests"
run: grunt jasmine

cypress-tests:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: '10'
check-latest: true
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Dependencies
run: npm install
- name: "Build dist files"
run: grunt build
- name: "Transpile"
run: grunt transpile
- name: "Run Cypress tests"
run: npm run start:ci & npm run cy:run:chrome
5 changes: 3 additions & 2 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"baseUrl": "http://localhost:8080",
"modifyObstructiveCode": false
}
"modifyObstructiveCode": false,
"chromeWebSecurity": false
}
6 changes: 4 additions & 2 deletions cypress/integration/purpleAirMarker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ describe('Purple layer - markers', function() {

it('has circle markers in minimal mode', function() {
cy.server()
cy.route('GET', 'https://www.purpleair.com/data.json?fetchData=true&minimize=true&sensorsActive2=10080&orderby=L&nwlat=45.67548217560647&selat=41.79179268262892&nwlng=-101.03576660156251&selng=-93.93310546875001', 'fixture:purpleMarker.json')
cy.route('GET',
'https://www.purpleair.com/data.json?fetchData=true&minimize=true&sensorsActive2=10080&orderby=L&nwlat=45.67548217560647&selat=41.79179268262892&nwlng=-101.03576660156251&selng=-93.93310546875001',
'fixture:purpleMarker.json')
const spy = cy.spy(window.top.aut.PurpleAirMarkerLayer, 'requestData')
cy.get('[title="Show minimal markers"]').click().then(() => {
expect(spy).to.be.called
Expand All @@ -52,4 +54,4 @@ describe('Purple layer - markers', function() {
cy.get('.leaflet-marker-pane img').should('have.length', 0)
cy.get('.leaflet-overlay-pane svg g').children().should('have.length', 0)
})
})
})
6 changes: 3 additions & 3 deletions cypress/integration/skytruth.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ describe('Skytruth layer', function() {
cy.openWindow('/example/index.html#lat=41.6283&lon=-91.7235&zoom=10&layers=Standard')
cy.wait(300)
cy.window().then((win) => {
cy.get('.leaflet-overlay-pane').children().should('have.length', 0)
cy.fixture('skytruth').then((data) => {
cy.stub(win.SkyTruth, 'requestData', function() {
win.SkyTruth.parseData(data);
})
})
cy.get('#map-menu-skytruth label').click({ force: true })
cy.get('.leaflet-marker-pane').children().should('have.length', 2)
cy.get('.leaflet-overlay-pane').children().should('have.length', 1)
})
})

Expand All @@ -18,8 +19,7 @@ describe('Skytruth layer', function() {
})

it('has default markers in default mode', function() {
cy.get('.leaflet-marker-pane img').invoke('attr', 'src').should('eq', 'https://www.clker.com/cliparts/T/G/b/7/r/A/red-dot.svg')
cy.get('.leaflet-marker-pane img[src="https://www.clker.com/cliparts/T/G/b/7/r/A/red-dot.svg"]').should('have.length', 2)
cy.get('.leaflet-overlay-pane svg').should('have.length', 1)
})

it('has circle markers in minimal mode', function() {
Expand Down
14 changes: 8 additions & 6 deletions src/layercode.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,13 +309,15 @@ L.LayerGroup.LayerCode = L.LayerGroup.extend(
if (this.layer == 'purpleairmarker')
{
var redDotIcon =new L.icon.purpleAirMarkerIcon();
var lat = data[25];
var lng = data[26];
// ref https://www.purpleair.com/data.json?fetchData=true&minimize=true&sensorsActive2=10080&orderby=L&nwlat=45.67548217560647&selat=41.79179268262892&nwlng=-101.03576660156251&selng=-93.93310546875001
// ["ID","pm","pm_cf_1","pm_atm","age","pm_0","pm_1","pm_2","pm_3","pm_4","pm_5","pm_6","conf","pm1","pm_10","p1","p2","p3","p4","p5","p6","Humidity","Temperature","Pressure","Elevation","Type","Label","Lat","Lon","Icon","isOwner","Flags","Voc","Ozone1","Adc","CH"],
var lat = data[27];
var lng = data[28];
var value = parseFloat(data[16]);
var Label = data[24];
var temp_f = data[21];
var humidity = data[20];
var pressure = data[22];
var Label = data[26];
var temp_f = data[22];
var humidity = data[21];
var pressure = data[23];
var defaultMarker = L.marker([lat, lng], {icon: redDotIcon});
var minimalMarker = L.circleMarker(L.latLng([lat, lng]), { radius: 5, weight: 1, fillOpacity: 1, color: '#7c7c7c', fillColor: '#7c22b5' });
var content = '<i style=\'color: purple ; size : 20px\'>Label : ' + Label + '</i><br><br> <strong>PM2.5 Value : ' + value +'</strong><br><strong> Lat: ' + lat + '</strong><br><strong> Lon: ' + lng + '<br>Temp (F) : '+temp_f+'<br>Humidity : ' + humidity + '<br>Pressure : ' + pressure +'<br><br> <i>Data provided by <a href=\'www.purpleair.com\'>www.purpleair.com</a></i>';
Expand Down

0 comments on commit f3b4a50

Please sign in to comment.