From a871ea6d69a755cd0efb5a4ed30906cf0ae37eb6 Mon Sep 17 00:00:00 2001 From: Keavon Chambers Date: Wed, 16 Aug 2023 00:35:06 -0700 Subject: [PATCH] Add auto deployment infrastructure for website --- .github/workflows/ci.yml | 159 +++++++++--------- .github/workflows/deploy.yml | 75 +++++---- .github/workflows/website.yml | 94 +++++++++++ .prettierrc | 15 ++ .vscode/settings.json | 12 +- ...buted-computing-in-the-graphene-runtime.md | 2 +- .../other/bezier-rs-demos/webpack.config.js | 2 +- website/other/build.sh | 22 ++- website/templates/base.html | 2 +- 9 files changed, 247 insertions(+), 136 deletions(-) create mode 100644 .github/workflows/website.yml create mode 100644 .prettierrc diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a353e50d6..921ee9a42 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,12 +1,12 @@ -name: Continuous Integration +name: "Editor: CI & Dev" on: push: branches: - - master + - master pull_request: branches: - - master + - master env: CARGO_TERM_COLOR: always INDEX_HTML_HEAD_REPLACEMENT: @@ -24,102 +24,95 @@ jobs: SCCACHE_DIR: /var/lib/github-actions/.cache steps: - - uses: actions/checkout@v3 + - name: ๐Ÿ“ฅ Clone and checkout repository + uses: actions/checkout@v3 - - name: ๐Ÿ”ง Clear wasm-bindgen cache - run: rm -r ~/.cache/.wasm-pack + - name: ๐Ÿ—‘ Clear wasm-bindgen cache + run: rm -r ~/.cache/.wasm-pack - - name: ๐Ÿ”ง Set up Node - uses: actions/setup-node@v3 - with: - node-version: '16' + - name: ๐ŸŸข Set up Node + uses: actions/setup-node@v3 + with: + node-version: "16" - - name: ๐Ÿšง Install Node dependencies - run: | - cd frontend - npm ci + - name: ๐Ÿšง Install Node dependencies + run: | + cd frontend + npm ci - - name: ๐Ÿ”ผ Update Rust to latest stable - run: | - rustc --version - rustup update stable - rustc --version + - name: ๐Ÿฆ€ Update Rust to latest stable + run: | + rustc --version + rustup update stable + rustc --version - - name: Replace template in 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|" frontend/index.html + - name: โœ‚ Replace template in 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|" frontend/index.html - - name: ๐ŸŒ Build Graphite web code - env: - NODE_ENV: production - run: | - cd frontend - mold -run npm run build + - name: ๐ŸŒ Build Graphite web code + env: + NODE_ENV: production + run: | + cd frontend + mold -run npm run build - - name: Publish - id: cloudflare - uses: cloudflare/pages-action@1 - continue-on-error: true - with: - apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} - accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - projectName: graphite-dev - directory: frontend/dist - gitHubToken: ${{ secrets.GITHUB_TOKEN }} + - 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-dev + directory: frontend/dist + gitHubToken: ${{ secrets.GITHUB_TOKEN }} - - name: ๐Ÿ‘• Lint Graphite web formatting - env: - NODE_ENV: production - run: | - cd frontend - # npm run lint - echo "๐Ÿ’ฅ Frontend linting is temporarily disabled until it can be set up again with Svelte ๐Ÿ’ฅ" + - name: ๐Ÿ‘• Lint Graphite web formatting + env: + NODE_ENV: production + run: | + cd frontend + # npm run lint + echo "๐Ÿ’ฅ Frontend linting is temporarily disabled until it can be set up again with Svelte ๐Ÿ’ฅ" - - name: ๐Ÿ”ฌ Check Rust formatting - run: | - mold -run cargo fmt --all -- --check + - name: ๐Ÿ”ฌ Check Rust formatting + run: | + mold -run cargo fmt --all -- --check - - name: ๐Ÿฆ€ Build Rust code - run: | - mold -run cargo build + - name: ๐Ÿฆ€ Build Rust code + run: | + mold -run cargo build - - name: ๐Ÿงช Run Rust tests - run: | - mold -run cargo nextest run + - name: ๐Ÿงช Run Rust tests + run: | + mold -run cargo nextest run - #miri: - # runs-on: self-hosted - # - # steps: - # - uses: actions/checkout@v3 - # - # - name: ๐Ÿงช Run Rust miri - # run: | - # mold -run cargo +nightly miri nextest run -j32 + # miri: + # runs-on: self-hosted + + # steps: + # - uses: actions/checkout@v3 + + # - name: ๐Ÿงช Run Rust miri + # run: | + # mold -run cargo +nightly miri nextest run -j32 cargo-deny: 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: - - uses: actions/checkout@v3 + - name: ๐Ÿ“ฅ Clone and checkout repository + uses: actions/checkout@v3 - - uses: EmbarkStudios/cargo-deny-action@v1 - if: matrix.checks == 'crate security advisories' - with: - command: check advisories + - name: ๐Ÿ”’ Check crate security advisories + uses: EmbarkStudios/cargo-deny-action@v1 + with: + command: check advisories - - uses: EmbarkStudios/cargo-deny-action@v1 - if: matrix.checks == 'crate license compatibility' - with: - command: check bans licenses sources + - name: ๐Ÿ“œ Check crate license compatibility + uses: EmbarkStudios/cargo-deny-action@v1 + with: + command: check bans licenses sources diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 89860ce23..e12753d3c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,9 +1,9 @@ -name: Deploy release +name: "Editor: Production (Latest Stable)" on: push: tags: - - 'latest-stable' + - "latest-stable" env: CARGO_TERM_COLOR: always @@ -21,45 +21,46 @@ jobs: INDEX_HTML_HEAD_REPLACEMENT: steps: - - uses: actions/checkout@v3 + - name: ๐Ÿ“ฅ Clone and checkout repository + uses: actions/checkout@v3 - - name: ๐Ÿ”ง Clear wasm-bindgen cache - run: rm -r ~/.cache/.wasm-pack + - name: ๐Ÿ—‘ Clear wasm-bindgen cache + run: rm -r ~/.cache/.wasm-pack - - name: ๐Ÿ”ง Set up Node - uses: actions/setup-node@v3 - with: - node-version: '16' + - name: ๐ŸŸข Set up Node + uses: actions/setup-node@v3 + with: + node-version: "16" - - name: ๐Ÿšง Install Node dependencies - run: | - cd frontend - npm ci + - name: ๐Ÿšง Install Node dependencies + run: | + cd frontend + npm ci - - name: ๐Ÿ”ผ Update Rust to latest stable - run: | - rustc --version - rustup update stable - rustc --version + - name: ๐Ÿฆ€ Update Rust to latest stable + run: | + rustc --version + rustup update stable + rustc --version - - name: Replace template in of index.html - run: | - sed -i "s||$INDEX_HTML_HEAD_REPLACEMENT|" frontend/index.html + - name: โœ‚ Replace template in of index.html + run: | + sed -i "s||$INDEX_HTML_HEAD_REPLACEMENT|" frontend/index.html - - name: ๐ŸŒ Build Graphite web code - env: - NODE_ENV: production - run: | - cd frontend - mold -run npm run build + - name: ๐ŸŒ Build Graphite web code + env: + NODE_ENV: production + run: | + cd frontend + mold -run npm run build - - name: Publish - id: cloudflare - uses: cloudflare/pages-action@1 - with: - apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} - accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - projectName: graphite-editor - directory: frontend/dist - branch: master - gitHubToken: ${{ secrets.GITHUB_TOKEN }} + - name: ๐Ÿ“ค Publish to Cloudflare Pages + id: cloudflare + uses: cloudflare/pages-action@1 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + projectName: graphite-editor + directory: frontend/dist + branch: master + gitHubToken: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml new file mode 100644 index 000000000..298f33dfd --- /dev/null +++ b/.github/workflows/website.yml @@ -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: + +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 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|" 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 }} diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 000000000..54721570f --- /dev/null +++ b/.prettierrc @@ -0,0 +1,15 @@ +{ + "singleQuote": false, + "useTabs": true, + "tabWidth": 4, + "printWidth": 200, + "overrides": [ + { + "files": ["*.yml", "*.yaml"], + "options": { + "useTabs": false, + "tabWidth": 2 + } + } + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 7d78a43d8..1da69fa97 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -18,6 +18,12 @@ "source.fixAll.eslint": 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" }, // Handlebars: don't save on format @@ -37,9 +43,5 @@ // VS Code config "html.format.wrapLineLength": 200, "files.eol": "\n", - "files.insertFinalNewline": true, - "prettier.singleQuote": false, - "prettier.useTabs": true, - "prettier.tabWidth": 4, - "prettier.printWidth": 200 + "files.insertFinalNewline": true } diff --git a/website/content/blog/2022-05-12-distributed-computing-in-the-graphene-runtime.md b/website/content/blog/2022-05-12-distributed-computing-in-the-graphene-runtime.md index a06480001..c1523a00e 100644 --- a/website/content/blog/2022-05-12-distributed-computing-in-the-graphene-runtime.md +++ b/website/content/blog/2022-05-12-distributed-computing-in-the-graphene-runtime.md @@ -77,6 +77,6 @@ Graphene should recognize when a certain intermediate result already lives in RA # 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! diff --git a/website/other/bezier-rs-demos/webpack.config.js b/website/other/bezier-rs-demos/webpack.config.js index f42bfdd04..019e9c37b 100644 --- a/website/other/bezier-rs-demos/webpack.config.js +++ b/website/other/bezier-rs-demos/webpack.config.js @@ -18,7 +18,7 @@ module.exports = { }, output: { path: path.resolve(__dirname, "public/build"), - publicPath: "/build/", + publicPath: "./build/", filename: "[name].js" }, module: { diff --git a/website/other/build.sh b/website/other/build.sh index f3ca49e82..19df86f05 100644 --- a/website/other/build.sh +++ b/website/other/build.sh @@ -1,21 +1,27 @@ #!/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 export PATH=$PATH:/opt/buildhome/.cargo/bin +rustup update stable echo rustc version: rustc --version -echo ๐Ÿšง Install Node dependencies +echo ๐Ÿšง Print installed node and npm versions echo node version: node --version echo 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 npm ci - -echo ๐Ÿ‘ท Build Bezier-rs Demos -export NODE_ENV=production -npm run build-prod-unix -mkdir ../../public/libraries -mv public ../../public/libraries/bezier-rs +NODE_ENV=production npm run build-prod-unix +mv public/* ../dist/libraries/bezier-rs +cd .. diff --git a/website/templates/base.html b/website/templates/base.html index b094eefbd..d5682dc75 100644 --- a/website/templates/base.html +++ b/website/templates/base.html @@ -27,7 +27,7 @@ {% endif %} - +