-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
77 lines (69 loc) · 3.73 KB
/
Copy pathMakefile
File metadata and controls
77 lines (69 loc) · 3.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# =============================================================================
# Makefile -- pg-migration-lint build and test targets
# =============================================================================
IMAGE_NAME := pg-migration-lint-test
CONTAINER_NAME := pgml-bridge-gen
.PHONY: bridge-generate bridge-verify bridge-clean test coverage docs-sync
# ---------------------------------------------------------------------------
# bridge-generate: Build everything in Docker, then extract golden files
# and insta snapshots back to the host for committing.
#
# Use this when:
# - First-time setup of bridge golden files / snapshots
# - After changing XML fixtures or bridge Java code
# - After changing lint rules that affect bridge test output
# ---------------------------------------------------------------------------
bridge-generate:
docker build -f Dockerfile.test -t $(IMAGE_NAME) .
@# Remove any leftover container from a previous run
@docker rm $(CONTAINER_NAME) 2>/dev/null || true
@# Run with INSTA_UPDATE=always to generate/update snapshots
docker run --name $(CONTAINER_NAME) $(IMAGE_NAME) \
sh -c 'INSTA_UPDATE=always cargo test --features bridge-tests --test bridge'
@# Extract Java golden file
docker cp $(CONTAINER_NAME):/app/bridge/src/test/resources/fixtures/full-changelog.expected.json \
bridge/src/test/resources/fixtures/full-changelog.expected.json
@# Extract insta snapshots (bridge tests only)
@mkdir -p tests/snapshots
docker cp $(CONTAINER_NAME):/app/tests/snapshots/. tests/snapshots/
docker rm $(CONTAINER_NAME)
@echo ""
@echo "==> Golden files and snapshots extracted. Review and commit."
# ---------------------------------------------------------------------------
# bridge-verify: Build and run all tests in Docker (CI mode).
# Assumes golden files / snapshots are already committed.
# ---------------------------------------------------------------------------
bridge-verify:
docker build -f Dockerfile.test -t $(IMAGE_NAME) .
docker run --rm $(IMAGE_NAME)
# ---------------------------------------------------------------------------
# bridge-clean: Remove Docker artifacts.
# ---------------------------------------------------------------------------
bridge-clean:
@docker rm $(CONTAINER_NAME) 2>/dev/null || true
@docker rmi $(IMAGE_NAME) 2>/dev/null || true
@echo "==> Docker artifacts cleaned."
# ---------------------------------------------------------------------------
# test: Run standard (non-bridge) tests locally.
# ---------------------------------------------------------------------------
test:
cargo test
cargo clippy -- -D warnings
# ---------------------------------------------------------------------------
# coverage: Generate an HTML code coverage report using cargo-llvm-cov.
# Requires: cargo install cargo-llvm-cov
# Opens the report in the default browser when done.
# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------
# docs-sync: Sync generated rules doc from insta snapshot to docs/rules.md.
# Run after `cargo insta review` to accept snapshot changes.
# ---------------------------------------------------------------------------
docs-sync:
@sed '1,/^---$$/d' src/snapshots/pg_migration_lint__docgen__tests__rules_md.snap > docs/rules.md
@echo "==> docs/rules.md updated from snapshot."
coverage:
cargo llvm-cov --html --output-dir $(HOME)/Downloads/pg-migration-lint-coverage
@chmod -R a+rX $(HOME)/Downloads/pg-migration-lint-coverage
@echo ""
@echo "==> Coverage report: $(HOME)/Downloads/pg-migration-lint-coverage/html/index.html"
@xdg-open $(HOME)/Downloads/pg-migration-lint-coverage/html/index.html 2>/dev/null || true