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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/v2-build-demos-swc-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: V2 Build Demos for SWC Environment

on:
push:
# TODO: Remove 'test-v2-master' and 'test-v2-dev' for release
branches:
- master
- test-v2-master
Expand Down Expand Up @@ -80,3 +81,36 @@ jobs:
name: deployment_build_context
path: /tmp/merge
retention-days: 30

# Step 4: Build and upload the updated objects.inv files
build-objects-inv-file-dev:
# TODO: Change ref_name to 'dev' for release
if: (needs.identify-changed-demos.outputs.updated != '') && ${{ github.ref_name == 'test-v2-dev' }}
uses: ./.github/workflows/v2-sync-objects-dot-inv.yml
needs:
- identify-changed-demos
with:
branch: ${{ github.ref }}
dev: true

secrets:
aws_region: ${{ secrets.AWS_REGION }}
aws_access_key_id: ${{ secrets.PL_SITE_DEV_NON_REACT_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.PL_SITE_DEV_NON_REACT_SECRET_ACCESS_KEY }}
aws_html_s3_bucket_id: ${{ secrets.PL_SITE_DEV_S3_BUCKET_NAME }}

build-objects-inv-file-master:
# TODO: Change ref_name to 'master' for release
if: (needs.identify-changed-demos.outputs.updated != '') && ${{ github.ref_name == 'test-v2-master' }}
uses: ./.github/workflows/v2-sync-objects-dot-inv.yml
needs:
- identify-changed-demos
with:
branch: ${{ github.ref }}

secrets:
# TODO: Change STAGING to PROD for release
aws_region: ${{ secrets.AWS_REGION }}
aws_access_key_id: ${{ secrets.PL_SITE_STAGING_NON_REACT_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.PL_SITE_STAGING_NON_REACT_SECRET_ACCESS_KEY }}
aws_html_s3_bucket_id: ${{ secrets.PL_SITE_STAGING_S3_BUCKET_NAME }}
69 changes: 69 additions & 0 deletions .github/workflows/v2-sync-objects-dot-inv.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: V2 Sync objects.inv
on:
workflow_call:
inputs:
branch:
description: The QML branch that is being built.
type: string
required: true
dev:
description: Use development dependencies.
required: false
type: boolean
default: false

secrets:
aws_region:
description: The AWS Region the infrastructure resides in
required: true
aws_access_key_id:
description: AWS Access Key to use when accessing the S3 bucket
required: true
aws_secret_access_key:
description: AWS Secret Access Key to use when accessing the S3 bucket
required: true
aws_html_s3_bucket_id:
description: The S3 bucket ID where the objects.inv file will be pushed
required: true


jobs:
build-and-upload:
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
Comment on lines +32 to +69

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.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ demos_community.rst
.venv/
.venv-build/
**/*.egg-info/
sg_execution_times.rst

# Generated after installation
.github/workflows/qml_pipeline_utils/build/