Skip to content

Add workflow for uploading dev builds of Plotly.js #7795

Open
emilykl wants to merge 2 commits intomasterfrom
persistent-dev-build-url-2
Open

Add workflow for uploading dev builds of Plotly.js #7795
emilykl wants to merge 2 commits intomasterfrom
persistent-dev-build-url-2

Conversation

@emilykl
Copy link
Copy Markdown
Contributor

@emilykl emilykl commented May 5, 2026

Closes #7759

  • Add new upload-dev-build.yml workflow which uploads a development build of plotly.js every time a new commit is pushed to a PR
  • Builds are uploaded to a private repo and made available via GitHub Pages at the following URLs:
    • https://plotly.github.io/plotly.js-dev-builds/upload/pr-{PR_NUM}/latest/plotly.min.js (for the latest commit on a PR)
    • https://plotly.github.io/plotly.js-dev-builds/upload/pr-{PR_NUM}/{SHA}/plotly.min.js (for a specific commit SHA on a PR)
    • */plotly.js and */plot-schema.json also work
  • Also split publish-dist jobs into a separate publish-dist.yml workflow, so that the upload-dev-build workflow can be triggered as soon as publish-dist finishes, without waiting for all the tests to complete

Steps for testing

  • Note: The workflow_run trigger always runs the version of the workflow on the default branch. This is an important security feature, but it means workflow_run won't allow us to test this implementation
  • Instead, manually trigger this workflow using the "Run workflow" button on this page
    • Select Branch: persistent-dev-build-url-2 (this branch)
    • Enter PR number 7795 (this PR) and Run ID 25395337702 (a completed run of the publish-dist workflow for this PR)
  • Wait for the run to complete. After it finishes, on the run page you should see an output containing the links. Here's an example from a previous run. It will take about 2-3 minutes for the GitHub Pages deployment to finish before the links become functional.
Screenshot 2026-05-05 at 2 46 36 PM

@emilykl emilykl requested a review from camdecoster May 5, 2026 18:47
@emilykl
Copy link
Copy Markdown
Contributor Author

emilykl commented May 5, 2026

@camdecoster FYI there are no major changes to the contents of the publish-dist workflow steps.

@@ -1,17 +1,117 @@
name: Upload dev build from PR (placeholder, not yet implemented)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: Upload dev build from PR

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of the (silly) way GHA woks, changing this title will break the link between this workflow file and the version on master. I'll update the title immediately before merging.

NODE_VERSION: '18'

jobs:
publish-dist:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's combine these two steps in a matrix configuration. They use (mostly) the same code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we even need the steps for both Node versions anymore? I'd be in favor of using Node 22 only. Not sure if there's any reason to keep 18, we can discuss.

Comment thread .github/workflows/upload-dev-build.yml
Comment thread .github/workflows/upload-dev-build.yml Outdated
fi

echo "Using SHA: $SHA"
mkdir -p "upload/pr-$PR_NUM/$SHA"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we include a metadata file that includes a timestamp inside the "pr-XXXX" folder to aid in eventually deleting old builds?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm betting we can get that metadata (last added/modified) through git itself or through the filesystem, so I would say let's not add it yet, but if it turns out to be necessary we can add it. I'm looking into it now.

Comment on lines +37 to +46
- name: Preview CHANGELOG for next release (only on master)
if: github.ref == 'refs/heads/master'
run: npm run use-draftlogs && git --no-pager diff --color-words CHANGELOG.md || true

- name: Set draft version in package.json
run: |
node --eval "var fs = require('fs'); var inOut = './package.json'; var data = JSON.parse(fs.readFileSync(inOut)); var a = process.argv; data.version = a[a.length - 1].replace('v', ''); fs.writeFileSync(inOut, JSON.stringify(data, null, 2) + '\n');" $(git describe)

- name: View package.json diff between previous and next releases
run: git --no-pager diff --color-words tags/$(git describe --tags --abbrev=0) package.json || true
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we even need these steps anymore? I migrated them over, but I don't think they're necessary.

Comment on lines +17 to +18
env:
NODE_VERSION: '18'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
env:
NODE_VERSION: '18'


- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: ${{ env.NODE_VERSION }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you combine steps, this would become moot.

Suggested change
node-version: ${{ env.NODE_VERSION }}
node-version: 18

Comment thread .github/workflows/upload-dev-build.yml Outdated
runs-on: ubuntu-latest
if: |
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'workflow_run' && github.event.workflow_run.event == 'pull_request')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(github.event_name == 'workflow_run' && github.event.workflow_run.event == 'pull_request')
(github.event_name == 'workflow_run' && github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success')

run: cp dist/plotly.js dist/plotly.node22.js

# Upload library uncompressed to allow for testing in REPLs
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this step

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Create long lived direct links to PR versions of library

2 participants