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

chore: Upgrade testing infrastructure #513

Open
wants to merge 91 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 84 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
f164e77
Foundation for snapshot testing
ok-nick Jul 16, 2024
644a6dc
Use more snapshot in integration tests
ok-nick Jul 16, 2024
fcd3005
Integration tests over all assets
ok-nick Jul 16, 2024
bfd22f4
Fix/document issues with assets
ok-nick Jul 16, 2024
e911ae3
Merge remote-tracking branch 'origin' into ok-nick/tests
ok-nick Jul 16, 2024
96596fe
Integration tests for specific assets/hash types
ok-nick Jul 17, 2024
c088660
Simplify test asset io
ok-nick Jul 17, 2024
1a638c5
Merge remote-tracking branch 'origin' into ok-nick/tests
ok-nick Jul 17, 2024
8c2199d
New fixture asset structure
ok-nick Jul 17, 2024
b3173bb
Cleanup some old code
ok-nick Jul 17, 2024
b6a605e
A back code coverage
ok-nick Jul 17, 2024
e6ead78
Rework Asset and fix some unit test paths
ok-nick Jul 18, 2024
66793d8
Feature-toggle include_bytes! vs File::open for tests
ok-nick Jul 19, 2024
5ac1d38
Replace macros with plain functions
ok-nick Jul 19, 2024
9439903
Revert some changes
ok-nick Jul 22, 2024
7a1774c
Update integration tests
ok-nick Jul 22, 2024
3f56677
Merge remote-tracking branch 'origin' into ok-nick/tests
ok-nick Jul 22, 2024
4704252
Order snapshot outputs by default
ok-nick Jul 22, 2024
1ffac9f
Fix up tests and regex dep conflict
ok-nick Jul 22, 2024
10d597f
Always add thumbnails for integration tests
ok-nick Jul 22, 2024
a93235c
Fix deprecated use of image in make_test_images
ok-nick Jul 22, 2024
30d7742
Deny doc build warnings
ok-nick Jul 22, 2024
2c23919
Merge branch 'main' into ok-nick/tests
ok-nick Jul 22, 2024
36c5ca1
Merge branch 'ok-nick/tests' of github.com:contentauth/c2pa-rs into o…
ok-nick Jul 22, 2024
18ed29b
Foundation for testing old versions + add integration tests
ok-nick Jul 23, 2024
d2e7f1f
Foundation for c2pa-compat binary
ok-nick Jul 23, 2024
470005e
Add c2pa-compat note
ok-nick Jul 23, 2024
0529bb3
Merge remote-tracking branch 'origin' into ok-nick/tests
ok-nick Jul 23, 2024
af97371
Add manifest compat snapshot CI
ok-nick Jul 23, 2024
ba6b7aa
Install submodules during tests
ok-nick Jul 23, 2024
ed4e655
Temp comment compat test
ok-nick Jul 23, 2024
334c55b
Do not use thumbnails in tests on WASM + add c2pa-compat license
ok-nick Jul 23, 2024
2f2e28d
Fix WASM build issue
ok-nick Jul 23, 2024
cdfef09
WIP mvp c2pa-compat
ok-nick Jul 23, 2024
6ac617c
c2pa-compat all parser types embedded + remote
ok-nick Jul 23, 2024
a835084
Remove fixtures
ok-nick Jul 24, 2024
085d1d0
Use sidecars instead of remote, submodule, split ci
ok-nick Jul 24, 2024
1625f56
Merge remote-tracking branch 'origin' into ok-nick/tests
ok-nick Jul 24, 2024
add6a9b
Fix serde_json version in c2pa-compat
ok-nick Jul 24, 2024
5689078
Fix install submodules build script
ok-nick Jul 24, 2024
c0c5612
Temp remove conditional comp for ci
ok-nick Jul 24, 2024
180b569
c2pa-compat integration test over all asset types
ok-nick Jul 24, 2024
3df1a42
More compat assertions
ok-nick Jul 24, 2024
a399e8b
Prototype c2pa-compat + serve remote manifests + sidecar
ok-nick Jul 24, 2024
4ec0e6f
Fix remote URLs for c2pa-compat
ok-nick Jul 24, 2024
f08da2e
Cleanup and prep compat assertion validation(?)
ok-nick Jul 25, 2024
2a1df55
Checkout submodules in CI
ok-nick Jul 25, 2024
e7cbcde
Fix clippy checks
ok-nick Jul 25, 2024
6ac858b
Add json stabilization
ok-nick Jul 26, 2024
3c68bf6
Merge branch 'main' into ok-nick/tests
ok-nick Jul 26, 2024
e6cbb2a
Mvp c2pa-compat and only test compat against reading
ok-nick Jul 29, 2024
104fdc2
Merge remote-tracking branch 'origin' into ok-nick/tests
ok-nick Jul 29, 2024
d543a1c
Sanitize c2pa version in snapshots
ok-nick Jul 29, 2024
cbc08e7
Update c2pa-fixtures test compat assets
ok-nick Jul 29, 2024
5fe5ef6
Add binary diffing and compression to compat assets
ok-nick Jul 29, 2024
3759ba3
Move diff/compression to dev-dep platform agnostic
ok-nick Jul 29, 2024
23ced9e
Change fixtures repo
ok-nick Jul 29, 2024
1900f77
Temp run compat workflow
ok-nick Jul 29, 2024
cf29b3e
Remove repository key from create PR in CI
ok-nick Aug 1, 2024
6b649e7
Remove submodules and use local repo
ok-nick Aug 2, 2024
8306260
Temp enable compat snapshot on PR
ok-nick Aug 2, 2024
3c1106d
Add head_ref to compat PR in CI
ok-nick Aug 2, 2024
c7c4e9b
Get latest release tag for compat PR in CI
ok-nick Aug 2, 2024
6170567
Test removing compression for Windows CI
ok-nick Aug 5, 2024
91314cb
Change binary diff crate
ok-nick Aug 5, 2024
a39ec83
test without compression or diffing
ok-nick Aug 5, 2024
f798c29
Revert to old diff and upload artifacts for test
ok-nick Aug 5, 2024
3b7571b
temp: test compat all platforms
ok-nick Aug 5, 2024
fb6372f
fix latest tag step
ok-nick Aug 5, 2024
3c7e5eb
Get all git tags
ok-nick Aug 5, 2024
f6d03d6
unique names for compat snapshot
ok-nick Aug 5, 2024
881967f
Use new diffing crate
ok-nick Aug 5, 2024
7eb392c
Revert diffing c test
ok-nick Aug 5, 2024
a64561e
Revert test diff
ok-nick Aug 5, 2024
ef26a7e
Clean up and finalize
ok-nick Aug 6, 2024
00da14f
Merge remote-tracking branch 'origin' into ok-nick/tests
ok-nick Aug 6, 2024
4955af6
Clean up TODOs
ok-nick Aug 6, 2024
d842c11
Merge remote-tracking branch 'origin/main' into ok-nick/tests
ok-nick Aug 12, 2024
fe4cf54
Update tests
ok-nick Aug 13, 2024
6f141f5
Disable autocrlf on Windows to fix SVG issue
ok-nick Aug 13, 2024
c4b754e
Fix unused function clippy
ok-nick Aug 13, 2024
bc14a2b
Merge remote-tracking branch 'origin' into ok-nick/tests
ok-nick Aug 13, 2024
8ae1dc4
Merge remote-tracking branch 'origin' into ok-nick/tests
ok-nick Aug 14, 2024
f9c24de
Add RIFF after fix
ok-nick Aug 14, 2024
87ad146
Document c2pa-compat
ok-nick Aug 15, 2024
4c281a9
Ignore unknown fields
ok-nick Aug 15, 2024
16b9bc2
Ignore unknown fields found in original and not in modified
ok-nick Aug 15, 2024
bc39ad3
c2pa-compat takes path and introduce latest snapshot
ok-nick Aug 15, 2024
9ffb9bd
Use brotli compression
ok-nick Aug 16, 2024
adaf308
Use c2pa::VERSION instead of env! var
ok-nick Aug 16, 2024
6c85936
Escape the version regex
ok-nick Aug 16, 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
64 changes: 48 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,47 @@ jobs:
rust_version: [stable, 1.74.0]

