Add auto deployment infrastructure for website

This commit is contained in:
Keavon Chambers 2023-08-16 00:35:06 -07:00
parent 0a7a69b315
commit a871ea6d69
9 changed files with 247 additions and 136 deletions

View File

@ -1,12 +1,12 @@
name: Continuous Integration name: "Editor: CI & Dev"
on: on:
push: push:
branches: branches:
- master - master
pull_request: pull_request:
branches: branches:
- master - master
env: env:
CARGO_TERM_COLOR: always CARGO_TERM_COLOR: always
INDEX_HTML_HEAD_REPLACEMENT: <script defer data-domain="dev.graphite.rs" data-api="https://graphite.rs/visit/event" src="https://graphite.rs/visit/script.outbound-links.file-downloads.js"></script> INDEX_HTML_HEAD_REPLACEMENT: <script defer data-domain="dev.graphite.rs" data-api="https://graphite.rs/visit/event" src="https://graphite.rs/visit/script.outbound-links.file-downloads.js"></script>
@ -24,102 +24,95 @@ jobs:
SCCACHE_DIR: /var/lib/github-actions/.cache SCCACHE_DIR: /var/lib/github-actions/.cache
steps: steps:
- uses: actions/checkout@v3 - name: 📥 Clone and checkout repository
uses: actions/checkout@v3
- name: 🔧 Clear wasm-bindgen cache - name: 🗑 Clear wasm-bindgen cache
run: rm -r ~/.cache/.wasm-pack run: rm -r ~/.cache/.wasm-pack
- name: 🔧 Set up Node - name: 🟢 Set up Node
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: '16' node-version: "16"
- name: 🚧 Install Node dependencies - name: 🚧 Install Node dependencies
run: | run: |
cd frontend cd frontend
npm ci npm ci
- name: 🔼 Update Rust to latest stable - name: 🦀 Update Rust to latest stable
run: | run: |
rustc --version rustc --version
rustup update stable rustup update stable
rustc --version rustc --version
- name: Replace template in <head> of index.html - name: Replace template in <head> of index.html
run: | run: |
# Remove the INDEX_HTML_HEAD_REPLACEMENT environment variable for build links (not master deploys) # Remove the INDEX_HTML_HEAD_REPLACEMENT environment variable for build links (not master deploys)
git rev-parse --abbrev-ref HEAD | grep master > /dev/null || export INDEX_HTML_HEAD_REPLACEMENT="" git rev-parse --abbrev-ref HEAD | grep master > /dev/null || export INDEX_HTML_HEAD_REPLACEMENT=""
sed -i "s|<!-- INDEX_HTML_HEAD_REPLACEMENT -->|$INDEX_HTML_HEAD_REPLACEMENT|" frontend/index.html sed -i "s|<!-- INDEX_HTML_HEAD_REPLACEMENT -->|$INDEX_HTML_HEAD_REPLACEMENT|" frontend/index.html
- name: 🌐 Build Graphite web code - name: 🌐 Build Graphite web code
env: env:
NODE_ENV: production NODE_ENV: production
run: | run: |
cd frontend cd frontend
mold -run npm run build mold -run npm run build
- name: Publish - name: 📤 Publish to Cloudflare Pages
id: cloudflare id: cloudflare
uses: cloudflare/pages-action@1 uses: cloudflare/pages-action@1
continue-on-error: true continue-on-error: true
with: with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: graphite-dev projectName: graphite-dev
directory: frontend/dist directory: frontend/dist
gitHubToken: ${{ secrets.GITHUB_TOKEN }} gitHubToken: ${{ secrets.GITHUB_TOKEN }}
- name: 👕 Lint Graphite web formatting - name: 👕 Lint Graphite web formatting
env: env:
NODE_ENV: production NODE_ENV: production
run: | run: |
cd frontend cd frontend
# npm run lint # npm run lint
echo "💥 Frontend linting is temporarily disabled until it can be set up again with Svelte 💥" echo "💥 Frontend linting is temporarily disabled until it can be set up again with Svelte 💥"
- name: 🔬 Check Rust formatting - name: 🔬 Check Rust formatting
run: | run: |
mold -run cargo fmt --all -- --check mold -run cargo fmt --all -- --check
- name: 🦀 Build Rust code - name: 🦀 Build Rust code
run: | run: |
mold -run cargo build mold -run cargo build
- name: 🧪 Run Rust tests - name: 🧪 Run Rust tests
run: | run: |
mold -run cargo nextest run mold -run cargo nextest run
#miri: # miri:
# runs-on: self-hosted # runs-on: self-hosted
#
# steps: # steps:
# - uses: actions/checkout@v3 # - uses: actions/checkout@v3
#
# - name: 🧪 Run Rust miri # - name: 🧪 Run Rust miri
# run: | # run: |
# mold -run cargo +nightly miri nextest run -j32 # mold -run cargo +nightly miri nextest run -j32
cargo-deny: cargo-deny:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
matrix:
checks:
- 'crate security advisories'
- 'crate license compatibility'
# Prevent sudden announcement of a new advisory from failing ci:
continue-on-error: ${{ matrix.checks == 'crate security advisories' }}
steps: steps:
- uses: actions/checkout@v3 - name: 📥 Clone and checkout repository
uses: actions/checkout@v3
- uses: EmbarkStudios/cargo-deny-action@v1 - name: 🔒 Check crate security advisories
if: matrix.checks == 'crate security advisories' uses: EmbarkStudios/cargo-deny-action@v1
with: with:
command: check advisories command: check advisories
- uses: EmbarkStudios/cargo-deny-action@v1 - name: 📜 Check crate license compatibility
if: matrix.checks == 'crate license compatibility' uses: EmbarkStudios/cargo-deny-action@v1
with: with:
command: check bans licenses sources command: check bans licenses sources

