Skip to content

Add V2 objects.inv workflow #1435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

doctorperceptron
Copy link
Contributor

@doctorperceptron doctorperceptron commented Jul 10, 2025

The objects.inv file is generated by Sphinx and is used to enable easy syntax for referencing demos from the PennyLane docs.

This PR adds a workflow that builds all demos in a specified branch and uploads the generated objects.in file to s3. The v2-build-demos-swc-env workflow calls this workflow after merges to master or dev (currently using testing branches), so that the objects.inv files are created and uploaded whenever new demos are deployed to those environments.

This new workflow is set to run on merges to the two testing branches, test-v2-master and test-v2-dev. We don't have testing buckets though, so merges to the test-v2-dev branch will push the objects.inv file to the dev bucket, while merges to the test-v2-master branch will push the objects.inv file to the staging bucket. Because this will push to the dev environment, we should hold off on merging this until after PennyLane v0.42.0 is released next week, or merge before then but refrain from testing the dev version of this workflow until then.

Note: I've been executing a lot of demos locally and am getting annoyed by the generated sg_execution_times.rst file tainting my branch, so I've also added this to .gitignore.

@doctorperceptron doctorperceptron marked this pull request as ready for review July 11, 2025 14:19
@doctorperceptron doctorperceptron changed the title Add objects.inv workflow Add V2 objects.inv workflow Jul 11, 2025
Comment on lines +32 to +69
runs-on: ubuntu-latest
env:
AWS_REGION: ${{ secrets.aws_region }}
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key_id }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }}
AWS_S3_HTML_BUCKET_ID: ${{ secrets.aws_html_s3_bucket_id }}

steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
fetch-depth: 1

- name: Install pandoc and opencl
run: |
sudo apt-get install -y \
ocl-icd-opencl-dev \
pandoc

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install dependencies
run: pip install . && poetry config warnings.export false

- name: Build all demos in HTML format
run: |
qml build \
--format html \
--keep-going \
--no-quiet \
${{ inputs.dev && '--dev' || '--no-dev' }}

- name: Sync objects.inv to HTML Bucket
run: aws s3 cp ./_build/objects.inv s3://$AWS_S3_HTML_BUCKET_ID/qml/objects.inv

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 5 days ago

To fix this issue, we need to explicitly define the permissions key at the workflow level to limit the GITHUB_TOKEN permissions. From the workflow's logic, it primarily interacts with AWS and performs build processes, which do not require GitHub API write permissions. The contents permission can be set to read since the workflow checks out the repository contents. No other GitHub API permissions appear necessary.

The fix involves adding a permissions block at the root of the workflow file (before the jobs block). This ensures that all jobs in the workflow inherit these minimal permissions unless overridden.

Suggested changeset 1
.github/workflows/v2-sync-objects-dot-inv.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/v2-sync-objects-dot-inv.yml b/.github/workflows/v2-sync-objects-dot-inv.yml
--- a/.github/workflows/v2-sync-objects-dot-inv.yml
+++ b/.github/workflows/v2-sync-objects-dot-inv.yml
@@ -1,3 +1,5 @@
+permissions:
+  contents: read
 name: V2 Sync objects.inv
 on:
   workflow_call:
EOF
@@ -1,3 +1,5 @@
permissions:
contents: read
name: V2 Sync objects.inv
on:
workflow_call:
Copilot is powered by AI and may make mistakes. Always verify output.
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.

1 participant