steps:
- name: Disable core.autocrlf
run: git config --global core.autocrlf false

- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust_version }}
components: llvm-tools-preview

- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2

- name: Run unit tests
run: cargo test --all-features --verbose
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov

- name: Generate code coverage
id: run_tests
env:
RUST_BACKTRACE: 1
CARGO_TERM_COLOR: always
CLICOLOR_FORCE: 1
INSTA_UPDATE: new
run: cargo llvm-cov --tests --bins --all-features --lcov --output-path lcov.info

# https://insta.rs/docs/patterns/
- name: Upload snapshots of failed tests
if: ${{ failure() && steps.run_tests.outcome == 'failure' }}
uses: actions/upload-artifact@v3
with:
name: failed-snapshots
path: "**/snapshots/*.snap.new"

- name: Upload code coverage results
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
verbose: true

tests-cross:
name: Unit tests
Expand All @@ -44,8 +72,11 @@ jobs:
rust_version: [stable, 1.74.0]

steps:
- name: Disable core.autocrlf
run: git config --global core.autocrlf false

- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
Expand All @@ -72,7 +103,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
Expand All @@ -94,8 +125,11 @@ jobs:
os: [windows-latest, macos-latest, ubuntu-latest]

steps:
- name: Disable core.autocrlf
run: git config --global core.autocrlf false

- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@nightly
Expand All @@ -120,7 +154,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
Expand All @@ -139,7 +173,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
Expand All @@ -163,7 +197,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install stable toolchain
uses: dtolnay/rust-toolchain@nightly
Expand All @@ -178,7 +212,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install nightly Rust toolchain
# Nightly is used here because the docs.rs build
Expand All @@ -193,7 +227,7 @@ jobs:
# documentation build on docs.rs.
run: cargo +nightly doc --all-features --no-deps
env:
RUSTDOCFLAGS: --cfg docsrs
RUSTDOCFLAGS: "--cfg docsrs -D warnings"
DOCS_RS: 1

cargo-deny:
Expand All @@ -212,7 +246,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Audit crate dependencies
uses: EmbarkStudios/cargo-deny-action@v1
Expand All @@ -224,7 +258,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@nightly
Expand All @@ -241,9 +275,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_ADMIN_COMMIT_TOKEN }}
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: nightly

Expand All @@ -107,7 +107,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: nightly

Expand Down
32 changes: 31 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,43 @@ on:
workflow_dispatch:

jobs:
compat-snapshot:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Create compat snapshot
run: cargo run -p c2pa-compat

- name: Get latest existing tag
uses: WyriHaximus/github-action-get-previous-tag@v1
id: get-latest-tag

- name: Send compat PR
uses: peter-evans/create-pull-request@v6
with:
title: "Create compat snapshot for ${{ steps.get-latest-tag.outputs.tag }}"
labels: compat-snapshot
commit-message: "Create compat snapshot for ${{ steps.get-latest-tag.outputs.tag }}"
branch: "compat-snapshot-${{ steps.get-latest-tag.outputs.tag }}"
add-paths: sdk/tests/fixtures
base: ${{ github.head_ref }}

