Skip to content

Commit

Permalink
Merge branch 'main' into locale
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbastian committed Aug 30, 2022
2 parents e7e337f + 9e95b1d commit 3dd89f5
Show file tree
Hide file tree
Showing 2,602 changed files with 1,596,381 additions and 415,870 deletions.
111 changes: 111 additions & 0 deletions .github/workflows/artifacts-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,114 @@ jobs:
echo "::group::📖 Docs Preview"
echo "http://${{ env.GCP_BUCKET_ID }}.storage.googleapis.com/gha/${{ github.sha }}/docs/icu/index.html"
echo "::endgroup::"
webpack:
name: WASM Demo
needs: credentials
runs-on: "ubuntu-latest"
env:
GCP_PROJECT_ID: "dev-infra-273822"
GCP_BUCKET_ID: "icu4x-pr-artifacts"
steps:
- uses: actions/checkout@v2

- name: Load the default Rust toolchain via the rust-toolchain file.
run: rustup show

- name: Install prerequisites for wasm build
run: |
rustup toolchain list
rustup toolchain install nightly-2022-04-05
rustup component add --toolchain nightly-2022-04-05 rust-src
- name: Authenticate to Google Cloud
uses: google-github-actions/setup-gcloud@v0.2
with:
project_id: ${{ env.GCP_PROJECT_ID }}
service_account_key: ${{ secrets.ICU4X_GCP_SA_KEY }}
export_default_credentials: true

- name: Get cargo-make version
id: cargo-make-version
run: |
echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make =' | md5sum)"
shell: bash

- name: Attempt to load cached cargo-make
uses: actions/cache@v2
id: cargo-make-cache
with:
path: |
~/.cargo/bin/cargo-make
~/.cargo/bin/cargo-make.exe
key: ${{ runner.os }}-make-${{ steps.cargo-make-version.outputs.hash }}

- name: Install cargo-make
if: steps.cargo-make-cache.outputs.cache-hit != 'true'
uses: actions-rs/install@v0.1.2
with:
crate: cargo-make
version: latest

- name: Run Webpack
uses: actions-rs/cargo@v1
with:
command: make
args: diplomat-build-webpack-demo

- name: Put index.html in dist for temp URL
run: |
cp ffi/diplomat/wasm/wasm-demo/index.html ffi/diplomat/wasm/wasm-demo/dist/index.html
printf "const gcs=document.createElement('script');gcs.setAttribute('src','./bundle.js');document.body.appendChild(gcs);" > ffi/diplomat/wasm/wasm-demo/dist/index.js
- name: Upload Webpack bundle to Google Cloud Storage
run: |
# gsutil cors set ffi/diplomat/wasm/cors-config-file.json gs://${{ env.GCP_BUCKET_ID }}
gsutil -m cp -r ffi/diplomat/wasm/wasm-demo/dist/ gs://${{ env.GCP_BUCKET_ID }}/gha/${{ github.sha }}/wasm-demo
- name: "⭐⭐⭐ Links to Uploaded Artifacts ⭐⭐⭐"
run: |
echo "::group::Wasm Demo Preview"
echo "https://storage.googleapis.com/icu4x-pr-artifacts/gha/${{ github.sha }}/wasm-demo/index.html"
echo "::endgroup::"
# TODO(qnnokabayashi): This was my attempt to get it to copy the HTML to
# the `gh-pages` branch. As of 8/1/2022, idea is that
# `ffi/diplomat/wasm/wasm-demo/index.html` contains the structure for
# the demo. It needs to call into the Webpacked JavaScript. When testing
# locally, this content is in `ffi/diplomat/wasm/wasm-demo/dist/`, but
# when deployed, it lives in Google Cloud Storage. But we don't want to
# be editing this arbitrarily complex HTML file in CI. The solution was
# to have it call a very simple `index.js` file which modifies the HTML
# and tells it where to get the script from. Locally, this lives next to
# `index.html` at `ffi/diplomat/wasm/wasm-demo/index.js`, and contains
# the following:
# ```js
# const gcs = document.createElement('script');
# gcs.setAttribute('src', './dist/bundle.js');
# document.body.appendChild(gcs);
# ```
# The plan was to rewrite this file in CI to point into GCS instead of
# `./dist/bundle.js`, and then commit and push the original `index.html`
# and this new `index.js` to the `gh-pages` branch. That way, when a
# browser visited the Github page, `index.html` would read `index.js`,
# which would then point the browser to get `bundle.js` from GCS.
#
# This was my attempt to make that work, but I couldn't quite figure out
# how to push to `gh-pages`.
#
# - name: Store index.html
# run: |
# cp ffi/diplomat/wasm/wasm-demo/index.html /tmp/wasm-demo-index.html
# - name: Checkout gh-pages
# uses: actions/checkout@v2
# with:
# ref: gh-pages
# - name: Retrieve index.html
# run: |
# rm -rf wasm-demo-app
# mkdir wasm-demo-app
# printf "const gcs=document.createElement('script');gcs.setAttribute('src','https://storage.googleapis.com/icu4x-pr-artifacts/gha/%s/wasm-demo/bundle.js');document.body.appendChild(gcs);" ${{ github.sha }} > wasm-demo-app/index.js
# cp /tmp/wasm-demo-index.html wasm-demo-app/index.html
# git diff-index --quiet HEAD || git commit -m "add wasm demo for ${{ github.sha }}"
# git push
3 changes: 3 additions & 0 deletions .github/workflows/artifacts-info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ jobs:
echo "The link will be available after the following job completes:"
echo "${{ github.event.pull_request.head.repo.html_url }}/actions/workflows/artifacts-build.yml"
echo "::endgroup::"
echo "::group::Wasm Demo Preview"
echo "http://${{ env.GCP_BUCKET_ID }}.storage.googleapis.com/gha/${{ github.event.pull_request.head.sha }}/wasm-demo/index.html"
echo "::endgroup::"
Loading

0 comments on commit 3dd89f5

Please sign in to comment.