-
Notifications
You must be signed in to change notification settings - Fork 0
ci: Fix builds #2
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
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
d866bab
feat: apple silicon only\n\n- Limit initial release to Apple Silicon …
kevinmichaelchen 52cb561
fix: update CI workflow\n\n- Update test and publish jobs to only exp…
kevinmichaelchen daaea5e
feat: add dry-run publish to PRs\n\n- Make Publish job run on PRs wit…
kevinmichaelchen d38e7e6
style: add emojis to CI workflow\n\n- Add descriptive emojis to job a…
kevinmichaelchen 82c5b08
fix: yaml syntax in CI workflow\n\n- Remove duplicate name field in b…
kevinmichaelchen 3fa9207
fix: use consistent platform names\n\n- Use --platform instead of --t…
kevinmichaelchen cd1061f
ci: fix target
kevinmichaelchen 235ea18
refactor: simplify CI workflow and use NX for native builds
kevinmichaelchen f05429f
refactor: update test job to use consistent matrix format
kevinmichaelchen 736e68b
feat: support more platforms (Windows, Linux, Intel Mac)
kevinmichaelchen 698c946
fix: validate exact number of .node files during publish
kevinmichaelchen ab8b7c1
fix: improve artifact handling and binary naming
kevinmichaelchen 10dd196
fix: use explicit target flag for napi-rs build
kevinmichaelchen 0ce8f2f
fix: use mlugg/setup-zig for cross-compilation
kevinmichaelchen 834b775
fix: update build command and improve docs
kevinmichaelchen ad82ea2
fix: install zig for all ARM64 builds
kevinmichaelchen 63db4d1
fix: install zig for all builds
kevinmichaelchen 59be1fb
fix: only use zig for linux builds
kevinmichaelchen 90027ee
fix: use shell script for conditional zig usage
kevinmichaelchen 20c614f
test: more unit tests
kevinmichaelchen e677a80
chore: Formatting
kevinmichaelchen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -152,15 +152,274 @@ describe("Performance measurements", () => { | |
| // Allow more variation due to system noise, optimization differences, and convenience overhead | ||
| const tolerance = 1.0; // Allow 100% variation | ||
| const expectedEvaluateTime = compileTime + executeTime; | ||
|
|
||
| // Log the actual ratios to help with debugging | ||
| const ratio = evaluateTime / expectedEvaluateTime; | ||
| console.log(`One-step evaluation was ${ratio.toFixed(2)}x the separate steps`); | ||
|
|
||
| console.log( | ||
| `One-step evaluation was ${ratio.toFixed(2)}x the separate steps`, | ||
| ); | ||
|
|
||
| // Only fail if the difference is extreme | ||
| expect(evaluateTime).toBeGreaterThan( | ||
| expectedEvaluateTime * (1 - tolerance), | ||
| ); | ||
| expect(evaluateTime).toBeLessThan(expectedEvaluateTime * (2 + tolerance)); | ||
| }); | ||
| }); | ||
|
|
||
| describe("Timestamp Functions", () => { | ||
| it("should correctly parse and compare timestamps", async () => { | ||
| const expr = `[ | ||
| // Test 1: Compare UTC timestamp with itself | ||
| timestamp('2025-04-28T12:00:00Z') == timestamp('2025-04-28T12:00:00Z'), | ||
| // Test 2: Compare UTC timestamp with equivalent EDT timestamp | ||
| timestamp('2025-04-28T12:00:00Z') == timestamp('2025-04-28T08:00:00-04:00'), | ||
| // Test 3: Compare timestamps one day apart | ||
| timestamp('2025-04-28T12:00:00Z') < timestamp('2025-04-29T12:00:00Z'), | ||
| // Test 4: Get components from UTC timestamp | ||
| timestamp('2025-04-28T12:00:00Z').getMonth(), | ||
| timestamp('2025-04-28T12:00:00Z').getDayOfMonth(), | ||
| timestamp('2025-04-28T12:00:00Z').getHours(), | ||
| timestamp('2025-04-28T12:00:00Z').getDayOfWeek() // 1==Monday | ||
| ]`; | ||
| const result = await evaluate(expr, {}); | ||
| expect(result).toEqual([true, true, true, 3, 27, 12, 1]); | ||
| }); | ||
| }); | ||
|
|
||
| describe("Travel Reservation Rules", () => { | ||
| describe("Premium Discount Eligibility", () => { | ||
| // Tests a complex pricing rule that considers: | ||
| // - Total package cost across flight, hotel, and car | ||
| // - Customer loyalty tier | ||
| // - Seasonal booking (summer months) | ||
| const expr = ` | ||
| // Calculate total package cost | ||
| double(reservation.flight.price) + | ||
| double(reservation.hotel.nightlyRate) * int(reservation.hotel.nights) + | ||
| double(reservation.car.dailyRate) * int(reservation.car.days) >= 2000.0 && | ||
| // Check loyalty tier | ||
| reservation.customer.loyaltyTier in ['GOLD', 'PLATINUM'] && | ||
| // Check if booking is in summer months (0-based: 5=June, 6=July, 7=August) | ||
| timestamp(reservation.bookingDate).getMonth() in [5, 6, 7] | ||
| `; | ||
| let program: CelProgram; | ||
|
|
||
| beforeEach(async () => { | ||
| program = await CelProgram.compile(expr); | ||
| }); | ||
|
|
||
| it("should qualify for premium discount with valid summer booking", async () => { | ||
| const result = await program.execute({ | ||
| reservation: { | ||
| flight: { price: 1000.0 }, | ||
| hotel: { nightlyRate: 200.0, nights: 4 }, | ||
| car: { dailyRate: 100.0, days: 4 }, | ||
| customer: { loyaltyTier: "PLATINUM" }, | ||
| bookingDate: "2025-07-15T00:00:00Z", | ||
| }, | ||
| }); | ||
| expect(result).toBe(true); | ||
| }); | ||
|
|
||
| it("should not qualify outside summer months", async () => { | ||
| const result = await program.execute({ | ||
| reservation: { | ||
| flight: { price: 1000.0 }, | ||
| hotel: { nightlyRate: 200.0, nights: 4 }, | ||
| car: { dailyRate: 100.0, days: 4 }, | ||
| customer: { loyaltyTier: "PLATINUM" }, | ||
| bookingDate: "2025-12-15T00:00:00Z", | ||
| }, | ||
| }); | ||
| expect(result).toBe(false); | ||
| program = await CelProgram.compile(expr); | ||
| }); | ||
| }); | ||
|
|
||
| describe("Multi-condition Booking Validation", () => { | ||
| // Tests complex booking validation rules that ensure: | ||
| // - All required components are present | ||
| // - Logical time sequence of events | ||
| // - Location consistency | ||
| // - Capacity constraints | ||
| const expr = ` | ||
| has(reservation.flight) && | ||
| timestamp(reservation.flight.departureTime) < timestamp(reservation.hotel.checkIn) && | ||
| timestamp(reservation.hotel.checkIn) < timestamp(reservation.hotel.checkOut) && | ||
| (timestamp(reservation.hotel.checkOut) - timestamp(reservation.hotel.checkIn)) > duration("1h") && | ||
| timestamp(reservation.hotel.checkOut) < timestamp(reservation.flight.returnTime) && | ||
| (reservation.car.pickupLocation == reservation.flight.arrivalAirport || | ||
| reservation.car.pickupLocation == reservation.hotel.address.city) && | ||
| size(reservation.travelers) <= reservation.hotel.maxOccupancy && | ||
| size(reservation.travelers) <= reservation.car.capacity | ||
| `; | ||
| let program: CelProgram; | ||
|
|
||
| beforeEach(async () => { | ||
| program = await CelProgram.compile(expr); | ||
| }); | ||
|
|
||
| it("should validate a well-formed booking", async () => { | ||
| const result = await program.execute({ | ||
| reservation: { | ||
| flight: { | ||
| departureTime: "2025-05-01T10:00:00Z", | ||
| returnTime: "2025-05-05T15:00:00Z", | ||
| arrivalAirport: "LAX", | ||
| }, | ||
| hotel: { | ||
| checkIn: "2025-05-01T15:00:00Z", | ||
| checkOut: "2025-05-05T11:00:00Z", | ||
| maxOccupancy: 4, | ||
| address: { city: "Los Angeles" }, | ||
| }, | ||
| car: { | ||
| pickupLocation: "LAX", | ||
| capacity: 5, | ||
| }, | ||
| travelers: ["person1", "person2", "person3"], | ||
| }, | ||
| }); | ||
| expect(result).toBe(true); | ||
| }); | ||
|
|
||
| it("should reject invalid time sequence", async () => { | ||
| const result = await program.execute({ | ||
| reservation: { | ||
| flight: { | ||
| departureTime: "2025-05-01T16:00:00Z", // Later than check-in | ||
| returnTime: "2025-05-05T15:00:00Z", | ||
| arrivalAirport: "LAX", | ||
| }, | ||
| hotel: { | ||
| checkIn: "2025-05-01T15:00:00Z", | ||
| checkOut: "2025-05-05T11:00:00Z", | ||
| maxOccupancy: 4, | ||
| address: { city: "Los Angeles" }, | ||
| }, | ||
| car: { | ||
| pickupLocation: "LAX", | ||
| capacity: 5, | ||
| }, | ||
| travelers: ["person1", "person2", "person3"], | ||
| }, | ||
| }); | ||
| expect(result).toBe(false); | ||
| }); | ||
| }); | ||
|
|
||
| describe.skip("Dynamic Pricing with Seasonal Adjustments", () => { | ||
| // Tests complex pricing calculations including: | ||
| // - Base rates for all components | ||
| // - Seasonal multipliers | ||
| // - Loyalty discounts | ||
| const expr = ` | ||
| let basePrice = double(reservation.flight.price) + | ||
| double(reservation.hotel.nightlyRate) * int(reservation.hotel.nights) + | ||
| double(reservation.car.dailyRate) * int(reservation.car.days); | ||
| let seasonalPrice = basePrice * (timestamp(reservation.hotel.checkIn).getMonth() in [11, 0, 1] ? 1.25 : 1.0); | ||
| seasonalPrice * (1.0 - {'BRONZE': 0.05, 'SILVER': 0.10, 'GOLD': 0.15, 'PLATINUM': 0.20}[reservation.customer.loyaltyTier]) | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't think CEL supports |
||
| `; | ||
| let program: CelProgram; | ||
|
|
||
| beforeEach(async () => { | ||
| program = await CelProgram.compile(expr); | ||
| }); | ||
|
|
||
| it("should calculate winter pricing with loyalty discount", async () => { | ||
| const result = await program.execute({ | ||
| reservation: { | ||
| flight: { price: 1000.0 }, | ||
| hotel: { | ||
| nightlyRate: 200.0, | ||
| nights: 4, | ||
| checkIn: "2025-01-15T15:00:00Z", // January | ||
| }, | ||
| car: { dailyRate: 100.0, days: 4 }, | ||
| customer: { loyaltyTier: "GOLD" }, | ||
| }, | ||
| }); | ||
| // Base: 1000 + (200 * 4) + (100 * 4) = 2200 | ||
| // Winter multiplier: 2200 * 1.25 = 2750 | ||
| // Gold discount (15%): 2750 * 0.85 = 2337.5 | ||
| expect(result).toBe(2337.5); | ||
| }); | ||
|
|
||
| it("should calculate summer pricing with loyalty discount", async () => { | ||
| const result = await program.execute({ | ||
| reservation: { | ||
| flight: { price: 1000.0 }, | ||
| hotel: { | ||
| nightlyRate: 200.0, | ||
| nights: 4, | ||
| checkIn: "2025-07-15T15:00:00Z", // July | ||
| }, | ||
| car: { dailyRate: 100.0, days: 4 }, | ||
| customer: { loyaltyTier: "PLATINUM" }, | ||
| }, | ||
| }); | ||
| // Base: 1000 + (200 * 4) + (100 * 4) = 2200 | ||
| // No seasonal multiplier | ||
| // Platinum discount (20%): 2200 * 0.80 = 1760 | ||
| expect(result).toBe(1760.0); | ||
| }); | ||
| }); | ||
|
|
||
| describe("Room Upgrade Eligibility", () => { | ||
| // Tests complex upgrade eligibility rules considering: | ||
| // - Customer loyalty tier | ||
| // - Stay duration | ||
| // - Hotel occupancy | ||
| // - Existing offers | ||
| // - Total spend | ||
| // - Current booking class | ||
| const expr = ` | ||
| reservation.customer.loyaltyTier in ['GOLD', 'PLATINUM'] && | ||
| reservation.hotel.nights >= 3 && | ||
| reservation.hotel.occupancyRate < 0.80 && | ||
| !(reservation.specialOffers.exists(o, o.type == 'ROOM_UPGRADE')) && | ||
| reservation.totalSpend > 5000.0 && | ||
| [reservation.flight.class, reservation.hotel.roomType].all(t, t != 'ECONOMY') | ||
| `; | ||
| let program: CelProgram; | ||
|
|
||
| beforeEach(async () => { | ||
| program = await CelProgram.compile(expr); | ||
| }); | ||
|
|
||
| it("should qualify eligible platinum member for upgrade", async () => { | ||
| const result = await program.execute({ | ||
| reservation: { | ||
| customer: { loyaltyTier: "PLATINUM" }, | ||
| hotel: { | ||
| nights: 4, | ||
| occupancyRate: 0.7, | ||
| roomType: "DELUXE", | ||
| }, | ||
| flight: { class: "BUSINESS" }, | ||
| specialOffers: [], | ||
| totalSpend: 6000.0, | ||
| }, | ||
| }); | ||
| expect(result).toBe(true); | ||
| }); | ||
|
|
||
| it("should reject upgrade when conditions not met", async () => { | ||
| const result = await program.execute({ | ||
| reservation: { | ||
| customer: { loyaltyTier: "PLATINUM" }, | ||
| hotel: { | ||
| nights: 4, | ||
| occupancyRate: 0.85, // Too high occupancy | ||
| roomType: "DELUXE", | ||
| }, | ||
| flight: { class: "BUSINESS" }, | ||
| specialOffers: [], | ||
| totalSpend: 6000.0, | ||
| }, | ||
| }); | ||
| expect(result).toBe(false); | ||
| }); | ||
| }); | ||
| }); | ||
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cel-rust appears to not support the array.min() function that would simplify this