|
| 1 | +name: CDS Extractor Distribution Bundle |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + paths: |
| 7 | + - 'extractors/cds/**' |
| 8 | + pull_request: |
| 9 | + branches: [ main ] |
| 10 | + paths: |
| 11 | + - 'extractors/cds/**' |
| 12 | + workflow_dispatch: |
| 13 | + # This job can be manually triggered to validate the CDS extractor bundle |
| 14 | + |
| 15 | +jobs: |
| 16 | + bundle-validation: |
| 17 | + name: CDS extractor bundle validation |
| 18 | + runs-on: ubuntu-latest |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout repository |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Setup Node.js |
| 25 | + uses: actions/setup-node@v4 |
| 26 | + with: |
| 27 | + node-version: '20' |
| 28 | + cache: 'npm' |
| 29 | + cache-dependency-path: 'extractors/cds/tools/package-lock.json' |
| 30 | + |
| 31 | + - name: Install node dependencies |
| 32 | + working-directory: extractors/cds/tools |
| 33 | + run: npm ci |
| 34 | + |
| 35 | + - name: Run TS code linter |
| 36 | + working-directory: extractors/cds/tools |
| 37 | + run: npm run lint |
| 38 | + |
| 39 | + - name: Run TS code unit tests with coverage report |
| 40 | + working-directory: extractors/cds/tools |
| 41 | + run: npm run test:coverage |
| 42 | + |
| 43 | + - name: Build and validate the CDS extractor bundle |
| 44 | + working-directory: extractors/cds/tools |
| 45 | + run: npm run build:validate |
| 46 | + |
| 47 | + - name: Validate CDS extractor JS bundle and map files |
| 48 | + working-directory: extractors/cds/tools |
| 49 | + run: | |
| 50 | + _bundle_file="dist/cds-extractor.bundle.js" |
| 51 | + _bundle_map_file="${_bundle_file}.map" |
| 52 | + if [ -f "$_bundle_file" ]; then |
| 53 | + echo "✅ Bundle file exists." |
| 54 | + else |
| 55 | + echo "❌ Bundle file not found." |
| 56 | + exit 2 |
| 57 | + fi |
| 58 | +
|
| 59 | + if [ -f "$_bundle_map_file" ]; then |
| 60 | + echo "✅ CDS extractor JS bundle source map file exists." |
| 61 | + else |
| 62 | + echo "❌ CDS extractor JS bundle source map file not found." |
| 63 | + exit 3 |
| 64 | + fi |
| 65 | +
|
| 66 | + # Check if the built bundle and map files differ |
| 67 | + # from the versions committed to git. |
| 68 | + if git diff --exit-code "$_bundle_file" "$_bundle_map_file"; then |
| 69 | + echo "✅ CDS JS bundle and map files match committed versions." |
| 70 | + else |
| 71 | + echo "❌ CDS JS bundle and/or map file(s) differ from committed version(s)." |
| 72 | + echo "The built bundle and/or source map do not match the committed versions." |
| 73 | + echo "Please rebuild the bundle and commit the changes:" |
| 74 | + echo " cd extractors/cds/tools" |
| 75 | + echo " npm install" |
| 76 | + echo " npm run build:all" |
| 77 | + echo " git add dist/cds-extractor.bundle.*" |
| 78 | + echo " git commit -m 'Update CDS extractor dist bundle'" |
| 79 | + exit 4 |
| 80 | + fi |
| 81 | +
|
| 82 | + # Check if bundle file starts with the expected shebang for `node`. |
| 83 | + if head -n 1 "${_bundle_file}" | grep -q "#!/usr/bin/env node"; then |
| 84 | + echo "✅ Bundle has Node.js shebang" |
| 85 | + else |
| 86 | + echo "❌ Bundle missing Node.js shebang" |
| 87 | + exit 5 |
| 88 | + fi |
0 commit comments