Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test pr: Removing the PR build from the site after a PR merge #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/merge_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: After PR merging

on:
pull_request:
types:
- closed

jobs:
if_merged:
env:
WEBSITE_REPO: ${{ secrets.WEBSITE_REPO }}
if: ${{ github.event.pull_request.merged == true && env.WEBSITE_REPO != '' }}
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v3
with:
repository: ${{ secrets.WEBSITE_REPO }}
ref: 'master'
token: ${{ secrets.API_TOKEN_GITHUB }}

- name: Setup git config
run: |
git config user.name "userz"
git config user.email "<>"

- name: Delete old build artifacts
run: |
git rm -r static/build/artifact/PR${{ github.event.number }}/
git commit -m "🤖 PR #${{ github.event.number }} merged, deleting old build artifacts"

- run: git push origin master
7 changes: 4 additions & 3 deletions .github/workflows/upload_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ on:
jobs:
upload:
runs-on: ubuntu-latest
env:
WEBSITE_REPO: ${{ secrets.WEBSITE_REPO }}
if: >
${{ github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success' }}
github.event.workflow_run.conclusion == 'success' &&
env.WEBSITE_REPO != '' }}
steps:
- name: 'Download artifact'
uses: actions/github-script@v6
Expand Down Expand Up @@ -51,7 +54,6 @@ jobs:
env:
WEBSITE_REPO: ${{ secrets.WEBSITE_REPO }}
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
if: ${{ env.WEBSITE_REPO != '' }}
uses: dmnemec/copy_file_to_another_repo_action@main
with:
source_file: "./build/."
Expand All @@ -63,7 +65,6 @@ jobs:
commit_message: '🤖 New IITC test build from https://github.com/${{ github.repository }}/commit/${{ github.sha }}'

- name: Comment with build url
if: ${{ env.WEBSITE_REPO != '' }}
env:
WEBSITE_REPO: ${{ secrets.WEBSITE_REPO }}
uses: marocchino/sticky-pull-request-comment@v2
Expand Down
100 changes: 60 additions & 40 deletions plugins/cross-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
// @version 1.3.1
// @description Checks for existing links that cross planned links. Requires draw-tools plugin.


window.plugin.crossLinks = function () { };
window.plugin.crossLinks = function () {};

/**
* greatCircleArcIntersect
*/
window.plugin.crossLinks.greatCircleArcIntersect = function (a0, a1, b0, b1) {

// 0) quick checks
// zero length line
if (a0.equals(a1)) return false;
Expand Down Expand Up @@ -50,8 +48,8 @@ window.plugin.crossLinks.greatCircleArcIntersect = function (a0, a1, b0, b1) {
// c) special case when both planes are equal
// = both lines are on the same greatarc. test if they overlap
var len2 = p[0] * p[0] + p[1] * p[1] + p[2] * p[2];
if (len2 < 1e-30) /* === 0 */ {
// b0 inside a0-a1 ?
if (len2 < 1e-30) {
/* === 0 */ // b0 inside a0-a1 ?
var s1 = dot(cb0, da0);
var d1 = dot(cb0, da1);
if ((s1 < 0 && d1 > 0) || (s1 > 0 && d1 < 0)) return true;
Expand All @@ -68,7 +66,7 @@ window.plugin.crossLinks.greatCircleArcIntersect = function (a0, a1, b0, b1) {

// normalize P
var n = 1 / Math.sqrt(len2);
p[0] *= n, p[1] *= n, p[2] *= n
(p[0] *= n), (p[1] *= n), (p[2] *= n);

// d) at this point we have two possible collision points
// p or -p (in 3D space)
Expand Down Expand Up @@ -99,56 +97,75 @@ function toCartesian(lat, lng) {
lat *= d2r;
lng *= d2r;
var o = Math.cos(lat);
return [o * Math.cos(lng), o * Math.sin(lng), Math.sin(lat)]
return [o * Math.cos(lng), o * Math.sin(lng), Math.sin(lat)];
}

function cross(t, n) {
return [t[1] * n[2] - t[2] * n[1], t[2] * n[0] - t[0] * n[2], t[0] * n[1] - t[1] * n[0]]
return [
t[1] * n[2] - t[2] * n[1],
t[2] * n[0] - t[0] * n[2],
t[0] * n[1] - t[1] * n[0],
];
}

function dot(t, n) {
return t[0] * n[0] + t[1] * n[1] + t[2] * n[2]
return t[0] * n[0] + t[1] * n[1] + t[2] * n[2];
}


window.plugin.crossLinks.testPolyLine = function (polyline, link, closed) {

var a = link.getLatLngs();
var b = polyline.getLatLngs();

for (var i = 0; i < b.length - 1; ++i) {
if (window.plugin.crossLinks.greatCircleArcIntersect(a[0], a[1], b[i], b[i + 1])) return true;
if (
window.plugin.crossLinks.greatCircleArcIntersect(
a[0],
a[1],
b[i],
b[i + 1]
)
)
return true;
}

if (closed) {
if (window.plugin.crossLinks.greatCircleArcIntersect(a[0], a[1], b[b.length - 1], b[0])) return true;
if (
window.plugin.crossLinks.greatCircleArcIntersect(
a[0],
a[1],
b[b.length - 1],
b[0]
)
)
return true;
}

return false;
}
};

window.plugin.crossLinks.onLinkAdded = function (data) {
if (window.plugin.crossLinks.disabled) return;

plugin.crossLinks.testLink(data.link);
}
};

window.plugin.crossLinks.checkAllLinks = function () {
if (window.plugin.crossLinks.disabled) return;

console.debug('Cross-Links: checking all links');
console.debug("Cross-Links: checking all links");
plugin.crossLinks.linkLayer.clearLayers();
plugin.crossLinks.linkLayerGuids = {};

$.each(window.links, function (guid, link) {
plugin.crossLinks.testLink(link);
});
}
};

window.plugin.crossLinks.testLink = function (link) {
if (plugin.crossLinks.linkLayerGuids[link.options.guid]) return;

for (var i in plugin.drawTools.drawnItems._layers) { // leaflet don't support breaking out of the loop
for (var i in plugin.drawTools.drawnItems._layers) {
// leaflet don't support breaking out of the loop
var layer = plugin.drawTools.drawnItems._layers[i];
if (layer instanceof L.GeodesicPolygon) {
if (plugin.crossLinks.testPolyLine(layer, link, true)) {
Expand All @@ -162,32 +179,30 @@ window.plugin.crossLinks.testLink = function (link) {
}
}
}
}

};

window.plugin.crossLinks.showLink = function (link) {

var poly = L.geodesicPolyline(link.getLatLngs(), {
color: '#d22',
color: "#d22",
opacity: 0.7,
weight: 5,
interactive: false,
dashArray: '8,8',
dashArray: "8,8",

guid: link.options.guid
guid: link.options.guid,
});

poly.addTo(plugin.crossLinks.linkLayer);
plugin.crossLinks.linkLayerGuids[link.options.guid] = poly;
}
};

window.plugin.crossLinks.onMapDataRefreshEnd = function () {
if (window.plugin.crossLinks.disabled) return;

window.plugin.crossLinks.linkLayer.bringToFront();

window.plugin.crossLinks.testForDeletedLinks();
}
};

window.plugin.crossLinks.testAllLinksAgainstLayer = function (layer) {
if (window.plugin.crossLinks.disabled) return;
Expand All @@ -205,31 +220,34 @@ window.plugin.crossLinks.testAllLinksAgainstLayer = function (layer) {
}
}
});
}
};

