|  | 
|  | 1 | +on: push | 
|  | 2 | + | 
|  | 3 | +jobs: | 
|  | 4 | + check-js-build: | 
|  | 5 | + name: Check JS build artifacts | 
|  | 6 | + runs-on: ubuntu-latest | 
|  | 7 | + steps: | 
|  | 8 | + - uses: actions/checkout@v4 | 
|  | 9 | + - name: Set up Python | 
|  | 10 | + uses: actions/setup-python@v5 | 
|  | 11 | + with: | 
|  | 12 | + python-version: "3.x" | 
|  | 13 | + | 
|  | 14 | + - name: Install Node | 
|  | 15 | + uses: actions/setup-node@v2 | 
|  | 16 | + with: | 
|  | 17 | + node-version: '22' | 
|  | 18 | + | 
|  | 19 | + - name: Copy current files to a temporary directory | 
|  | 20 | + run: | | 
|  | 21 | + cp -R plotly/labextension/ plotly/labextension-tmp/ | 
|  | 22 | + | 
|  | 23 | + - name: Install dependencies and build | 
|  | 24 | + run: | | 
|  | 25 | + curl -LsSf https://astral.sh/uv/install.sh | sh | 
|  | 26 | + uv venv | 
|  | 27 | + source .venv/bin/activate | 
|  | 28 | + uv pip install jupyter | 
|  | 29 | + cd js | 
|  | 30 | + npm ci | 
|  | 31 | + npm run build | 
|  | 32 | + - name: Check JupyterLab build artifacts | 
|  | 33 | + run: | | 
|  | 34 | + # 1. Hash contents of all static files, sort by content hash | 
|  | 35 | + find plotly/labextension/static -type f -exec sha256sum {} \; | awk '{print 1ドル}' | sort > new_hashes.txt | 
|  | 36 | + find plotly/labextension-tmp/static -type f -exec sha256sum {} \; | awk '{print 1ドル}' | sort > old_hashes.txt | 
|  | 37 | + | 
|  | 38 | + # 2. Compare the sorted content hashes | 
|  | 39 | + diff old_hashes.txt new_hashes.txt > content_diff.txt | 
|  | 40 | + | 
|  | 41 | + # Remove the "load" line from both package.json files before comparing | 
|  | 42 | + grep -v '"load": "static/' plotly/labextension/package.json > pkg1.json | 
|  | 43 | + grep -v '"load": "static/' plotly/labextension-tmp/package.json > pkg2.json | 
|  | 44 | + | 
|  | 45 | + # Compare stripped versions | 
|  | 46 | + diff pkg1.json pkg2.json > package_json_diff.txt | 
|  | 47 | + | 
|  | 48 | + # 5. Final check | 
|  | 49 | + if [ -s content_diff.txt ] || [ -s package_json_diff.txt ]; then | 
|  | 50 | + echo "❌ Build artifacts differ:" | 
|  | 51 | + echo "--- Unexpected diffs ---" | 
|  | 52 | + cat content_diff.txt | 
|  | 53 | + echo "--- Unexpected package.json diffs ---" | 
|  | 54 | + cat package_json_diff.txt | 
|  | 55 | + echo "Please replace the 'plotly/labextension' directory with the artifacts of this CI run." | 
|  | 56 | + exit 1 | 
|  | 57 | + else | 
|  | 58 | + echo "✅ Build artifacts match expected output (ignoring known 'load' hash in package.json)." | 
|  | 59 | + fi | 
|  | 60 | + | 
|  | 61 | + - name: Store the build artifacts from plotly/labextension | 
|  | 62 | + uses: actions/upload-artifact@v4 | 
|  | 63 | + if: failure() | 
|  | 64 | + with: | 
|  | 65 | + name: labextension | 
|  | 66 | + path: plotly/labextension | 
0 commit comments