fix(ImpressionArea): fix return type of ImpressionArea (#256) #699
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
name: Integration | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
quality: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
command: ['format', 'lint', 'type', 'spec'] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Enable Corepack | |
run: corepack enable | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
cache: 'yarn' | |
- name: Install dependencies | |
run: yarn install | |
- name: Run test:${{ matrix.command }} | |
run: yarn run test:${{ matrix.command }} | |
check-changes: | |
runs-on: ubuntu-latest | |
outputs: | |
changed: ${{ steps.filter.outputs.changed }} | |
changed_files: ${{ steps.filter.outputs.changed_files }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Enable Corepack | |
run: corepack enable | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
cache: 'yarn' | |
- name: Check for changes in .ts and .tsx files | |
id: filter | |
uses: dorny/paths-filter@v3 | |
with: | |
list-files: shell | |
filters: | | |
changed: | |
- added|modified: | |
- 'src/components/**/!(index|*.spec).ts' | |
- 'src/components/**/!(*.spec).tsx' | |
- 'src/hooks/**/!(index|*.spec).ts' | |
- 'src/hooks/**/!(*.spec).tsx' | |
- 'src/utils/**/!(index|*.spec).ts' | |
- 'src/utils/**/!(*.spec).tsx' | |
verify-test: | |
runs-on: ubuntu-latest | |
needs: check-changes | |
if: ${{ needs.check-changes.outputs.changed == 'true' }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Enable Corepack | |
run: corepack enable | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
cache: 'yarn' | |
- name: Install dependencies | |
run: yarn install | |
- name: Run tests and generate coverage | |
run: yarn run test:coverage | |
- name: Upload coverage reports to Codecov | |
uses: codecov/codecov-action@v5 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
- name: Verify test coverage | |
run: | | |
changed_files="${{ needs.check-changes.outputs.changed_files }}" | |
coverage_file="coverage/coverage-final.json" | |
if [ ! -f "$coverage_file" ]; then | |
echo "Coverage file not found!" | |
exit 1 | |
fi | |
for file in $changed_files; do | |
dir_name=$(basename $(dirname "$file")) | |
base_name=$(basename $dir_name) | |
test_file="$(dirname "$file")/$base_name.spec.ts" | |
if [ ! -f "$test_file" ]; then | |
test_file="$(dirname "$file")/$base_name.spec.tsx" | |
if [ ! -f "$test_file" ]; then | |
echo "Test file missing for $base_name" | |
exit 1 | |
fi | |
fi | |
# Debugging: Print the file path | |
echo "Checking coverage for: $file" | |
# Calculate coverage percentage for each matching entry | |
total_lines=0 | |
covered_lines=0 | |
# Iterate over each matching coverage data entry | |
for entry in $(jq -c --arg base_name "$base_name" '. | to_entries[] | select(.key | contains($base_name)) | .value' "$coverage_file"); do | |
entry_total_lines=$(echo "$entry" | jq '.s | length') | |
entry_covered_lines=$(echo "$entry" | jq '[.s[] | select(. > 0)] | length') | |
# Accumulate total and covered lines | |
total_lines=$((total_lines + entry_total_lines)) | |
covered_lines=$((covered_lines + entry_covered_lines)) | |
done | |
# Calculate overall coverage percentage | |
coverage=$(echo "scale=2; ($covered_lines / $total_lines) * 100" | bc) | |
# Debugging: Print accumulated total and covered lines | |
echo "Total lines: $total_lines, Covered lines: $covered_lines" | |
echo "Coverage: $coverage%" | |
# Correct the condition to check if coverage is less than 100 | |
if (( $(echo "$coverage < 100" | bc -l) )); then | |
echo "Test coverage for $base_name is not 100%: $coverage%" | |
exit 1 | |
fi | |
done | |
verify-jsdoc: | |
runs-on: ubuntu-latest | |
needs: check-changes | |
if: ${{ needs.check-changes.outputs.changed == 'true' }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Check for JSDoc comments | |
run: | | |
for file in ${{ needs.check-changes.outputs.changed_files }}; do | |
dir_name=$(basename $(dirname "$file")) | |
base_name=$(basename $dir_name) | |
implementation="$(dirname "$file")/$base_name.ts" | |
if [ ! -f "$implementation" ]; then | |
implementation="$(dirname "$file")/$base_name.tsx" | |
if [ ! -f "$implementation" ]; then | |
echo "Implementation missing for $file" | |
exit 1 | |
fi | |
fi | |
if ! grep -q "/\*\*" "$implementation"; then | |
echo "JSDoc comments missing in $implementation" | |
exit 1 | |
fi | |
if ! grep -q "@description" "$implementation"; then | |
echo "@description tag missing in $implementation" | |
exit 1 | |
fi | |
if ! grep -q "@example" "$implementation"; then | |
echo "@example tag missing in $implementation" | |
exit 1 | |
fi | |
done | |
verify-jsdoc-structure: | |
runs-on: ubuntu-latest | |
needs: check-changes | |
if: ${{ needs.check-changes.outputs.changed == 'true' }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Enable Corepack | |
run: corepack enable | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
cache: 'yarn' | |
- name: Install dependencies | |
run: yarn install | |
- name: Check JSDoc structure | |
run: | | |
for file in ${{ needs.check-changes.outputs.changed_files }}; do | |
directory=$(basename "$(dirname "$file")") | |
filename=$(basename $file) | |
filename="${filename%%.*}" | |
if [ "$directory" != "$filename" ]; then | |
continue | |
fi | |
if ! grep -e "@description" "$file"; then | |
echo "@description tag missing in $file" | |
exit 1 | |
fi | |
if ! grep -e "@example" "$file"; then | |
echo "@example tag missing in $file" | |
exit 1 | |
fi | |
if grep -q "@param" "$file"; then | |
if ! grep -q "@param {.*}" "$file"; then | |
echo "Parameter type missing in @param tag in $file" | |
exit 1 | |
fi | |
if ! grep -q "@param {.*} [^ -]* - .*" "$file"; then | |
echo "Parameter description missing in @param tag in $file" | |
exit 1 | |
fi | |
fi | |
if grep -q "@returns" "$file"; then | |
if grep -q "@returns {\\[.*:.*\\]}" "$file"; then | |
tuple_vars=$(grep "@returns {\\[.*\\]}" "$file" | sed -E 's/.*\[(.*)\].*/\1/' | tr ',' '\n' | sed 's/^ //' | sed -E 's/([^:]): (.+)$/\1 \`\2\`/') | |
while read -r var_type; do | |
if ! grep -qe "- $var_type - .*;" "$file"; then | |
echo "Missing or invalid description for tuple member with [$var_type] in $file" | |
exit 1 | |
fi | |
done <<< "$tuple_vars" | |
else | |
if ! grep -q "@returns {.*}" "$file"; then | |
echo "Return type missing in @returns tag in $file" | |
exit 1 | |
fi | |
fi | |
fi | |
done | |
verify-exports: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Check exports | |
run: | | |
IMPL_DIRS=("components" "hooks" "utils") | |
ROOT_INDEX="src/index.ts" | |
ERROR_LOG="" | |
HAS_ERROR=0 | |
for dir in "${IMPL_DIRS[@]}"; do | |
for impl_dir in src/$dir/*/; do | |
if [ ! -d "$impl_dir" ]; then | |
continue | |
fi | |
impl_name=$(basename "$impl_dir") | |
impl_index="$impl_dir/index.ts" | |
impl_file="" | |
if [ -f "$impl_dir$impl_name.ts" ]; then | |
impl_file="$impl_name.ts" | |
elif [ -f "$impl_dir$impl_name.tsx" ]; then | |
impl_file="$impl_name.tsx" | |
else | |
ERROR_LOG+="❌ Implementation file not found for $impl_name\n" | |
HAS_ERROR=1 | |
continue | |
fi | |
if [ ! -f "$impl_index" ]; then | |
ERROR_LOG+="❌ Missing index.ts in $impl_dir\n" | |
HAS_ERROR=1 | |
fi | |
if ! grep -q "export.*from.*['\"]\./$impl_file['\"]" "$impl_index"; then | |
ERROR_LOG+="❌ $impl_name is not exported in $impl_index\n" | |
HAS_ERROR=1 | |
fi | |
relative_path="./$dir/$impl_name/index.ts" | |
if ! grep -q "export.*from.*['\"]$relative_path['\"]" "$ROOT_INDEX"; then | |
ERROR_LOG+="❌ $impl_name is not exported in root index.ts\n" | |
HAS_ERROR=1 | |
fi | |
done | |
done | |
if [ $HAS_ERROR -eq 1 ]; then | |
echo -e "\n🚨 Export Validation Errors:\n" | |
echo -e "$ERROR_LOG" | |
echo -e "\nPlease fix the above export issues." | |
exit 1 | |
else | |
echo "✅ All exports are valid!" | |
fi |