Add initialWidth prop to Origin charts for SSR support
#2010
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: Test, release, and sync | |
| on: | |
| pull_request: | |
| paths: | |
| - "**" | |
| - ".github/workflows/**" | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - "**" | |
| - ".github/workflows/**" | |
| jobs: | |
| update-lock-file: | |
| # Only auto-update the lock file on the develop→main sync PR (where webdev | |
| # dependency changes land). All other PRs must commit a correct lock file | |
| # themselves — enforced by --immutable in downstream jobs. | |
| if: github.head_ref == 'develop' | |
| name: "Update lock file for develop→main sync PR" | |
| runs-on: "ubuntu-22.04" | |
| outputs: | |
| VERIFIED_LOCK_COMMIT: ${{ steps.sync-lock-file.outputs.VERIFIED_LOCK_COMMIT }} | |
| steps: | |
| - name: "Generate a token" | |
| id: generate-token | |
| uses: actions/create-github-app-token@v2 | |
| with: | |
| app-id: ${{ secrets.LIGHTSPARK_COPYBARA_APP_ID }} | |
| private-key: ${{ secrets.LIGHTSPARK_COPYBARA_PRIVATE_KEY }} | |
| owner: lightsparkdev | |
| repositories: js-sdk | |
| - name: "Checkout" | |
| uses: "actions/checkout@v3" | |
| with: | |
| # use branch name instead of triggering ref so we can commit to the PR branch: | |
| ref: ${{ github.head_ref }} | |
| fetch-depth: 2 | |
| # Use app token so lock file commits trigger CI re-runs | |
| # (GITHUB_TOKEN commits don't trigger workflows) | |
| token: ${{ steps.generate-token.outputs.token }} | |
| - name: "Setup Node" | |
| uses: "actions/setup-node@v4" | |
| env: | |
| SKIP_YARN_COREPACK_CHECK: true | |
| with: | |
| node-version: "20.x" | |
| - name: "Install dependencies with yarn cache" | |
| uses: ./.github/actions/yarn-nm-install | |
| with: | |
| cwd: "." | |
| install-mode: "update-lock-only" | |
| # Since we are in update-lock-only mode the resulting yarn cache is much smaller and less useful | |
| # for the rest of the steps. But since this is the first step and the cache is restored for each | |
| # step in the workflow, they all get the same useless cache unless we set a different prefix here: | |
| cache-prefix: "update-lock-file-for-prs" | |
| - name: "Commit and push changes if modified" | |
| id: sync-lock-file | |
| run: | | |
| if [[ $(git rev-parse --abbrev-ref HEAD) == "main" ]] && ! git diff-index --quiet HEAD; then | |
| echo "Lock file must not be modified by CI on main branch." | |
| exit 1; | |
| fi | |
| git config --global user.name 'Lightspark Eng' | |
| git config --global user.email 'engineering@lightspark.com' | |
| git add -A | |
| git diff-index --quiet HEAD || git commit -nm "CI update lock file for PR" | |
| git push | |
| echo "$(git rev-parse HEAD)" | |
| echo "VERIFIED_LOCK_COMMIT=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT | |
| checks: | |
| # Lint, format, type-check, package:checks — only needs to run on a modern Node. | |
| # Some dev tools (e.g. stylelint 17 via meow) require Node >= 20. | |
| needs: "update-lock-file" | |
| if: "!failure() && !cancelled()" | |
| runs-on: "ubuntu-22.04" | |
| steps: | |
| - name: "Checkout" | |
| uses: "actions/checkout@v3" | |
| with: | |
| ref: ${{ needs.update-lock-file.outputs.VERIFIED_LOCK_COMMIT || github.event.pull_request.head.sha || github.sha }} | |
| - name: "Setup Node" | |
| uses: "actions/setup-node@v4" | |
| env: | |
| SKIP_YARN_COREPACK_CHECK: true | |
| with: | |
| node-version: "22.x" | |
| - name: Install dependencies with yarn cache | |
| uses: ./.github/actions/yarn-nm-install | |
| with: | |
| cwd: "." | |
| - run: "yarn checks" | |
| - name: "Notify failure on Slack" | |
| if: "failure() && github.event_name == 'push'" | |
| run: | | |
| curl --data-binary @- --header "Content-Type: application/json" --silent "${{ secrets.SLACK_WEBHOOK_ENGINT }}" <<EOF | |
| { | |
| "text": ":x: ${{ github.workflow }} workflow by ${{ github.actor }} <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id}}|failed> in ${{ github.job }} on <${{ github.server_url }}/${{ github.repository }}/commit/$GITHUB_SHA|${{ github.ref_name }}>" | |
| } | |
| EOF | |
| # Unit tests run on the full Node matrix to verify runtime compatibility. | |
| test: | |
| needs: "update-lock-file" | |
| if: "!failure() && !cancelled()" | |
| runs-on: "ubuntu-22.04" | |
| strategy: | |
| matrix: | |
| node-version: ["18.x", "22.x"] | |
| steps: | |
| - name: "Checkout" | |
| uses: "actions/checkout@v3" | |
| with: | |
| ref: ${{ needs.update-lock-file.outputs.VERIFIED_LOCK_COMMIT || github.event.pull_request.head.sha || github.sha }} | |
| - name: "Setup Node v${{ matrix.node-version }}" | |
| uses: "actions/setup-node@v4" | |
| env: | |
| SKIP_YARN_COREPACK_CHECK: true | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| - name: Install dependencies with yarn cache | |
| uses: ./.github/actions/yarn-nm-install | |
| with: | |
| cwd: "." | |
| - name: Setup .lightsparkenv file | |
| run: | | |
| echo 'export LIGHTSPARK_WALLET_BASE_URL="api.dev.dev.sparkinfra.net"' > ~/.lightsparkenv | |
| echo 'export LIGHTSPARK_ACCOUNT_ID="${{ secrets.LIGHTSPARK_TEST_ACCOUNT_ID }}"' >> ~/.lightsparkenv | |
| echo 'export LIGHTSPARK_JWT_PRIV_KEY="${{ secrets.LIGHTSPARK_TEST_ACCOUNT_JWT_PRIV_KEY }}"' >> ~/.lightsparkenv | |
| echo 'export LIGHTSPARK_JWT_PUB_KEY="${{ secrets.LIGHTSPARK_TEST_ACCOUNT_JWT_PUB_KEY }}"' >> ~/.lightsparkenv | |
| - name: Setup .lightsparkapienv file | |
| run: | | |
| echo 'export LIGHTSPARK_API_TOKEN_CLIENT_ID="${{ secrets.LIGHTSPARK_TEST_ACCOUNT_API_TOKEN_CLIENT_ID }}"' > ~/.lightsparkapienv | |
| echo 'export LIGHTSPARK_API_TOKEN_CLIENT_SECRET="${{ secrets.LIGHTSPARK_TEST_ACCOUNT_API_TOKEN_CLIENT_SECRET }}"' >> ~/.lightsparkapienv | |
| echo 'export BITCOIN_NETWORK="REGTEST"' >> ~/.lightsparkapienv | |
| echo 'export LIGHTSPARK_BASE_URL="https://api.dev.dev.sparkinfra.net"' >> ~/.lightsparkapienv | |
| - name: "Run tests" | |
| run: | | |
| if [[ "${{ matrix.node-version }}" == "18.x" ]]; then | |
| # Origin's vitest config requires Node >= 20 (styleText from node:util) | |
| yarn test-cmd --filter='!@lightsparkdev/origin' | |
| else | |
| yarn test-cmd | |
| fi | |
| - name: "Notify failure on Slack" | |
| if: "failure() && github.event_name == 'push'" | |
| run: | | |
| curl --data-binary @- --header "Content-Type: application/json" --silent "${{ secrets.SLACK_WEBHOOK_ENGINT }}" <<EOF | |
| { | |
| "text": ":x: ${{ github.workflow }} workflow by ${{ github.actor }} <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id}}|failed> in ${{ github.job }} on <${{ github.server_url }}/${{ github.repository }}/commit/$GITHUB_SHA|${{ github.ref_name }}>" | |
| } | |
| EOF | |
| # turbo doesn't seem to parallelize builds with checks although they don't depend on one another, | |
| # or else there's something in CI that prevents it from doing it well. Faster to keep them separate. | |
| build: | |
| needs: "update-lock-file" | |
| if: "!failure() && !cancelled()" | |
| runs-on: "ubuntu-22.04" | |
| steps: | |
| - name: "Checkout" | |
| uses: "actions/checkout@v3" | |
| with: | |
| ref: ${{ needs.update-lock-file.outputs.VERIFIED_LOCK_COMMIT || github.event.pull_request.head.sha || github.sha }} | |
| - name: "Setup Node" | |
| uses: "actions/setup-node@v4" | |
| env: | |
| SKIP_YARN_COREPACK_CHECK: true | |
| with: | |
| node-version: "22.x" | |
| - name: Install dependencies with yarn cache | |
| uses: ./.github/actions/yarn-nm-install | |
| with: | |
| cwd: "." | |
| - run: "yarn build" | |
| - name: "Notify failure on Slack" | |
| if: "failure() && github.event_name == 'push'" | |
| run: | | |
| curl --data-binary @- --header "Content-Type: application/json" --silent "${{ secrets.SLACK_WEBHOOK_ENGINT }}" <<EOF | |
| { | |
| "text": ":x: ${{ github.workflow }} workflow by ${{ github.actor }} <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id}}|failed> in ${{ github.job }} on <${{ github.server_url }}/${{ github.repository }}/commit/$GITHUB_SHA|${{ github.ref_name }}>" | |
| } | |
| EOF | |
| release: | |
| name: Release | |
| needs: ["checks", "test", "build"] | |
| permissions: | |
| id-token: write | |
| contents: write | |
| pull-requests: write | |
| if: "!failure() && !cancelled() && github.event_name == 'push'" | |
| runs-on: "ubuntu-22.04" | |
| environment: npm | |
| steps: | |
| - name: Checkout Repo | |
| uses: actions/checkout@v3 | |
| - name: "Setup Node" | |
| uses: "actions/setup-node@v4" | |
| env: | |
| SKIP_YARN_COREPACK_CHECK: true | |
| with: | |
| # npm trusted publishing requires node >=22.14.0 | |
| node-version: "24" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Install dependencies with yarn cache | |
| uses: ./.github/actions/yarn-nm-install | |
| with: | |
| cwd: "." | |
| - name: Create Release Pull Request or Publish to npm | |
| id: changesets | |
| uses: changesets/action@v1 | |
| with: | |
| # This expects you to have a script called release which does a build for your packages and calls changeset publish | |
| publish: yarn release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # If the Version Packages PR has been created in the changesets step we should check if our workspace | |
| # package.json files have been updated from dependency bumps and update the lock file if so: | |
| - name: "Install dependencies with yarn cache" | |
| id: update-lock-file-for-version-packages-pr | |
| if: steps.changesets.outputs.published == 'false' && github.ref == 'refs/heads/main' | |
| uses: ./.github/actions/yarn-nm-install | |
| with: | |
| cwd: "." | |
| install-mode: "update-lock-only" | |
| # check if previous step updated the lock file and commit and push if so: | |
| - name: Update lock file for Version Packages PR | |
| if: steps.changesets.outputs.published == 'false' && github.ref == 'refs/heads/main' | |
| run: | | |
| if git ls-remote --exit-code --heads origin changeset-release/main; then | |
| git fetch origin changeset-release/main | |
| if git show-ref --quiet changeset-release/main; then | |
| git checkout changeset-release/main | |
| git push --set-upstream origin changeset-release/main | |
| git config --global user.name 'Lightspark Eng' | |
| git config --global user.email 'engineering@lightspark.com' | |
| git add -A | |
| git diff-index --quiet HEAD || git commit -nm "CI update lock file for PR" | |
| git push | |
| echo "$(git rev-parse HEAD)" | |
| else | |
| echo "changeset-release/main branch does not exist locally." | |
| fi | |
| else | |
| echo "changeset-release/main branch does not exist on remote." | |
| fi | |
| - name: Notify publish on Slack | |
| if: steps.changesets.outputs.published == 'true' | |
| # You can do something when a publish happens. | |
| run: | | |
| json_escape () { | |
| printf '%s' "$1" | python -c 'import json,sys; print(json.dumps(sys.stdin.read()))' | |
| } | |
| format_packages() { | |
| local json_input="$1" | |
| local formatted_output | |
| formatted_output=$(python -c "import json; data = $json_input; formatted_data = [f\"{item['name'].replace('@lightsparkdev/', '')}@{item['version']}\" for item in data]; print(', '.join(formatted_data))") | |
| echo "$formatted_output" | |
| } | |
| formatted_packages=$(format_packages '${{ steps.changesets.outputs.publishedPackages }}') | |
| text=$(json_escape ":white_check_mark: ${{ github.actor }} <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id}}|published> new js-sdk versions from <${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ github.ref_name }}|${{ github.ref_name }}>: $formatted_packages") | |
| curl --data-binary @- --header "Content-Type: application/json" --silent "${{ secrets.SLACK_WEBHOOK_ENGINT }}" <<EOF | |
| { | |
| "text": $text | |
| } | |
| EOF | |
| - name: "Notify failure on Slack" | |
| if: "failure() && github.event_name == 'push'" | |
| run: | | |
| curl --data-binary @- --header "Content-Type: application/json" --silent "${{ secrets.SLACK_WEBHOOK_ENGINT }}" <<EOF | |
| { | |
| "text": ":x: js-sdk public repo: ${{ github.workflow }} workflow by ${{ github.actor }} <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id}}|failed> in ${{ github.job }} on <${{ github.server_url }}/${{ github.repository }}/commit/$GITHUB_SHA|${{ github.ref_name }}>" | |
| } | |
| EOF | |
| create-webdev-pr: | |
| name: Create Webdev PR | |
| if: "github.event_name == 'push'" | |
| runs-on: "ubuntu-22.04" | |
| environment: npm | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout Repo | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Reset develop to main | |
| run: | | |
| git checkout develop | |
| git reset --hard origin/main | |
| git push origin develop --force | |
| git checkout main | |
| - name: Generate a token | |
| id: generate_token | |
| uses: actions/create-github-app-token@v2 | |
| with: | |
| app-id: ${{ secrets.LIGHTSPARK_COPYBARA_APP_ID }} | |
| private-key: ${{ secrets.LIGHTSPARK_COPYBARA_PRIVATE_KEY }} | |
| owner: lightsparkdev | |
| repositories: | | |
| js-sdk | |
| webdev | |
| permissions: | | |
| contents: write | |
| workflows: write | |
| - name: "Run Copybara" | |
| env: | |
| TOKEN: ${{ steps.generate_token.outputs.token }} | |
| run: | | |
| ls -la | |
| git config --global user.name 'Lightspark Eng' | |
| git config --global user.email 'engineering@lightspark.com' | |
| echo "https://x-access-token:${TOKEN}@github.com" > ~/.git-credentials | |
| on_exit() { | |
| # See this for possible error codes from Copybara https://github.com/google/copybara/issues/236 | |
| exit_code=$? | |
| case $exit_code in | |
| 0) | |
| echo "Copybara completed successfully" | |
| exit 0 | |
| ;; | |
| 4) | |
| echo "Copybara completed with no changes detected, exiting 0" | |
| exit 0 | |
| ;; | |
| *) | |
| echo "Copybara failed with exit code $exit_code" | |
| exit $exit_code | |
| ;; | |
| esac | |
| } | |
| curl https://lsdev-repo.s3-us-west-2.amazonaws.com/github-actions/copybara_deploy.jar --output ./copybara.jar | |
| trap on_exit EXIT | |
| java -jar copybara.jar ./copy.bara.sky js-sdk-push-to-webdev --nogit-destination-rebase | |
| - name: "Notify failure on Slack" | |
| if: "failure() && github.event_name == 'push'" | |
| run: | | |
| curl --data-binary @- --header "Content-Type: application/json" --silent "${{ secrets.SLACK_WEBHOOK_ENGINT }}" <<EOF | |
| { | |
| "text": ":x: ${{ github.workflow }} workflow by ${{ github.actor }} <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id}}|failed> in ${{ github.job }} on <${{ github.server_url }}/${{ github.repository }}/commit/$GITHUB_SHA|${{ github.ref_name }}>" | |
| } | |
| EOF |