Skip to content

Test caching workflow for action #697

Test caching workflow for action

Test caching workflow for action #697

Workflow file for this run

name: Rust Build and Deploy
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master", "dev" ]
env:
CARGO_TERM_COLOR: always
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
CARGO_INCREMENTAL: "0"
RUST_BACKTRACE: "1"
jobs:
build-and-deploy:
runs-on: mars
permissions: write-all
steps:
- uses: actions/checkout@v3
- 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
# Cache sccache
- name: Cache sccache
uses: actions/cache@v3
with:
path: ~/.cache/sccache
key: ${{ runner.os }}-sccache-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-sccache-
# Cache Rust dependencies
- uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
# Cache wasm-pack
- uses: actions/cache@v3
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@v3
with:
path: examples/src/starter-project/.pax/build
key: ${{ runner.os }}-pax-build-${{ hashFiles('examples/src/starter-project/**') }}
- name: Build Starter Project
env:
RUSTFLAGS: "-C debuginfo=0"
run: |
pushd examples/src/starter-project
sccache --start-server
./pax build --release --designer
sccache --show-stats
popd
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
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
run: |
BUCKET_NAME="staging.pax.dev/${{ github.event.pull_request.number }}"
aws s3 sync /home/runner/work/pax/pax/examples/src/starter-project/.pax/build/release/web s3://$BUCKET_NAME --delete --acl public-read
- name: Invalidate CloudFront
run: |
aws cloudfront create-invalidation --distribution-id E29ZMWF6F0HQ61 --paths "/*"
- name: Post deployment link as PR comment
if: github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
script: |
const prNumber = context.issue.number;
const deploymentUrl = `https://staging.pax.dev/${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})`
})
# Uncomment these steps if you want to run tests, check formatting, and lint
# - 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