-
Notifications
You must be signed in to change notification settings - Fork 53
Add GitHub Actions to test package exports with CSS @import validation and fix runtime dependencies #1244
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: lukasoppermann <[email protected]>
|
Co-authored-by: lukasoppermann <[email protected]>
Co-authored-by: lukasoppermann <[email protected]>
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.
@copilot The test is failing:
0s
Run cd test-exports
cd test-exports
PACKAGE_FILE=$(ls ../@primer-primitives-.tgz | head -1)
npm install "$PACKAGE_FILE"
shell: /usr/bin/bash -e {0}
ls: cannot access '../@primer-primitives-.tgz': No such file or directory
up to date, audited 1 package in 247ms
found 0 vulnerabilities
0s
Run cd test-exports
cd test-exports
cat > test-main.mjs << 'EOF'
// Test main export
try {
const { PrimerStyleDictionary } = await import('@primer/primitives');
console.log('✓ Main export works:', typeof PrimerStyleDictionary);
if (!PrimerStyleDictionary || typeof PrimerStyleDictionary !== 'object') {
throw new Error('PrimerStyleDictionary is not properly exported');
}
// Test that it has expected methods
if (typeof PrimerStyleDictionary.extend !== 'function') {
throw new Error('PrimerStyleDictionary.extend is not a function');
}
console.log('✓ PrimerStyleDictionary has expected API');
} catch (error) {
console.error('✗ Main export failed:', error.message);
process.exit(1);
}
EOF
node test-main.mjs
shell: /usr/bin/bash -e {0}
✗ Main export failed: Cannot find package '@primer/primitives' imported from /home/runner/work/primitives/primitives/test-exports/test-main.mjs
Error: Process completed with exit code 1.
0s
@copilot The test is failing: 0s up to date, audited 1 package in 247ms found 0 vulnerabilities
} catch (error) { |
Co-authored-by: lukasoppermann <[email protected]>
|
||
- name: Test CSS exports | ||
run: | | ||
cd test-exports |
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.
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.
Updated in commit 6533023. The CSS testing now uses actual @import statements processed with PostCSS instead of just checking file existence. The test creates CSS files with @import statements like @import '@primer/primitives/dist/css/functional/themes/light.css';
and uses PostCSS with postcss-import to verify they resolve correctly and include the expected content.
Co-authored-by: lukasoppermann <[email protected]>
This PR implements automated testing for all package exports to ensure they work correctly for consumers, with comprehensive CSS import validation using actual @import statements.
Problem Solved
The package exports defined in
package.json
needed validation to ensure they work with pre-release builds and that consumers can properly import CSS files, tokens, and the main API.Changes Made
Added Explicit Package Exports
Added a clear
exports
field topackage.json
defining the public API:Fixed Runtime Dependencies
Moved essential dependencies from
devDependencies
todependencies
:style-dictionary
- Required by the main exportcolor2k
,json5
,prettier
,zod
- Used by built modulesAdded Comprehensive Export Testing
The workflow tests all export patterns with realistic usage:
PrimerStyleDictionary
functionality@import
statements processed with PostCSS to verify CSS imports work correctly:Pre-release Testing
Added
test_exports_prerelease.yml
that triggers after Release Candidate workflow to test actual published packages from npm.Benefits
This ensures reliable consumption of
@primer/primitives
by other projects and validates that all documented import patterns continue to work.💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.