window.plugin.crossLinks.testForDeletedLinks = function () {
window.plugin.crossLinks.linkLayer.eachLayer(function (layer) {
var guid = layer.options.guid;
if (!window.links[guid]) {
console.log('link removed');
console.log("link removed");
plugin.crossLinks.linkLayer.removeLayer(layer);
delete plugin.crossLinks.linkLayerGuids[guid];
}
});
}
};

window.plugin.crossLinks.createLayer = function () {
window.plugin.crossLinks.linkLayer = new L.FeatureGroup();
window.plugin.crossLinks.linkLayerGuids = {};
window.layerChooser.addOverlay(window.plugin.crossLinks.linkLayer, 'Cross Links');
window.layerChooser.addOverlay(
window.plugin.crossLinks.linkLayer,
"Cross Links"
);

map.on('layeradd', function (obj) {
map.on("layeradd", function (obj) {
if (obj.layer === window.plugin.crossLinks.linkLayer) {
delete window.plugin.crossLinks.disabled;
window.plugin.crossLinks.checkAllLinks();
}
});
map.on('layerremove', function (obj) {
map.on("layerremove", function (obj) {
if (obj.layer === window.plugin.crossLinks.linkLayer) {
window.plugin.crossLinks.disabled = true;
window.plugin.crossLinks.linkLayer.clearLayers();
Expand All @@ -241,19 +259,19 @@ window.plugin.crossLinks.createLayer = function () {
if (!map.hasLayer(window.plugin.crossLinks.linkLayer)) {
window.plugin.crossLinks.disabled = true;
}
}
};

var setup = function () {
if (window.plugin.drawTools === undefined) {
alert('\'Cross-Links\' requires \'draw-tools\'');
alert("'Cross-Links' requires 'draw-tools'");
return;
}

window.plugin.crossLinks.createLayer();

// events
window.addHook('pluginDrawTools', function (e) {
if (e.event === 'layerCreated') {
window.addHook("pluginDrawTools", function (e) {
if (e.event === "layerCreated") {
// we can just test the new layer in this case
window.plugin.crossLinks.testAllLinksAgainstLayer(e.layer);
} else {
Expand All @@ -262,7 +280,9 @@ var setup = function () {
}
});

window.addHook('linkAdded', window.plugin.crossLinks.onLinkAdded);
window.addHook('mapDataRefreshEnd', window.plugin.crossLinks.onMapDataRefreshEnd);

}
window.addHook("linkAdded", window.plugin.crossLinks.onLinkAdded);
window.addHook(
"mapDataRefreshEnd",
window.plugin.crossLinks.onMapDataRefreshEnd
);
};