Skip to content

Commit

Permalink
Merge pull request #12 from milespetrov/pr-link-fix
Browse files Browse the repository at this point in the history
Pr link fix
  • Loading branch information
milespetrov authored Dec 2, 2024
2 parents 58358cb + cbb77fc commit f51a9d6
Show file tree
Hide file tree
Showing 377 changed files with 18,343 additions and 19,524 deletions.
14 changes: 14 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,21 @@
### Notes
*Additional comments about the changes in this PR, including screenshots/gifs*

### QA Testing

*See https://hackmd.io/@james-rae/HJhylgGpA for details on qa test scenarios and procedures*

*If this PR is not the last category (does not require special qa demo branch), put the next line in this section*
Please test against `main` branch https://ramp4-pcar4.github.io/ramp4-pcar4/main/demos/enhanced-samples.html

*If this PR will require a future qa branch & PR, put the next line in this section*
QA demo in future PR.

*If this PR is the qa branch & special demo, put the next line in this section. Link the OG PR in Related Items above.*
Please test using the demo links in the first comment.

### Testing

Steps:
1. ...
2. ...
4 changes: 4 additions & 0 deletions .github/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
transformers
protobuf
sentencepiece
torch
44 changes: 44 additions & 0 deletions .github/slack-bot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import os
import json
from transformers import pipeline

# Get the PR body and labels from environment variables
pr_body = os.environ.get('PR_BODY', '')
pr_labels_json = os.environ.get('PR_LABELS_JSON', '[]')
pr_labels = json.loads(pr_labels_json)

# Summarization (example model, could be adjusted)
summarizer = pipeline('summarization', model='tuner007/pegasus_summarizer')
neutral_summary = summarizer(pr_body, max_length=200, min_length=25, do_sample=False)[0]['summary_text']

# Replace all double quotes with single quotes in the summary
neutral_summary = neutral_summary.replace('"', "'")

# PR label types with associated metadata
pr_label_types = {
'PR: Active': ['Active', 'https://github.com/search?q=org%3Aramp4-pcar4+state%3A%22open%22+type%3A%22pr%22+label%3A%22PR%3A+Active%22&type=pullrequests'],
'PR: Build': ['Build', 'https://github.com/search?q=org%3Aramp4-pcar4+state%3A%22open%22+type%3A%22pr%22+label%3A%22PR%3A+Active%22%2C%22PR%3A+Build%22+&type=pullrequests'],
'PR: Frontend': ['Frontend', 'https://github.com/search?q=org%3Aramp4-pcar4+state%3A%22open%22+type%3A%22pr%22+label%3A%22PR%3A+Active%22%2C%22PR%3A+Frontend%22+&type=pullrequests'],
'PR: Geo': ['Geo', 'https://github.com/search?q=org%3Aramp4-pcar4+state%3A%22open%22+type%3A%22pr%22+label%3A%22PR%3A+Active%22%2C%22PR%3A+Geo%22+&type=pullrequests']
}

# Format PR label links as Slack mrkdwn links
pr_label_str = ", ".join(
f"<{pr_label_types[label['name']][1]}|{pr_label_types[label['name']][0]}>"
for label in pr_labels if pr_label_types.get(label['name'])
)
if (len(pr_label_str) == 0):
pr_label_str = "None"

# Handle regular labels (not in pr_label_types)
reg_label_str = ", ".join(
label['name'] for label in pr_labels if pr_label_types.get(label['name']) is None
)
if (len(reg_label_str) == 0):
reg_label_str = "None"

# Write all results to environment
with open(os.environ['GITHUB_ENV'], 'a') as env_file:
env_file.write(f'NEUTRAL_SUMMARY={neutral_summary}\n')
env_file.write(f'PR_LABEL_STR={pr_label_str}\n')
env_file.write(f'REG_LABEL_STR={reg_label_str}\n')
2 changes: 2 additions & 0 deletions .github/workflows/demo-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: '22.5.1'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
cache-dependency-path: ramp/package-lock.json

