Improve Designer Performance #810
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Rust Build and Deploy | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master", "dev" ] | |
env: | |
CARGO_TERM_COLOR: always | |
RUSTC_WRAPPER: "sccache" | |
CARGO_INCREMENTAL: "0" | |
SCCACHE_DIR: "/home/runner/.cache/sccache" | |
SCCACHE_CACHE_SIZE: "1G" | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
permissions: write-all | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install sccache | |
run: | | |
SCCACHE_VERSION=v0.5.4 | |
curl -L "https://github.com/mozilla/sccache/releases/download/${SCCACHE_VERSION}/sccache-${SCCACHE_VERSION}-x86_64-unknown-linux-musl.tar.gz" | tar xz | |
sudo mv sccache-*/sccache /usr/local/bin/sccache | |
sccache --version | |
# Cache sccache and Rust dependencies | |
- name: Cache sccache and Cargo | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/sccache | |
~/.cargo/registry | |
~/.cargo/git | |
key: ${{ runner.os }}-sccache-cargo-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-sccache-cargo- | |
# Cache wasm-pack | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.cargo/bin/wasm-pack | |
key: ${{ runner.os }}-wasm-pack | |
- name: Install system dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libgtk-4-dev libpango1.0-dev libcairo2-dev libharfbuzz-dev | |
# Install dependencies | |
- name: Install dependencies | |
run: | | |
if ! command -v wasm-pack &> /dev/null; then | |
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
fi | |
# Cache Pax build artifacts | |
- uses: actions/cache@v4 | |
if: ${{ github.event_name == 'pull_request' && (github.event.pull_request.author_association == 'COLLABORATOR' || github.event.pull_request.author_association == 'OWNER' || github.event.pull_request.author_association == 'MEMBER') }} | |
with: | |
path: examples/src/increment/.pax/build | |
key: ${{ runner.os }}-pax-build-${{ hashFiles('examples/src/increment/**') }} | |
- name: Build Increment example | |
if: ${{ github.event_name == 'pull_request' && (github.event.pull_request.author_association == 'COLLABORATOR' || github.event.pull_request.author_association == 'OWNER' || github.event.pull_request.author_association == 'MEMBER') }} | |
env: | |
RUSTFLAGS: "-C debuginfo=0" | |
run: | | |
pushd examples/src/increment | |
sccache --start-server | |
./pax build --release --designer | |
sccache --show-stats | |
popd | |
- name: Configure AWS Credentials | |
if: ${{ github.event_name == 'pull_request' && (github.event.pull_request.author_association == 'COLLABORATOR' || github.event.pull_request.author_association == 'OWNER' || github.event.pull_request.author_association == 'MEMBER') }} | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-east-1 | |
- name: Deploy to S3 | |
if: ${{ github.event_name == 'pull_request' && (github.event.pull_request.author_association == 'COLLABORATOR' || github.event.pull_request.author_association == 'OWNER' || github.event.pull_request.author_association == 'MEMBER') }} | |
run: | | |
BUCKET_NAME="staging.pax.dev/build/${{ github.event.pull_request.number }}" | |
aws s3 cp --recursive /home/runner/work/pax/pax/examples/src/increment/.pax/build/release/web s3://$BUCKET_NAME --acl public-read | |
- name: Invalidate CloudFront | |
if: ${{ github.event_name == 'pull_request' && (github.event.pull_request.author_association == 'COLLABORATOR' || github.event.pull_request.author_association == 'OWNER' || github.event.pull_request.author_association == 'MEMBER') }} | |
run: | | |
aws cloudfront create-invalidation --distribution-id E29ZMWF6F0HQ61 --paths "/*" | |
- name: Post deployment link as PR comment | |
if: ${{ github.event_name == 'pull_request' && (github.event.pull_request.author_association == 'COLLABORATOR' || github.event.pull_request.author_association == 'OWNER' || github.event.pull_request.author_association == 'MEMBER') }} | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const prNumber = context.issue.number; | |
const deploymentUrl = `https://staging.pax.dev/build/${prNumber}`; | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `Deployment preview ready! :rocket:\n\nYou can view this deployment at: [${deploymentUrl}](${deploymentUrl})` | |
}) | |
- name: Run tests | |
run: cargo test --verbose --workspace --exclude pax-chassis-macos --exclude pax-chassis-common --exclude pax-chassis-ios | |
- name: Check formatting | |
run: cargo fmt -- --check | |
- name: Check for linting errors | |
run: | | |
rustup component add clippy | |
cargo clippy -- -D warnings |