diff --git a/.github/workflows/dashboard-workflow.yml b/.github/workflows/dashboard-workflow.yml new file mode 100644 index 00000000..4b3604a4 --- /dev/null +++ b/.github/workflows/dashboard-workflow.yml @@ -0,0 +1,75 @@ +name: Makefile CI + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +jobs: + make_dashboard: + name: Build Dashboard + runs-on: ubuntu-latest + steps: + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: "3.10" + architecture: x64 + + - run: sudo apt update + + - run: sudo apt install curl + + - name: Install NPM + run: curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash + + - name: Install npm deps + run: cd dashboard && npm ci + + - id: cache-pipenv + uses: actions/cache@v3 + with: + path: ~/.local/share/virtualenvs + key: ${{ runner.os }}-pipenv-${{ hashFiles('dashboard/Pipfile.lock') }} + + - name: Install dependencies + if: steps.cache-pipenv.outputs.cache-hit != 'true' + run: | + cd dashboard && pipenv install --deploy --dev + + - run: cd dashboard && pipenv run make stage + + - uses: actions/upload-artifact@v2 + with: + name: Dashboard_Transpiled + path: dashboard/dist + + publish: + # Only run on tags + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + name: Publish + needs: [make_dashboard] + + steps: + - uses: actions/download-artifact@v2 + with: + name: Dashboard_Transpiled + path: Dashboard_Transpiled/ + + - uses: papeloto/action-zip@v1 + with: + files: Dashboard_Transpiled/ + dest: Dashboard_Transpiled.zip + + - name: Upload Dashboard to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: "*.zip" + tag: ${{ github.ref }} + overwrite: true + prerelease: true + body: "Tidal Force Robotics, Automated with github ci/cd." + file_glob: true diff --git a/.gitignore b/.gitignore index 74acd7d6..9741c3a1 100644 --- a/.gitignore +++ b/.gitignore @@ -169,5 +169,13 @@ networktables.json # Add to tree but only when neccicary (adding a map or smthn) simgui-window.json +# =========== +# Dashboard +# =========== + +.parcel-cache/ +node_modules/ +dashboard.zip + # sysid ignores *.SysId diff --git a/dashboard/Makefile b/dashboard/Makefile new file mode 100644 index 00000000..06b28de5 --- /dev/null +++ b/dashboard/Makefile @@ -0,0 +1,32 @@ +# +# FRC 1721 Tidal Force +# 2023-2024 +# + +ROOT := $(PWD) +STAGEDIR := $(ROOT)/dist/ +DASH_HASH := $(shell git describe --tags --always) + +all: help +help: # List all commands and their descriptions + @echo + @cat Makefile | grep ': #' --color=never | sed '/^\t/d' | sed 's/: / /' | column -t -s '#' + @echo + +ready: # Run the necessary commands for development + pipenv install + npm ci +build: # Run `parcel build' and inject NetworkTables + npm run build + ./build.sh +run: # Run a live server of the dashboard + cd dist && pipenv run python -m pynetworktables2js +dev: # Automatically run `make build' whenever a file changes in src/ (requires program `entr') + find src/ | entr sh -c 'make build' +clean: # Run `git clean -fdX + git clean -fdX +stage: # Prepares dist/ for deployment + rm -rf dist/ + make build + cp entrypoint.sh $(STAGEDIR) + cp run.bat $(STAGEDIR) diff --git a/dashboard/Pipfile b/dashboard/Pipfile new file mode 100644 index 00000000..2a2de19d --- /dev/null +++ b/dashboard/Pipfile @@ -0,0 +1,12 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] +pynetworktables2js = {ref = "refs/pull/45/head", git = "git+https://github.com/robotpy/pynetworktables2js.git"} + +[dev-packages] + +[requires] +python_version = "3.11" diff --git a/dashboard/Pipfile.lock b/dashboard/Pipfile.lock new file mode 100644 index 00000000..91a509de --- /dev/null +++ b/dashboard/Pipfile.lock @@ -0,0 +1,93 @@ +{ + "_meta": { + "hash": { + "sha256": "175d87a73f9bf98c9711cbcce8e73b393aa4cdc894fe04d65ac01e9ef325d57a" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.11" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "cbor2": { + "hashes": [ + "sha256:1206180f66a9ad23e692cf457610c877f186ad303a1264b6c5335015b7bee83e", + "sha256:1a5770bdf4340de55679efe6c38fc6d64529fda547e7a85eb0217a82717a8235", + "sha256:37ba4f719384bd4ea317e92a8763ea343e205f3112c8241778fd9dbc64ae1498", + "sha256:39d94852dd61bda5b3d2bfe74e7b194a7199937d270f90099beec3e7584f0c9b", + "sha256:41f7501338228b27dac88c1197928cf8985f6fc775f59be89c6fdaddb4e69658", + "sha256:42155a20be46312fad2ceb85a408e2d90da059c2d36a65e0b99abca57c5357fd", + "sha256:425ae919120b9d05b4794b3e5faf6584fc47a9d61db059d4f00ce16ae93a3f63", + "sha256:4384a56afef0b908b61c8ea3cca3e257a316427ace3411308f51ee301b23adf9", + "sha256:4bb35f3b1ebd4b7b37628f0cd5c839f3008dec669194a2a4a33d91bab7f8663b", + "sha256:4bfa417dbb8b4581ad3c2312469899518596551cfb0fe5bdaf8a6921cff69d7e", + "sha256:4eae4d56314f22920a28bf7affefdfc918646877ce3b16220dc6cf38a584aa41", + "sha256:4ee46e6dbc8e2cf302a022fec513d57dba65e9d5ec495bcd1ad97a5dbdbab249", + "sha256:50019fea3cb07fa9b2b53772a52b4243e87de232591570c4c272b3ebdb419493", + "sha256:537da7bfee97ee44a11b300c034c18e674af6a5dc4718a6fba141037f099c7ec", + "sha256:559a0c1ec8dcedd6142b81727403e0f5a2e8f4c18e8bb3c548107ec39af4e9cb", + "sha256:5c511ff6356d6f4292ced856d5048a24ee61a85634816f29dadf1f089e8cb4f9", + "sha256:5c99fd8bbc6bbf3bf4d6b2996594ae633b778b27b0531559487950762c4e1e3f", + "sha256:60e7e0073291096605de27de3ce006148cf9a095199160439555f14f93d044d5", + "sha256:65532ba929beebe1c63317ad00c79d4936b60a5c29a3c329d2aa7df4e72ad907", + "sha256:67e2be461320197495fff55f250b111d4125a0a2d02e6256e41f8598adc3ad3f", + "sha256:6f3827ae14c009df9b37790f1da5cd1f9d64f7ffec472a49ebf865c0af6b77e9", + "sha256:93b949a66bec40dd0ca87a6d026136fea2cf1660120f921199a47ac8027af253", + "sha256:93d601ca92d917f769370a5e6c3ead62dca6451b2b603915e4fcf300083b9fcd", + "sha256:9e45d5aa8e484b4bf57240d8e7949389f1c9d4073758abb30954386321b55c9d", + "sha256:a11876abd50b9f70d114fcdbb0b5a3249ccd7d321465f0350028fd6d2317e114", + "sha256:a18be0af9241883bc67a036c1f33e3f9956d31337ccd412194bf759bc1095e03", + "sha256:b5d53826ad0c92fcb004b2a475896610b51e0ca010f6c37d762aae44ab0807b2", + "sha256:c85ab7697252af2240e939707c935ea18081ccb580d4b5b9a94b04148ab2c32b", + "sha256:c8cc64acc606b7f2a4b673a1d6cde5a9cb1860a6ce27b353e269c9535efbd62c", + "sha256:d6ab54a9282dd99a3a70d0f64706d3b3592e7920564a93101caa74dec322346c", + "sha256:dc77cac985f7f7a20f2d8b1957d1e79393d7df823f61c7c6173d3a0011c1d770", + "sha256:dca639c8ff81b9f0c92faf97324adfdbfb5c2a5bb97f249606c6f5b94c77cc0d", + "sha256:e3317e7dfb4f3180be90bcd853204558d89f119b624c2168153b53dea305e79d", + "sha256:efb81920d80410b8e80a4a6a8b06ec9b766be0ae7f3029af8ae4b30914edcfa3", + "sha256:f41e4a439f642954ed728dc18915098b5f2ebec7029eaebe52c06c52b6a9a63a", + "sha256:f9e192f461a9f8f6082df28c035b006d153904213dc8640bed8a72d72bbc9475", + "sha256:fd77c558decdba2a2a7a463e6346d53781d2163bacf205f77b999f561ba4ac73" + ], + "markers": "python_version >= '3.8'", + "version": "==5.5.1" + }, + "pynetworktables": { + "hashes": [ + "sha256:54604b1993515c43890be058263f158c1d168c69bedd802f0de644964cf3840d", + "sha256:91167948e66c29d5c90f85f3e249403f4d2ebf11368b93f9b968ef315388c73c" + ], + "markers": "python_version >= '3.5'", + "version": "==2021.0.0" + }, + "pynetworktables2js": { + "git": "git+https://github.com/robotpy/pynetworktables2js.git", + "ref": "d0313bc6b47f834379907f5b89f27e9a515e1766" + }, + "tornado": { + "hashes": [ + "sha256:02ccefc7d8211e5a7f9e8bc3f9e5b0ad6262ba2fbb683a6443ecc804e5224ce0", + "sha256:10aeaa8006333433da48dec9fe417877f8bcc21f48dda8d661ae79da357b2a63", + "sha256:27787de946a9cffd63ce5814c33f734c627a87072ec7eed71f7fc4417bb16263", + "sha256:6f8a6c77900f5ae93d8b4ae1196472d0ccc2775cc1dfdc9e7727889145c45052", + "sha256:71ddfc23a0e03ef2df1c1397d859868d158c8276a0603b96cf86892bff58149f", + "sha256:72291fa6e6bc84e626589f1c29d90a5a6d593ef5ae68052ee2ef000dfd273dee", + "sha256:88b84956273fbd73420e6d4b8d5ccbe913c65d31351b4c004ae362eba06e1f78", + "sha256:e43bc2e5370a6a8e413e1e1cd0c91bedc5bd62a74a532371042a18ef19e10579", + "sha256:f0251554cdd50b4b44362f73ad5ba7126fc5b2c2895cc62b14a1c2d7ea32f212", + "sha256:f7894c581ecdcf91666a0912f18ce5e757213999e183ebfc2c3fdbf4d5bd764e", + "sha256:fd03192e287fbd0899dd8f81c6fb9cbbc69194d2074b38f384cb6fa72b80e9c2" + ], + "markers": "python_version >= '3.8'", + "version": "==6.4" + } + }, + "develop": {} +} diff --git a/dashboard/README.md b/dashboard/README.md new file mode 100644 index 00000000..96732bc8 --- /dev/null +++ b/dashboard/README.md @@ -0,0 +1,33 @@ +# FRC 1721 Dashboard +## Getting Started +- Make sure you have sed installed +- Make sure Robot sim is running +- Make sure npm is installed + +Make sure you are in the dashboard/ folder. + +Install deps + +``` sh +npm ci +``` + +Build webpage + +``` sh +make build +``` + +(NOT REQUIRED) You can build automatically when a file changes in src/ (requires 'entr', `paru -S entr` `paman install entr`) + +``` sh +make dev +``` + +Run webpage + +``` sh +make run +``` + +`make run` can be left running when you run `make build`, and doesn't need to be run again to update the webpage diff --git a/dashboard/build.sh b/dashboard/build.sh new file mode 100755 index 00000000..e0289bdf --- /dev/null +++ b/dashboard/build.sh @@ -0,0 +1,12 @@ +sed -i -e 's/
<\/p>/ + +
+ + + + + +