View File

@ -1,9 +1,9 @@
name: Deploy release name: "Editor: Production (Latest Stable)"
on: on:
push: push:
tags: tags:
- 'latest-stable' - "latest-stable"
env: env:
CARGO_TERM_COLOR: always CARGO_TERM_COLOR: always
@ -21,45 +21,46 @@ jobs:
INDEX_HTML_HEAD_REPLACEMENT: <script defer data-domain="editor.graphite.rs" data-api="https://graphite.rs/visit/event" src="https://graphite.rs/visit/script.outbound-links.file-downloads.js"></script> INDEX_HTML_HEAD_REPLACEMENT: <script defer data-domain="editor.graphite.rs" data-api="https://graphite.rs/visit/event" src="https://graphite.rs/visit/script.outbound-links.file-downloads.js"></script>
steps: steps:
- uses: actions/checkout@v3 - name: 📥 Clone and checkout repository
uses: actions/checkout@v3
- name: 🔧 Clear wasm-bindgen cache - name: 🗑 Clear wasm-bindgen cache
run: rm -r ~/.cache/.wasm-pack run: rm -r ~/.cache/.wasm-pack
- name: 🔧 Set up Node - name: 🟢 Set up Node
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: '16' node-version: "16"
- name: 🚧 Install Node dependencies - name: 🚧 Install Node dependencies
run: | run: |
cd frontend cd frontend
npm ci npm ci
- name: 🔼 Update Rust to latest stable - name: 🦀 Update Rust to latest stable
run: | run: |
rustc --version rustc --version
rustup update stable rustup update stable
rustc --version rustc --version
- name: Replace template in <head> of index.html - name: Replace template in <head> of index.html
run: | run: |
sed -i "s|<!-- INDEX_HTML_HEAD_REPLACEMENT -->|$INDEX_HTML_HEAD_REPLACEMENT|" frontend/index.html sed -i "s|<!-- INDEX_HTML_HEAD_REPLACEMENT -->|$INDEX_HTML_HEAD_REPLACEMENT|" frontend/index.html
- name: 🌐 Build Graphite web code - name: 🌐 Build Graphite web code
env: env:
NODE_ENV: production NODE_ENV: production
run: | run: |
cd frontend cd frontend
mold -run npm run build mold -run npm run build
- name: Publish - name: 📤 Publish to Cloudflare Pages
id: cloudflare id: cloudflare
uses: cloudflare/pages-action@1 uses: cloudflare/pages-action@1
with: with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: graphite-editor projectName: graphite-editor
directory: frontend/dist directory: frontend/dist
branch: master branch: master
gitHubToken: ${{ secrets.GITHUB_TOKEN }} gitHubToken: ${{ secrets.GITHUB_TOKEN }}

