Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run tests in CI, and fix fonts for snapshot testing #233

Merged
merged 30 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2f70945
Properly prime the Rust cache
DJMcNab Aug 1, 2024
e5adf45
Migrate the snapshots to use `git lfs`
DJMcNab Aug 1, 2024
cdbfff6
Actually checkout the lfs files
DJMcNab Aug 2, 2024
24d0a82
Add `roboto` into the repository
DJMcNab Apr 29, 2024
bd27f77
Make snapshot testing use roboto
DJMcNab Apr 29, 2024
5b76051
Update snapshot tests to match
DJMcNab Apr 29, 2024
28e3ac4
Setup CI to run snapshot tests
DJMcNab Apr 29, 2024
a9f657e
"Fix" `clippy::needless_borrows_for_generic_args`
DJMcNab Apr 29, 2024
ad25a6a
Test only on ubuntu
DJMcNab Apr 29, 2024
1140f1e
Upload the screenshots on failure
DJMcNab Apr 29, 2024
63751cc
Stash nv-flip work
DJMcNab Jul 17, 2024
40bb7a4
Move roboto to the right folder
DJMcNab Jul 17, 2024
f073cc6
Fix render_root imports
DJMcNab Jul 17, 2024
50beb6e
Add nv-flip dependency
DJMcNab Aug 5, 2024
86b380a
Add nv-flip dependency
DJMcNab Jul 17, 2024
9b5242d
Migrate to cargo nextest in CI
DJMcNab Jul 18, 2024
729fb78
Fix compilation
DJMcNab Jul 18, 2024
1ec2c7f
Update Cargo.lock
DJMcNab Jul 18, 2024
a03b899
Introduce an artificial failure
DJMcNab Jul 18, 2024
077642b
Undo artificial failure
DJMcNab Jul 18, 2024
bd58f08
Fix Cargo.lock messiness
DJMcNab Jul 31, 2024
e92dff1
Update tests for new gap property
DJMcNab Jul 31, 2024
a9c83f0
Add assertion for release incompatible tests
DJMcNab Jul 31, 2024
1850fa2
Remove extra `crates/` reference
DJMcNab Aug 1, 2024
72d5c9f
Address some review feedback
DJMcNab Aug 2, 2024
271173c
Add docs for `add_test_font`
DJMcNab Aug 2, 2024
59f62b1
Add ignores to the new tests
DJMcNab Aug 5, 2024
ac7549d
Merge branch 'lfs-caching' into tests-ci
DJMcNab Aug 5, 2024
2bc25d4
Update all the screenshots
DJMcNab Aug 5, 2024
44589de
Remove `SKIP_RENDER_SNAPSHOT`
DJMcNab Aug 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# LFS settings
# If changing, also change in .github/workflows/ci.yml
masonry/src/widget/screenshots/*.png filter=lfs diff=lfs merge=lfs -text
83 changes: 82 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ name: CI
on:
pull_request:
merge_group:
# We run on push, even though the commit is the same as when we ran in merge_group.
# This allows the cache to be primed.
# See https://github.com/orgs/community/discussions/66430
push:
branches:
- main

jobs:
fmt:
Expand Down Expand Up @@ -102,6 +108,8 @@ jobs:

- name: restore cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name != 'merge_group' }}

- name: install stable toolchain
uses: dtolnay/rust-toolchain@master
Expand Down Expand Up @@ -137,6 +145,8 @@ jobs:

- name: restore cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name != 'merge_group' }}

- name: install stable toolchain
uses: dtolnay/rust-toolchain@master
Expand All @@ -161,17 +171,65 @@ jobs:
- name: cargo clippy (release)
run: cargo clippy --release --workspace ${{ env.NO_WASM_PKGS }} --locked --target wasm32-unknown-unknown --all-targets -- -D warnings

prime-lfs-cache:
name: Prime LFS Cache
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Cache git lfs
id: lfs-cache
uses: actions/cache@v4
with:
path: .git/lfs
# The files stored in git lfs are all in this folder
key: masonry-lfs-${{ hashFiles('masonry/src/widget/screenshots/*.png') }}
restore-keys: masonry-lfs-
enableCrossOsArchive: true

- name: Fetch lfs data
if: ${{ steps.lfs-cache.outputs.cache-hit != 'true' }}
run: git lfs fetch

test-stable:
name: cargo test
needs: prime-lfs-cache
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
include:
- os: windows-latest
# TODO: It should be possible to get WARP working here
skip_gpu: '1'
- os: macos-latest
skip_gpu: ''
- os: ubuntu-latest
skip_gpu: ''
steps:
- uses: actions/checkout@v4
# We intentionally do not use lfs: true here, instead using the caching method to save LFS bandwidth.

- name: restore cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name != 'merge_group' }}

- name: Restore lfs cache
id: lfs-cache
uses: actions/cache/restore@v4
with:
path: .git/lfs
# The files stored in git lfs are all in this folder
key: masonry-lfs-${{ hashFiles('masonry/src/widget/screenshots/*.png') }}
enableCrossOsArchive: true

- name: Checkout LFS files
run: git lfs checkout
continue-on-error: true

- name: install stable toolchain
uses: dtolnay/rust-toolchain@master
Expand All @@ -192,8 +250,21 @@ jobs:
sudo apt-get update
sudo apt install -y xvfb libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers

- name: Install cargo-nextest
uses: taiki-e/install-action@v2
with:
tool: cargo-nextest

- name: cargo test
run: cargo test --workspace --locked --all-features
run: cargo nextest run --workspace --locked --all-features
env:
SKIP_RENDER_TESTS: ${{ matrix.skip_gpu }}

- uses: actions/upload-artifact@v4
if: failure()
with:
name: masonry-snapshot-tests-${{ matrix.os }}
path: masonry/src/widget/screenshots/

test-stable-wasm:
name: cargo test (wasm32)
Expand All @@ -203,6 +274,8 @@ jobs:

- name: restore cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name != 'merge_group' }}

- name: install stable toolchain
uses: dtolnay/rust-toolchain@master
Expand All @@ -222,6 +295,8 @@ jobs:

- name: restore cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name != 'merge_group' }}

- name: install stable toolchain
uses: dtolnay/rust-toolchain@master
Expand Down Expand Up @@ -249,6 +324,8 @@ jobs:

- name: restore cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name != 'merge_group' }}

- name: install msrv toolchain
uses: dtolnay/rust-toolchain@master
Expand All @@ -275,6 +352,8 @@ jobs:

- name: restore cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name != 'merge_group' }}

- name: install msrv toolchain
uses: dtolnay/rust-toolchain@master
Expand All @@ -300,6 +379,8 @@ jobs:

- name: restore cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name != 'merge_group' }}

- name: install nightly toolchain
uses: dtolnay/rust-toolchain@nightly
Expand Down
Loading