Add helper to fetch SDK artifacts directly from Github #641
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: Examples | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main, new-try-it-now] | |
| merge_group: | |
| jobs: | |
| prepare-context: | |
| name: Prepare Example Build Context | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| # Needed to copy the WASM file during Docs MD build | |
| lfs: true | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "24" | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "pypy3.9" | |
| - name: Cache node_modules | |
| id: cache-node-modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: "**/node_modules" | |
| key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
| - name: Install dependencies | |
| if: steps.cache-node-modules.outputs.cache-hit != 'true' | |
| run: npm ci --ignore-scripts | |
| - name: Cache pip | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install Python dependencies | |
| run: | | |
| python -m pip install -r requirements.txt | |
| - name: Build Packages | |
| run: make build-packages | |
| - name: Archive build artifacts | |
| run: | | |
| tar -czf build-artifacts.tar.gz packages/compiler/dist packages/react/dist packages/shared/dist | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-artifacts | |
| path: build-artifacts.tar.gz | |
| verify-examples: | |
| name: Verify ${{ matrix.display }} | |
| runs-on: ubuntu-latest | |
| needs: prepare-context | |
| strategy: | |
| fail-fast: true | |
| matrix: | |
| include: | |
| - display: Docusaurus | |
| workspace: examples/docusaurus | |
| - display: Custom (Next.js) | |
| workspace: examples/custom | |
| - display: Nextra | |
| workspace: examples/nextra | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| lfs: true | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "24" | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "pypy3.9" | |
| - name: Cache pip | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install Python dependencies | |
| run: | | |
| python -m pip install -r requirements.txt | |
| - name: Restore node_modules cache | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: "**/node_modules" | |
| key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: build-artifacts | |
| - name: Restore build artifacts | |
| run: tar -xzf build-artifacts.tar.gz | |
| # Re-run install to link local binaries after build | |
| - name: Link local packages | |
| run: npm install --workspace ${{ matrix.workspace }} | |
| - name: Build example docs | |
| run: npm run build-api-docs --workspace ${{ matrix.workspace }} | |
| - name: Validate repository is clean | |
| run: | | |
| if ! git diff --exit-code --quiet ${{ matrix.workspace }}; then | |
| git status ${{ matrix.workspace }} | |
| git --no-pager diff ${{ matrix.workspace }} | |
| echo "Example build out of date for ${{ matrix.workspace }}. Please run make build-api-docs and commit the results." | |
| exit 1 | |
| fi | |
| verify-examples-success: | |
| name: Example Build Verification | |
| runs-on: ubuntu-latest | |
| needs: verify-examples | |
| if: always() | |
| steps: | |
| - name: Check if example docs builds successful | |
| if: needs.verify-examples.result != 'success' | |
| run: exit 1 |