Expand Down Expand Up @@ -102,6 +103,7 @@ jobs:
- name: Publish to NPM for tag releases on main repo only
if: github.repository == 'ramp4-pcar4/ramp4-pcar4' && startsWith(github.ref, 'refs/tags/v')
run: |
cd ramp
TAG_VERSION=${GITHUB_REF#refs/tags/v}
PACKAGE_VERSION=$(node -p "require('./package.json').version")
if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/demo-pr-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ jobs:
steps:
- name: Comment on the PR
uses: peter-evans/create-or-update-comment@v4
env:
PR_USER: ${{ github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name && github.event.pull_request.base.repo.owner.login || github.event.pull_request.head.repo.owner.login }}
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
Your demo site is ready! 🚀
Enhanced Testing:
Samples: https://${{github.event.pull_request.user.login}}.github.io/ramp4-pcar4/${{github.head_ref}}/demos/enhanced-samples.html
Catalogue: https://${{github.event.pull_request.user.login}}.github.io/ramp4-pcar4/${{github.head_ref}}/demos/enhanced-all.html
Samples: https://${{ env.PR_USER }}.github.io/ramp4-pcar4/${{github.head_ref}}/demos/enhanced-samples.html
Catalogue: https://${{ env.PR_USER }}.github.io/ramp4-pcar4/${{github.head_ref}}/demos/enhanced-all.html
Legacy Testing:
Main: https://${{github.event.pull_request.user.login}}.github.io/ramp4-pcar4/${{github.head_ref}}/
Catalogue: https://${{github.event.pull_request.user.login}}.github.io/ramp4-pcar4/${{github.head_ref}}/demos/index-all.html
Samples: https://${{github.event.pull_request.user.login}}.github.io/ramp4-pcar4/${{github.head_ref}}/demos/index-samples.html
Main: https://${{ env.PR_USER }}.github.io/ramp4-pcar4/${{github.head_ref}}/
Catalogue: https://${{ env.PR_USER }}.github.io/ramp4-pcar4/${{github.head_ref}}/demos/index-all.html
Samples: https://${{ env.PR_USER }}.github.io/ramp4-pcar4/${{github.head_ref}}/demos/index-samples.html
77 changes: 77 additions & 0 deletions .github/workflows/slack-bot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: slack-PR-message
on:
pull_request_target:
types:
- opened

permissions:
contents: read
pull-requests: read

jobs:
post-to-slack:
runs-on: ubuntu-20.04
steps:
- name: Check user permissions (allow only those w/ write access)
id: permission_check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
user_permission=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
"https://api.github.com/repos/${{ github.repository }}/collaborators/${{ github.event.pull_request.user.login }}/permission" | jq -r .permission)
if [[ "$user_permission" != "write" && "$user_permission" != "admin" ]]; then
echo "User does not have write access. Exiting."
exit 1
fi
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install Python dependency
run: pip install -r .github/requirements.txt

- name: Summarize PR body and process labels
id: summarize
env:
PR_LABELS_JSON: ${{ toJSON(github.event.pull_request.labels) }}
PR_BODY: ${{ github.event.pull_request.body }}
run: python .github/slack-bot.py

- name: Post to a Slack channel
id: slack
uses: slackapi/[email protected]
with:
channel-id: 'C08080W3W0Y'
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "New *ramp4-pcar4* PR by *${{ github.event.pull_request.user.login }}*"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Title*: ${{ github.event.pull_request.title }}\n*PR Type*: ${{ env.PR_LABEL_STR }}\n*Other labels*: ${{ env.REG_LABEL_STR }}\n*Link*: ${{ github.event.pull_request.html_url }}"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*PR Summary*:\n${{ env.NEUTRAL_SUMMARY }}"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,6 @@ dist/
# Generated docs folders
vite-docs
ts-docs

# Personal IDE settings
.idea
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"singleQuote": true,
"trailingComma": "none",
"arrowParens": "avoid",
"endOfLine": "auto"
"endOfLine": "auto",
"printWidth": 120
}
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,23 @@ Legacy Samples: `https://localhost:5173/demos/index-samples.html`.
npm run dev-http
```

### Build for production
### Building the application

```sh
npm run build
```

The production files will be placed in the `dist` folder.
This command runs four parallel builds, each with a different target mode and use case. This is done because Vite and Rollup do not support multiple build configurations at the same time. The modes are:

- `npm run build:npm`: This build generates the `dist/ramp.bundle.es.js` file which is the file that would be used if ramp is installed via npm. All `package.json` dependencies are excluded from this file, the consuming applications npm manager and build process will handle this.

- `npm run build:esDynamic`: This build generates the `dist/esDynamic` folder which contains the ramp library split into ES modules. This is useful for web applications that want dynamic imports to reduce the size of the initial bundle.

- `npm run build:inline`: This build generates the `dist/ramp.browser.es.js` and `dist/ramp.browser.iife.js` files which contain the entire ramp library as a single file. These files don't support dynamic imports and should only be used if the consuming environment doesn't support ES modules (use iife) and/or only one ramp file can be hosted.

- `npm run build:demos`: This build generates the `dist/demos` folder which contains the demo files. These files are the closest representation of a local develop serve.

You can also run these commands separately if you only need to build one of the modes.

### Preview production build (after running build)

Expand Down Expand Up @@ -115,7 +125,7 @@ npm run preview

Then open `http://localhost:5050/index.html` in your browser.

The `demos` folder **is** processed by vite and can therefore reference any source file in the repo. This is the starting point for local development. For example, the `demos/starter-scripts/main.js` file imports `{ createInstance, geo } from '@/main';` whereas `public/starter-scripts/index.js` doesn't since RAMP is globally defined by the `index.html` file when it loads `<script src="./lib/ramp.js"></script>`.
The `demos` folder **is** processed by vite and can therefore reference any source file in the repo. This is the starting point for local development. For example, the `demos/starter-scripts/main.js` file imports `{ createInstance, geo } from '@/main';` whereas `public/starter-scripts/index.js` doesn't since RAMP is globally defined by the `index.html` file when it loads `<script src="./ramp.browser.iife.js"></script>`.