publish:
concurrency: publish-mutex
runs-on: ubuntu-latest
steps:
- name: Disable core.autocrlf
run: git config --global core.autocrlf false

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_ADMIN_COMMIT_TOKEN }}
Expand Down
7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
[workspace]
resolver = "2"
members = ["sdk", "export_schema", "make_test_images"]
members = ["sdk", "export_schema", "make_test_images", "c2pa-compat"]

# https://insta.rs/docs/quickstart/
[profile.dev.package]
insta.opt-level = 3
similar.opt-level = 3
19 changes: 19 additions & 0 deletions c2pa-compat/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "c2pa-compat"
version = "0.1.0"
edition = "2021"
rust-version = "1.74.0"
license = "MIT OR Apache-2.0"

[dependencies]
c2pa = { path = "../sdk", features = [
"unstable_api",
"openssl_sign",
"file_io",
] }
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.117"
ed25519-dalek = "2.1.1"
pem = "3.0.2"
bsdiff = "0.2.0"
lz4_flex = "0.11.3"
6 changes: 6 additions & 0 deletions c2pa-compat/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# `c2pa-compat`
A tool for generating a compatibility snapshot of all asset types with remote and embedded manifests.

These snapshots are typically created every release and saved to `sdk/tests/fixtures/compat/<VERSION>` for each c2pa-rs version. They are used in the compatibility tests found in `sdk/tests/compat.rs`.

`src/full-manifest.json` should always contain every possible manifest feature for every release.
123 changes: 123 additions & 0 deletions c2pa-compat/src/full-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
"title": "extensive-version-snapshot",
"format": "TODO",
"instance_id": "TOOD",
"claim_generator_info": [
{
"name": "My claim generator",
"version": "0.1.0",
"icon": {
"format": "image/svg+xml",
"identifier": "sample1.svg"
}
}
],
"metadata": [
{
"reviews": [
{
"explanation": "Some explanation",
"code": "ingredient.notVisible",
"value": 2
}
],
"dateTime": "1985-04-12T23:20:50.52Z",
"dataSource": {
"type": "humanEntry.identified",
"details": "Some details",
"actors": [
{
"identifier": "Some identifier"
}
]
},
"my_custom_metadata": "my custom metatdata value"
}
],
"thumbnail": {
"format": "image/jpeg",
"identifier": "C.jpg",
"data_types": [
{
"type": "c2pa.types.classifier",
"version": "0.1.0"
}
]
},
"assertions": [
{
"label": "TODO: add every single type of assertion, v1 + v2 + vX",
"data": {
"TODO": "TODO: are assertions validated? are they all treated the same, just a blob?"
}
}
],
"ingredients": [
{
"title": "CA.jpg",
"format": "image/jpeg",
"document_id": "xmp.did:813ee422-9736-4cdc-9be6-4e35ed8e41cb",
"relationship": "parentOf",
"thumbnail": {
"format": "image/png",
"identifier": "fixtures/png/exp-test1.png",
"data_types": [
{
"type": "c2pa.types.classifier",
"version": "0.1.0"
}
]
},
"validation_status": [
{
"code": "claimSignature.validated",
"url": "TODO",
"explanation": "Some explanation"
}
],
"description": "Some description",
"informational_URI": "google.com",
"metadata": {
"reviews": [
{
"explanation": "Some explanation",
"code": "ingredient.notVisible",
"value": 2
}
],
"dateTime": "1985-04-12T23:20:50.52Z",
"dataSource": {
"type": "humanEntry.identified",
"details": "Some details",
"actors": [
{
"identifier": "Some identifier"
}
]
},
"my_custom_metadata": "my custom metatdata value"
},
"data_types": [
{
"type": "c2pa.types.classifier",
"version": "0.1.0"
}
]
},
{
"title": "prompt",
"format": "text/plain",
"relationship": "inputTo",
"data": {
"format": "text/plain",
"identifier": "prompt.txt",
"data_types": [
{
"type": "c2pa.types.generator.prompt"
}
]
}
}
],
"redactions": ["TODO"]
}
Loading
Loading