94
.github/workflows/website.yml vendored Normal file
View File

@ -0,0 +1,94 @@
name: "Website"
on:
push:
branches:
- master
paths:
- website/**
pull_request:
branches:
- master
paths:
- website/**
env:
CARGO_TERM_COLOR: always
INDEX_HTML_HEAD_REPLACEMENT: <script defer data-domain="graphite.rs" data-api="/visit/event" src="/visit/script.outbound-links.file-downloads.js"></script>
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
pull-requests: write
steps:
- name: 📥 Clone and checkout repository
uses: actions/checkout@v3
- name: 🕸 Install Zola
uses: taiki-e/install-action@v2
with:
tool: zola@0.17.2
- name: ✂ Replace template in <head> of index.html
run: |
# Remove the INDEX_HTML_HEAD_REPLACEMENT environment variable for build links (not master deploys)
git rev-parse --abbrev-ref HEAD | grep master > /dev/null || export INDEX_HTML_HEAD_REPLACEMENT=""
sed -i "s|<!-- INDEX_HTML_HEAD_REPLACEMENT -->|$INDEX_HTML_HEAD_REPLACEMENT|" website/templates/base.html
- name: 🌐 Build Graphite website with Zola
run: |
cd website
zola build
- name: 🔍 Check if `website/other` directory changed
uses: dorny/paths-filter@v2
id: changes
with:
filters: |
other:
- "website/other/**"
- name: 💿 Restore cache of `website/other/dist` directory, if available and `website/other` didn't change
if: steps.changes.outputs.other != 'true'
id: cache-website-other-dist
uses: actions/cache/restore@v3
with:
path: website/other/dist
key: website-other-dist-${{ runner.os }}
- name: 🟢 Set up Node only if we are going to build in the next step
if: steps.cache-website-other-dist.outputs.cache-hit != 'true'
uses: actions/setup-node@v3
with:
node-version: "16"
- name: 📁 Build `website/other` directory only if changed or not cached
if: steps.cache-website-other-dist.outputs.cache-hit != 'true'
id: build-website-other
run: |
sh website/other/build.sh
- name: 💾 Save cache of `website/other/dist` directory if it was built above
if: steps.cache-website-other-dist.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: website/other/dist
key: ${{ steps.cache-website-other-dist.outputs.cache-primary-key }}
- name: 🚚 Move `website/other/dist` contents to `website/public`
run: |
mv website/other/dist/* website/public
- name: 📤 Publish to Cloudflare Pages
id: cloudflare
uses: cloudflare/pages-action@1
continue-on-error: true
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: graphite-website
directory: website/public
gitHubToken: ${{ secrets.GITHUB_TOKEN }}

15
.prettierrc Normal file
View File

@ -0,0 +1,15 @@
{
"singleQuote": false,
"useTabs": true,
"tabWidth": 4,
"printWidth": 200,
"overrides": [
{
"files": ["*.yml", "*.yaml"],
"options": {
"useTabs": false,
"tabWidth": 2
}
}
]
}

12
.vscode/settings.json vendored
View File

@ -18,6 +18,12 @@
"source.fixAll.eslint": true "source.fixAll.eslint": true
}, },
"editor.formatOnSave": true, "editor.formatOnSave": true,
// Configured in `.prettierrc`
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[yaml][github-actions-workflow]": {
"editor.formatOnSave": true,
// Configured in `.prettierrc`
"editor.defaultFormatter": "esbenp.prettier-vscode" "editor.defaultFormatter": "esbenp.prettier-vscode"
}, },
// Handlebars: don't save on format // Handlebars: don't save on format
@ -37,9 +43,5 @@
// VS Code config // VS Code config
"html.format.wrapLineLength": 200, "html.format.wrapLineLength": 200,
"files.eol": "\n", "files.eol": "\n",
"files.insertFinalNewline": true, "files.insertFinalNewline": true
"prettier.singleQuote": false,
"prettier.useTabs": true,
"prettier.tabWidth": 4,
"prettier.printWidth": 200
} }

View File

@ -77,6 +77,6 @@ Graphene should recognize when a certain intermediate result already lives in RA
# Conclusion # Conclusion
Presently, we are [experimenting](https://github.com/GraphiteEditor/NodeGraphExperiments) with CPU and GPU node composition for the beginnings of the Graphene visual programming language. Most of what was described in this post will likely evolve as we get further into the implementation stage and when we learn more from experts in the fields of computer science that Graphene overlaps with. Presently, we are experimenting with CPU and GPU node composition for the beginnings of the Graphene visual programming language. Most of what was described in this post will likely evolve as we get further into the implementation stage and when we learn more from experts in the fields of computer science that Graphene overlaps with.
If you have a background or interest in programming language design, functional programming, ECS and data-oriented design, scheduling, distributed computing, general-purpose GPU compute (GPGPU), or high-performance computing (HPC), we'd love to have your ideas steer our work. Or better yet, join the team to make this dream a reality. We discuss most of our architecture and designs on our [Discord server](https://discord.graphite.rs) through text and sometimes voice. Please come say hi! If you have a background or interest in programming language design, functional programming, ECS and data-oriented design, scheduling, distributed computing, general-purpose GPU compute (GPGPU), or high-performance computing (HPC), we'd love to have your ideas steer our work. Or better yet, join the team to make this dream a reality. We discuss most of our architecture and designs on our [Discord server](https://discord.graphite.rs) through text and sometimes voice. Please come say hi!

View File

@ -18,7 +18,7 @@ module.exports = {
}, },
output: { output: {
path: path.resolve(__dirname, "public/build"), path: path.resolve(__dirname, "public/build"),
publicPath: "/build/", publicPath: "./build/",
filename: "[name].js" filename: "[name].js"
}, },
module: { module: {

View File

@ -1,21 +1,27 @@
#!/bin/sh #!/bin/sh
echo 🔧 Install Rust echo 📁 Create output directory in 'website/other/dist'
cd website/other
mkdir dist
echo 🔧 Install the latest Rust
curl https://sh.rustup.rs -sSf | sh -s -- -y curl https://sh.rustup.rs -sSf | sh -s -- -y
export PATH=$PATH:/opt/buildhome/.cargo/bin export PATH=$PATH:/opt/buildhome/.cargo/bin
rustup update stable
echo rustc version: echo rustc version:
rustc --version rustc --version
echo 🚧 Install Node dependencies echo 🚧 Print installed node and npm versions
echo node version: echo node version:
node --version node --version
echo npm version: echo npm version:
npm --version npm --version
echo 👷 Build Bezier-rs demos to 'website/other/dist/libraries/bezier-rs'
mkdir dist/libraries
mkdir dist/libraries/bezier-rs
cd bezier-rs-demos cd bezier-rs-demos
npm ci npm ci
NODE_ENV=production npm run build-prod-unix
echo 👷 Build Bezier-rs Demos mv public/* ../dist/libraries/bezier-rs
export NODE_ENV=production cd ..
npm run build-prod-unix
mkdir ../../public/libraries
mv public ../../public/libraries/bezier-rs

View File

@ -27,7 +27,7 @@
{% endif %} {% endif %}
<script src="/js/text-justification.js"></script> <script src="/js/text-justification.js"></script>
<script src="/js/navbar.js"></script> <script src="/js/navbar.js"></script>
<script defer data-domain="graphite.rs" data-api="/visit/event" src="/visit/script.outbound-links.file-downloads.js"></script> <!-- INDEX_HTML_HEAD_REPLACEMENT -->
<style> <style>
.balance-text { .balance-text {
visibility: hidden; visibility: hidden;