Run `npm run dev` then open `http://localhost:3000/demos/index.html` in your browser.

Expand Down
96 changes: 35 additions & 61 deletions demos/enhanced-all.html
Original file line number Diff line number Diff line change
@@ -1,76 +1,52 @@
<html>
<head>
<title>R4MP Enhanced Samples Yellow Pages</title>
<style>
.tag {
display: inline-block;
border-radius: 3px;
padding: 0.2em 0.5em 0.3em;
margin: 0.25em 0.1em;
background: #888888;
color: #000000;
}
.layer {
background: #41b883;
}
.legend {
background: #b8b641;
}
.misc {
background: #ee7d20;
}
body {
background-color: black;
color: aliceblue;
}
a {
color: deepskyblue;
}
li,
p {
font-size: 1.1rem;
}
</style>
<link rel="stylesheet" href="./styles/all.css" />
</head>
<body>
<h1>RAMP 4 Enhanced Samples Catalogue</h1>
<h2>Classic Samples</h2>
<p>Are found <a href="index-all.html">here</a>.</p>

<h2>Simple Samples</h2>
<h2>Other Samples</h2>
<p>
Samples with no fancy configuration. Useful for testing the basics.
Classic Samples are found <a href="index-all.html">here</a>. QA Samples are found
<a href="qa-all.html">here</a>.
</p>

<h2>Simple Samples</h2>
<p>Samples with no fancy configuration. Useful for testing the basics.</p>
<ul>
<li>
01.
<a href="enhanced-samples.html?sample=1">Happy</a>. Very basic
site for fast dev spinup. Default choice.
<a href="enhanced-samples.html?sample=1">Happy</a>. Very basic site for fast dev spinup. Default choice.
</li>
<li>
02.
<a href="enhanced-samples.html?sample=2">No Layers</a>. Test
template config untouched except for legend text.
<a href="enhanced-samples.html?sample=2">No Layers</a>. Test template config untouched except for legend
text.
</li>
<li>
03.
<a href="enhanced-samples.html?sample=3">Feature Layers</a>.
Couple of feature layers
<a href="enhanced-samples.html?sample=3">Feature Layers</a>. Couple of feature layers
</li>
<li>
04.
<a href="enhanced-samples.html?sample=4">Map Image Layers</a>.
An MIL with two sublayers.
<a href="enhanced-samples.html?sample=4">Map Image Layers</a>. An MIL with two sublayers.
</li>
<li>
05.
<a href="enhanced-samples.html?sample=5">File Layers</a>.
GeoJSON, CSV, and Shapefile layers.
<a href="enhanced-samples.html?sample=5">File Layers</a>. GeoJSON, CSV, and Shapefile layers.
</li>
<li>
06.
<a href="enhanced-samples.html?sample=6">Data Layers</a>. A
table service and custom JSON layer.
<a href="enhanced-samples.html?sample=6">Data Layers</a>. A table service and custom JSON layer.
</li>
<li>
08.
<a href="enhanced-samples.html?sample=8">Different Projections</a>. Has feature-based layers in a mix of
source projections.
</li>
<li>
09.
<a href="enhanced-samples.html?sample=9">Custom HTML panels</a>. Contains custom HTML panels
</li>
</ul>

Expand All @@ -79,16 +55,20 @@ <h2>Fancy Samples</h2>
<ul>
<li>
07.
<a href="index-samples.html?sample=7">O.G. Main</a>. The first /
default sample from the classic samples.
<a href="enhanced-samples.html?sample=7">O.G. Main</a>. The first / default sample from the classic
samples.
</li>
<li>
10.
<a href="enhanced-samples.html?sample=10">Identify Prioritization</a>. Has layers set up to test result
prioritization scenarios.
</li>
</ul>

<h2>Respect for Apps</h2>
<p>
Maps that are currently being used on real sites, demonstrated with
RAMP4. Note that some not all the features on the real sites are
currently supported.
Maps that are currently being used on real sites, demonstrated with RAMP4. Note that some not all the
features on the real sites are currently supported.
</p>
<ul>
<li>Stuff to be added.</li>
Expand All @@ -107,19 +87,13 @@ <h2>Various Templates</h2>
<a href="index-wet.html">RAMP inside the WET template</a>
</li>
<li>
<a href="index-teleport-details.html"
>RAMP with a teleported details panel</a
>
<a href="index-teleport-details.html">RAMP with a teleported details panel</a>
</li>
<li>
<a href="index-teleport-wet.html"
>RAMP inside the WET template with teleport enabled</a
>
<a href="index-teleport-wet.html">RAMP inside the WET template with teleport enabled</a>
</li>
<li>
<a href="index-multi-wet.html"
>Multiple RAMP instances inside the WET template</a
>
<a href="index-multi-wet.html">Multiple RAMP instances inside the WET template</a>
</li>
</ul>
</body>
Expand Down
Loading

0 comments on commit f51a9d6

Please sign in to comment.