From b084fc693553a713a44db7d908b7fe69d0cdd272 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Mon, 14 Apr 2025 17:22:05 -0400 Subject: [PATCH 01/60] scaffold --- .github/workflows/build-v2-pr.yml | 41 +++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/build-v2-pr.yml diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml new file mode 100644 index 0000000000..98f0db2ae0 --- /dev/null +++ b/.github/workflows/build-v2-pr.yml @@ -0,0 +1,41 @@ +# AC: +# - v2_build_demos workflow runs when a commit is pushed to a pull request +# - Only changed/added demos should be built on a commit +# - Changed demos are deployed as previews +# - PRs targeting the dev branch use development dependencies +# - PRs targeting master use the stable dependencies (constraints.txt) + +# We want to create a Workflow that runs on pull requests to the dev branch and master branch +# depending on if the branch is dev or master, we want to use different dependencies +# we want to use the stable dependencies for master and the development dependencies for dev, so we will need to check the branch being targeted and determine which dependencies to use. The workflow "Build V2 Demos" has a bool variable for this + +name: Build V2 Demos on Pull Request +on: + pull_request: + branches: + - dev + - master + +concurrency: + group: build-v2-demos + cancel-in-progress: true + +jobs: + set_build_params: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Get Changed Demos + run: echo "I will eventually get the changed demos" + + - name: Make and echo saying dev requirements + run: echo "I will eventually make and echo saying dev requirements" + if: github.event.pull_request.base.ref == 'dev' + + - name: Make and echo saying master requirements + run: echo "I will eventually make and echo saying master requirements" + if: github.event.pull_request.base.ref == 'master' + From 2e162d6604ce486061cf04341fe8cf28e56256bd Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Tue, 15 Apr 2025 09:07:29 -0400 Subject: [PATCH 02/60] fmt --- .github/workflows/build-v2-pr.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml index 98f0db2ae0..ca5ceb727c 100644 --- a/.github/workflows/build-v2-pr.yml +++ b/.github/workflows/build-v2-pr.yml @@ -10,14 +10,14 @@ # we want to use the stable dependencies for master and the development dependencies for dev, so we will need to check the branch being targeted and determine which dependencies to use. The workflow "Build V2 Demos" has a bool variable for this name: Build V2 Demos on Pull Request + on: pull_request: - branches: - - dev - - master + branches: [master, dev] + # Runs on pull requests where the target branch is dev or master concurrency: - group: build-v2-demos + group: build-v2-demos-${{ github.ref }} cancel-in-progress: true jobs: @@ -32,10 +32,10 @@ jobs: run: echo "I will eventually get the changed demos" - name: Make and echo saying dev requirements - run: echo "I will eventually make and echo saying dev requirements" + run: echo "I will run the dev requirements" if: github.event.pull_request.base.ref == 'dev' - name: Make and echo saying master requirements - run: echo "I will eventually make and echo saying master requirements" + run: echo "I will run the master requirements" if: github.event.pull_request.base.ref == 'master' From 4b20c963edaf2cf8274cfce0902155f3723ab9e7 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Tue, 15 Apr 2025 09:20:34 -0400 Subject: [PATCH 03/60] test --- .github/workflows/build-v2-pr.yml | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml index ca5ceb727c..c023b2737c 100644 --- a/.github/workflows/build-v2-pr.yml +++ b/.github/workflows/build-v2-pr.yml @@ -21,21 +21,14 @@ concurrency: cancel-in-progress: true jobs: - set_build_params: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Get Changed Demos - run: echo "I will eventually get the changed demos" - - - name: Make and echo saying dev requirements - run: echo "I will run the dev requirements" - if: github.event.pull_request.base.ref == 'dev' - - - name: Make and echo saying master requirements - run: echo "I will run the master requirements" - if: github.event.pull_request.base.ref == 'master' - + build: + uses: ./.github/workflows/v2-build-demos.yml + with: + ref: ${{ github.sha }} + demo-names: 'qrack, gbs' + dev: ${{ github.event.pull_request.base.ref == 'dev' }} + save-artifact: true + artifact-name: demo-build-${{ github.sha }} + keep-going: false + quiet: false + batch_size: 10 From d08388b83df3ef043cb6af5f6ec5ea1baaaf6a05 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Tue, 15 Apr 2025 09:22:51 -0400 Subject: [PATCH 04/60] typo --- .github/workflows/build-v2-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml index c023b2737c..4be4a2bd6d 100644 --- a/.github/workflows/build-v2-pr.yml +++ b/.github/workflows/build-v2-pr.yml @@ -25,7 +25,7 @@ jobs: uses: ./.github/workflows/v2-build-demos.yml with: ref: ${{ github.sha }} - demo-names: 'qrack, gbs' + demo-names: 'qrack gbs' dev: ${{ github.event.pull_request.base.ref == 'dev' }} save-artifact: true artifact-name: demo-build-${{ github.sha }} From 04186c36e7800bd9f8ef70e86291e93890152c3f Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Tue, 15 Apr 2025 10:10:11 -0400 Subject: [PATCH 05/60] add fork check --- .github/workflows/build-v2-pr.yml | 44 ++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml index 4be4a2bd6d..8cdbd64853 100644 --- a/.github/workflows/build-v2-pr.yml +++ b/.github/workflows/build-v2-pr.yml @@ -22,13 +22,37 @@ concurrency: jobs: build: - uses: ./.github/workflows/v2-build-demos.yml - with: - ref: ${{ github.sha }} - demo-names: 'qrack gbs' - dev: ${{ github.event.pull_request.base.ref == 'dev' }} - save-artifact: true - artifact-name: demo-build-${{ github.sha }} - keep-going: false - quiet: false - batch_size: 10 + runs-on: ubuntu-latest + + steps: + # If a PR is a fork, we need do not run the workflow, all external demo submissions + # should be done via fork but require a review before merged into a branch for testing and secondary review/ a final review.cancel-timeout-minutes: + + # Example of a PR that is a fork and what a user would see if they tried to run the workflow + + # User forks the repo and creates a PR to the dev branch + # If the PR is a fork, we need to cancel the workflow and comment on the PR + - name: Check if PR is a fork + if: github.event.pull_request.head.repo.full_name != github.repository + run: | + echo "This workflow does not run on forks, and requires a review before being merged into a branch for testing and secondary or final review." + exit 1 + + - name: Get Changed Demos + id: changed_demos + uses: ./.github/actions/get-changed-demos + with: + json: true + + - name: Build + uses: ./.github/workflows/v2-build-demos.yml + with: + ref: ${{ github.event.pull_request.head.sha }} + demo-names: ${{ steps.changed_demos.outputs.updated }} + dev: ${{ github.event.pull_request.base.ref == 'dev' }} + save-artifact: true + artifact-name: demo-build-${{ github.event.pull_request.head.sha }} + keep-going: false + quiet: false + batch_size: 10 + \ No newline at end of file From 26d038968cd4a3718c9aeb479e66689a06739e81 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Tue, 15 Apr 2025 10:20:09 -0400 Subject: [PATCH 06/60] correct the path, add pseudo steps --- .github/workflows/build-v2-pr.yml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml index 8cdbd64853..cfa875420f 100644 --- a/.github/workflows/build-v2-pr.yml +++ b/.github/workflows/build-v2-pr.yml @@ -40,7 +40,7 @@ jobs: - name: Get Changed Demos id: changed_demos - uses: ./.github/actions/get-changed-demos + uses: ./.github/actions/get-changed-demos/action.yml with: json: true @@ -55,4 +55,19 @@ jobs: keep-going: false quiet: false batch_size: 10 - \ No newline at end of file + + deploy: + runs-on: ubuntu-latest + needs: build + if: github.event.pull_request.base.ref == 'dev' || github.event.pull_request.base.ref == 'master' + steps: + # Pseudo code for deploying the demos — echos + - name: Upload demos + run: | + echo "Deploying demos to the server" + + - name: Post comment of preview link (Maybe?) + run: | + echo "Post a comment on the PR with the link to the preview" + echo "Comment posted on PR with preview link" + echo of all the demos that were built and their links \ No newline at end of file From 4895a8904a8c29854818d700fa2350be31806c0b Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Tue, 15 Apr 2025 10:26:20 -0400 Subject: [PATCH 07/60] missed checkout? --- .github/workflows/build-v2-pr.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml index cfa875420f..ddaf3734d1 100644 --- a/.github/workflows/build-v2-pr.yml +++ b/.github/workflows/build-v2-pr.yml @@ -32,6 +32,9 @@ jobs: # User forks the repo and creates a PR to the dev branch # If the PR is a fork, we need to cancel the workflow and comment on the PR + - name: Checkout + uses: actions/checkout@v4 + - name: Check if PR is a fork if: github.event.pull_request.head.repo.full_name != github.repository run: | From 778eab6a26e8ae38dc251bfc21ea340fffbe6a75 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Tue, 15 Apr 2025 10:44:56 -0400 Subject: [PATCH 08/60] ?? --- .github/workflows/build-v2-pr.yml | 42 ++++++++++--------------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml index ddaf3734d1..4bb582b7fc 100644 --- a/.github/workflows/build-v2-pr.yml +++ b/.github/workflows/build-v2-pr.yml @@ -21,29 +21,22 @@ concurrency: cancel-in-progress: true jobs: - build: + build-and-deploy: runs-on: ubuntu-latest steps: - # If a PR is a fork, we need do not run the workflow, all external demo submissions - # should be done via fork but require a review before merged into a branch for testing and secondary review/ a final review.cancel-timeout-minutes: - - # Example of a PR that is a fork and what a user would see if they tried to run the workflow - - # User forks the repo and creates a PR to the dev branch - # If the PR is a fork, we need to cancel the workflow and comment on the PR - - name: Checkout - uses: actions/checkout@v4 - - name: Check if PR is a fork if: github.event.pull_request.head.repo.full_name != github.repository run: | echo "This workflow does not run on forks, and requires a review before being merged into a branch for testing and secondary or final review." exit 1 + - name: Checkout + uses: actions/checkout@v4 + - name: Get Changed Demos - id: changed_demos - uses: ./.github/actions/get-changed-demos/action.yml + id: changed-demos + uses: ./.github/actions/get-changed-demos with: json: true @@ -51,26 +44,17 @@ jobs: uses: ./.github/workflows/v2-build-demos.yml with: ref: ${{ github.event.pull_request.head.sha }} - demo-names: ${{ steps.changed_demos.outputs.updated }} + demo-names: ${{ steps.changed-demos.outputs.updated }} dev: ${{ github.event.pull_request.base.ref == 'dev' }} save-artifact: true artifact-name: demo-build-${{ github.event.pull_request.head.sha }} keep-going: false quiet: false batch_size: 10 - - deploy: - runs-on: ubuntu-latest - needs: build - if: github.event.pull_request.base.ref == 'dev' || github.event.pull_request.base.ref == 'master' - steps: - # Pseudo code for deploying the demos — echos - - name: Upload demos - run: | - echo "Deploying demos to the server" - - - name: Post comment of preview link (Maybe?) + + - name: Deploy run: | - echo "Post a comment on the PR with the link to the preview" - echo "Comment posted on PR with preview link" - echo of all the demos that were built and their links \ No newline at end of file + # Deploy the built demos to a preview environment + # This is a placeholder for the actual deployment step + echo "Deploying demos..." + # Add your deployment commands here From 799a7c8335e3fc6ed791c4ad1607c3c63c96a2fc Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Tue, 15 Apr 2025 10:51:35 -0400 Subject: [PATCH 09/60] check --- .github/workflows/build-v2-pr.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml index 4bb582b7fc..4223a5348d 100644 --- a/.github/workflows/build-v2-pr.yml +++ b/.github/workflows/build-v2-pr.yml @@ -34,11 +34,11 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Get Changed Demos - id: changed-demos - uses: ./.github/actions/get-changed-demos - with: - json: true + # - name: Get Changed Demos + # id: changed-demos + # uses: ./.github/actions/get-changed-demos + # with: + # json: true - name: Build uses: ./.github/workflows/v2-build-demos.yml From 201d0e764a503a0fd8fed18eaa526c631c5fc1aa Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Tue, 15 Apr 2025 10:51:59 -0400 Subject: [PATCH 10/60] test --- .github/workflows/build-v2-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml index 4223a5348d..296c34158c 100644 --- a/.github/workflows/build-v2-pr.yml +++ b/.github/workflows/build-v2-pr.yml @@ -44,7 +44,7 @@ jobs: uses: ./.github/workflows/v2-build-demos.yml with: ref: ${{ github.event.pull_request.head.sha }} - demo-names: ${{ steps.changed-demos.outputs.updated }} + demo-names: 'gbs' dev: ${{ github.event.pull_request.base.ref == 'dev' }} save-artifact: true artifact-name: demo-build-${{ github.event.pull_request.head.sha }} From 7b28cded45fd0fe89a3e9658d4c96fdc8ed35299 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Tue, 15 Apr 2025 10:52:48 -0400 Subject: [PATCH 11/60] again --- .github/workflows/build-v2-pr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml index 296c34158c..5f9ad33475 100644 --- a/.github/workflows/build-v2-pr.yml +++ b/.github/workflows/build-v2-pr.yml @@ -31,8 +31,8 @@ jobs: echo "This workflow does not run on forks, and requires a review before being merged into a branch for testing and secondary or final review." exit 1 - - name: Checkout - uses: actions/checkout@v4 + # - name: Checkout + # uses: actions/checkout@v4 # - name: Get Changed Demos # id: changed-demos From 6be650b829e9792cff73f76788a041c91757f896 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Tue, 15 Apr 2025 10:55:44 -0400 Subject: [PATCH 12/60] again --- .github/workflows/build-v2-pr.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml index 5f9ad33475..86da35b4ac 100644 --- a/.github/workflows/build-v2-pr.yml +++ b/.github/workflows/build-v2-pr.yml @@ -31,14 +31,14 @@ jobs: echo "This workflow does not run on forks, and requires a review before being merged into a branch for testing and secondary or final review." exit 1 - # - name: Checkout - # uses: actions/checkout@v4 + - name: Checkout + uses: actions/checkout@v4 - # - name: Get Changed Demos - # id: changed-demos - # uses: ./.github/actions/get-changed-demos - # with: - # json: true + - name: Get Changed Demos + id: changed-demos + uses: ./.github/actions/get-changed-demos + with: + json: true - name: Build uses: ./.github/workflows/v2-build-demos.yml From 03952950c86b203f988ac56a98d07e83a8c06092 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Tue, 15 Apr 2025 10:56:53 -0400 Subject: [PATCH 13/60] trigger ci --- .github/workflows/build-v2-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml index 86da35b4ac..4bb582b7fc 100644 --- a/.github/workflows/build-v2-pr.yml +++ b/.github/workflows/build-v2-pr.yml @@ -44,7 +44,7 @@ jobs: uses: ./.github/workflows/v2-build-demos.yml with: ref: ${{ github.event.pull_request.head.sha }} - demo-names: 'gbs' + demo-names: ${{ steps.changed-demos.outputs.updated }} dev: ${{ github.event.pull_request.base.ref == 'dev' }} save-artifact: true artifact-name: demo-build-${{ github.event.pull_request.head.sha }} From 2bb3a6ee0507a6a358b2a0e2bd3f683c5d9744ee Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Tue, 15 Apr 2025 11:01:05 -0400 Subject: [PATCH 14/60] trigger --- .github/workflows/build-v2-pr.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml index 4bb582b7fc..bae2ce4f1d 100644 --- a/.github/workflows/build-v2-pr.yml +++ b/.github/workflows/build-v2-pr.yml @@ -40,17 +40,18 @@ jobs: with: json: true - - name: Build + - name: Build V2 Demos uses: ./.github/workflows/v2-build-demos.yml with: ref: ${{ github.event.pull_request.head.sha }} - demo-names: ${{ steps.changed-demos.outputs.updated }} + demo-names: ${{ steps.changed-demos.outputs.changed-demos }} dev: ${{ github.event.pull_request.base.ref == 'dev' }} save-artifact: true artifact-name: demo-build-${{ github.event.pull_request.head.sha }} keep-going: false quiet: false batch_size: 10 + - name: Deploy run: | From 04b17eef1c15315a6e7acec6d0a6e5e7e8f6a024 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Tue, 15 Apr 2025 11:06:01 -0400 Subject: [PATCH 15/60] trigger, add debug --- .github/workflows/build-v2-pr.yml | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml index bae2ce4f1d..da539f63b3 100644 --- a/.github/workflows/build-v2-pr.yml +++ b/.github/workflows/build-v2-pr.yml @@ -1,20 +1,8 @@ -# AC: -# - v2_build_demos workflow runs when a commit is pushed to a pull request -# - Only changed/added demos should be built on a commit -# - Changed demos are deployed as previews -# - PRs targeting the dev branch use development dependencies -# - PRs targeting master use the stable dependencies (constraints.txt) - -# We want to create a Workflow that runs on pull requests to the dev branch and master branch -# depending on if the branch is dev or master, we want to use different dependencies -# we want to use the stable dependencies for master and the development dependencies for dev, so we will need to check the branch being targeted and determine which dependencies to use. The workflow "Build V2 Demos" has a bool variable for this - name: Build V2 Demos on Pull Request on: pull_request: branches: [master, dev] - # Runs on pull requests where the target branch is dev or master concurrency: group: build-v2-demos-${{ github.ref }} @@ -33,7 +21,12 @@ jobs: - name: Checkout uses: actions/checkout@v4 - + with: + fetch-depth: 0 + + - name: List workspace contents + run: ls -R .github + - name: Get Changed Demos id: changed-demos uses: ./.github/actions/get-changed-demos @@ -52,10 +45,6 @@ jobs: quiet: false batch_size: 10 - - name: Deploy run: | - # Deploy the built demos to a preview environment - # This is a placeholder for the actual deployment step - echo "Deploying demos..." - # Add your deployment commands here + echo "Deploying demos..." \ No newline at end of file From 87767827eeff68d0f0067d5a8c868d22ef9eaa28 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Tue, 15 Apr 2025 11:47:04 -0400 Subject: [PATCH 16/60] step fails, try moving to job --- .github/workflows/build-v2-pr.yml | 52 +++++++++++++++++-------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml index da539f63b3..ebf1a4b8dd 100644 --- a/.github/workflows/build-v2-pr.yml +++ b/.github/workflows/build-v2-pr.yml @@ -1,5 +1,4 @@ -name: Build V2 Demos on Pull Request - +name: Build and Deploy V2 Demos on Pull Request on: pull_request: branches: [master, dev] @@ -9,42 +8,49 @@ concurrency: cancel-in-progress: true jobs: - build-and-deploy: + # Step 1. Check if PR is a fork + check-if-fork: runs-on: ubuntu-latest - steps: - name: Check if PR is a fork if: github.event.pull_request.head.repo.full_name != github.repository run: | echo "This workflow does not run on forks, and requires a review before being merged into a branch for testing and secondary or final review." exit 1 - + + # Step 2. Create output of changed demos for build-demos step + prepare-changed-demos-list: + runs-on: ubuntu-latest + needs: check-if-fork + outputs: + updated: ${{ steps.prepare-output.outputs.changed-demos }} + steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - - name: List workspace contents - run: ls -R .github - - name: Get Changed Demos - id: changed-demos + id: get-changed-demos uses: ./.github/actions/get-changed-demos with: json: true - - name: Build V2 Demos - uses: ./.github/workflows/v2-build-demos.yml - with: - ref: ${{ github.event.pull_request.head.sha }} - demo-names: ${{ steps.changed-demos.outputs.changed-demos }} - dev: ${{ github.event.pull_request.base.ref == 'dev' }} - save-artifact: true - artifact-name: demo-build-${{ github.event.pull_request.head.sha }} - keep-going: false - quiet: false - batch_size: 10 - - - name: Deploy + - name: Prepare Changed Demos Output + id: prepare-output run: | - echo "Deploying demos..." \ No newline at end of file + echo "::set-output name=changed-demos::${{ steps.get-changed-demos.outputs.changed-demos }}" + + # Step 3. Build changed demos + build-changed-demos: + uses: ./.github/workflows/v2-build-demos.yml + needs: prepare-changed-demos-list + with: + ref: ${{ github.event.pull_request.head.sha }} + demo-names: ${{ needs.prepare-changed-demos-list.outputs.updated }} + dev: ${{ github.event.pull_request.base.ref == 'dev' }} + save-artifact: true + artifact-name: demo-build-${{ github.event.pull_request.head.sha }} + keep-going: false + quiet: false + batch_size: 10 From ec59fdef38defddaad6c64086b9fab8291a2d141 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Tue, 15 Apr 2025 13:04:45 -0400 Subject: [PATCH 17/60] Use env var instead of set-output (depracated) --- .github/workflows/build-v2-pr.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml index ebf1a4b8dd..0ddbc71818 100644 --- a/.github/workflows/build-v2-pr.yml +++ b/.github/workflows/build-v2-pr.yml @@ -39,7 +39,11 @@ jobs: - name: Prepare Changed Demos Output id: prepare-output run: | - echo "::set-output name=changed-demos::${{ steps.get-changed-demos.outputs.changed-demos }}" + echo "${{ steps.get-changed-demos.outputs.changed-demos }}" > $GITHUB_ENV + # echo "${{ steps.get-changed-demos.outputs.deleted-demos }}" > $GITHUB_ENV + env: + changed-demos: ${{ steps.get-changed-demos.outputs.changed-demos }} + # deleted-demos: ${{ steps.get-changed-demos.outputs.deleted-demos }} # Step 3. Build changed demos build-changed-demos: From c259844b25a6081a2f52683986a19997871a8d78 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Tue, 15 Apr 2025 13:48:59 -0400 Subject: [PATCH 18/60] add build step --- .github/workflows/build-v2-pr.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml index 0ddbc71818..5d8dba9ad5 100644 --- a/.github/workflows/build-v2-pr.yml +++ b/.github/workflows/build-v2-pr.yml @@ -58,3 +58,13 @@ jobs: keep-going: false quiet: false batch_size: 10 + + # Step 4. Deploy demos + deploy-demos: + uses: ./.github/workflows/v2-deploy-demos.yml + needs: build-changed-demos + with: + environment: ${{ github.event.pull_request.base.ref }} + artifact-name: demo-build-${{ github.event.pull_request.head.sha }} + preview: true + branch: ${{ github.event.pull_request.head.ref }} From 704c941a34216f3413b1d3087a3adb8bba26a64d Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Tue, 15 Apr 2025 15:26:36 -0400 Subject: [PATCH 19/60] inherit secrets --- .github/workflows/build-v2-pr.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml index 5d8dba9ad5..e1274044fd 100644 --- a/.github/workflows/build-v2-pr.yml +++ b/.github/workflows/build-v2-pr.yml @@ -68,3 +68,5 @@ jobs: artifact-name: demo-build-${{ github.event.pull_request.head.sha }} preview: true branch: ${{ github.event.pull_request.head.ref }} + secrets: inherit + \ No newline at end of file From 539b1f4ed0a546e37e7a34fa8a5d9c906787db52 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Tue, 15 Apr 2025 16:15:53 -0400 Subject: [PATCH 20/60] create short list for testing --- .github/workflows/build-v2-pr.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml index e1274044fd..a6fe400c15 100644 --- a/.github/workflows/build-v2-pr.yml +++ b/.github/workflows/build-v2-pr.yml @@ -51,7 +51,8 @@ jobs: needs: prepare-changed-demos-list with: ref: ${{ github.event.pull_request.head.sha }} - demo-names: ${{ needs.prepare-changed-demos-list.outputs.updated }} + # demo-names: ${{ needs.prepare-changed-demos-list.outputs.updated }} + demo-names: 'tutorial_qpe tutorial_QUBO' dev: ${{ github.event.pull_request.base.ref == 'dev' }} save-artifact: true artifact-name: demo-build-${{ github.event.pull_request.head.sha }} From 8c2e71646682bfa0448c9431c818b74e2e3de725 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Wed, 16 Apr 2025 10:00:27 -0400 Subject: [PATCH 21/60] use swc-staging, add todos and notes --- .github/workflows/build-v2-pr.yml | 6 ++++-- .github/workflows/v2-deploy-demos.yml | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml index a6fe400c15..05b2174d51 100644 --- a/.github/workflows/build-v2-pr.yml +++ b/.github/workflows/build-v2-pr.yml @@ -3,6 +3,8 @@ on: pull_request: branches: [master, dev] +# TODO: Add permissions to this workflow + concurrency: group: build-v2-demos-${{ github.ref }} cancel-in-progress: true @@ -65,9 +67,9 @@ jobs: uses: ./.github/workflows/v2-deploy-demos.yml needs: build-changed-demos with: - environment: ${{ github.event.pull_request.base.ref }} + environment: 'swc-staging' # Is the environment dev or master? or is it swc-dev or swc-prod? artifact-name: demo-build-${{ github.event.pull_request.head.sha }} - preview: true + preview: true # should this be dynamic? or should it always be true as this a PR workflow? branch: ${{ github.event.pull_request.head.ref }} secrets: inherit \ No newline at end of file diff --git a/.github/workflows/v2-deploy-demos.yml b/.github/workflows/v2-deploy-demos.yml index 07f7e8adcf..261524b5ad 100644 --- a/.github/workflows/v2-deploy-demos.yml +++ b/.github/workflows/v2-deploy-demos.yml @@ -16,7 +16,7 @@ on: branch: description: Branch to checkout type: string - default: sc-81925-qml-repository-ci-pushes-newly-built-demos + default: sc-81925-qml-repository-ci-pushes-newly-built-demos ## Should this be updated, this seems out of date? Or should it be removed completely? workflow_dispatch: inputs: @@ -34,7 +34,7 @@ on: branch: description: Branch to checkout type: string - default: sc-81925-qml-repository-ci-pushes-newly-built-demos + default: sc-81925-qml-repository-ci-pushes-newly-built-demos ## Should this be updated, this seems out of date? Or should it be removed completely? jobs: deploy-demos: @@ -76,3 +76,6 @@ jobs: --preview ${{ inputs.preview }} \ _build/pack/*.zip +### TODO: ### +# - Access whether or not the default branch argument should be set, or if should be removed completely +# - See lines 16 and 34 \ No newline at end of file From 51e28d5019bcd2db1519599f366c31012794b370 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Wed, 16 Apr 2025 15:44:37 -0400 Subject: [PATCH 22/60] snub other steps, and see if changed demos works as expected --- .github/workflows/build-v2-pr.yml | 54 +++++++++++++++---------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml index 05b2174d51..aaf07f24dd 100644 --- a/.github/workflows/build-v2-pr.yml +++ b/.github/workflows/build-v2-pr.yml @@ -10,7 +10,6 @@ concurrency: cancel-in-progress: true jobs: - # Step 1. Check if PR is a fork check-if-fork: runs-on: ubuntu-latest steps: @@ -20,7 +19,6 @@ jobs: echo "This workflow does not run on forks, and requires a review before being merged into a branch for testing and secondary or final review." exit 1 - # Step 2. Create output of changed demos for build-demos step prepare-changed-demos-list: runs-on: ubuntu-latest needs: check-if-fork @@ -29,8 +27,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Get Changed Demos id: get-changed-demos @@ -46,30 +42,32 @@ jobs: env: changed-demos: ${{ steps.get-changed-demos.outputs.changed-demos }} # deleted-demos: ${{ steps.get-changed-demos.outputs.deleted-demos }} + + - name: Print all demos to logging + run: | + echo "Changed Demos: ${{ steps.get-changed-demos.outputs.changed-demos }}" - # Step 3. Build changed demos - build-changed-demos: - uses: ./.github/workflows/v2-build-demos.yml - needs: prepare-changed-demos-list - with: - ref: ${{ github.event.pull_request.head.sha }} - # demo-names: ${{ needs.prepare-changed-demos-list.outputs.updated }} - demo-names: 'tutorial_qpe tutorial_QUBO' - dev: ${{ github.event.pull_request.base.ref == 'dev' }} - save-artifact: true - artifact-name: demo-build-${{ github.event.pull_request.head.sha }} - keep-going: false - quiet: false - batch_size: 10 + # build-changed-demos: + # uses: ./.github/workflows/v2-build-demos.yml + # needs: prepare-changed-demos-list + # with: + # ref: ${{ github.event.pull_request.head.sha }} + # # demo-names: ${{ needs.prepare-changed-demos-list.outputs.updated }} + # demo-names: 'tutorial_qpe tutorial_QUBO' + # dev: ${{ github.event.pull_request.base.ref == 'dev' }} + # save-artifact: true + # artifact-name: demo-build-${{ github.event.pull_request.head.sha }} + # keep-going: false + # quiet: false + # batch_size: 10 - # Step 4. Deploy demos - deploy-demos: - uses: ./.github/workflows/v2-deploy-demos.yml - needs: build-changed-demos - with: - environment: 'swc-staging' # Is the environment dev or master? or is it swc-dev or swc-prod? - artifact-name: demo-build-${{ github.event.pull_request.head.sha }} - preview: true # should this be dynamic? or should it always be true as this a PR workflow? - branch: ${{ github.event.pull_request.head.ref }} - secrets: inherit + # deploy-demos: + # uses: ./.github/workflows/v2-deploy-demos.yml + # needs: build-changed-demos + # with: + # environment: 'swc-staging' + # artifact-name: demo-build-${{ github.event.pull_request.head.sha }} + # preview: true + # branch: ${{ github.event.pull_request.head.ref }} + # secrets: inherit \ No newline at end of file From 8b5ad3d549233f19fdf75b351ed9b83e6de0cfa7 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Wed, 16 Apr 2025 16:08:17 -0400 Subject: [PATCH 23/60] check if change actually get picked up --- .github/workflows/build-v2-pr.yml | 60 ++++++++++++++----------------- demonstrations_v2/gbs/demo.py | 1 + 2 files changed, 27 insertions(+), 34 deletions(-) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml index aaf07f24dd..81505a6bb3 100644 --- a/.github/workflows/build-v2-pr.yml +++ b/.github/workflows/build-v2-pr.yml @@ -23,7 +23,8 @@ jobs: runs-on: ubuntu-latest needs: check-if-fork outputs: - updated: ${{ steps.prepare-output.outputs.changed-demos }} + updated: ${{ steps.get-changed-demos.outputs.updated }} + deleted: ${{ steps.get-changed-demos.outputs.deleted }} steps: - name: Checkout uses: actions/checkout@v4 @@ -34,40 +35,31 @@ jobs: with: json: true - - name: Prepare Changed Demos Output - id: prepare-output + - name: Print Changed Demos run: | - echo "${{ steps.get-changed-demos.outputs.changed-demos }}" > $GITHUB_ENV - # echo "${{ steps.get-changed-demos.outputs.deleted-demos }}" > $GITHUB_ENV - env: - changed-demos: ${{ steps.get-changed-demos.outputs.changed-demos }} - # deleted-demos: ${{ steps.get-changed-demos.outputs.deleted-demos }} - - - name: Print all demos to logging - run: | - echo "Changed Demos: ${{ steps.get-changed-demos.outputs.changed-demos }}" + echo "Updated Demos: ${{ steps.get-changed-demos.outputs.updated }}" + echo "Deleted Demos: ${{ steps.get-changed-demos.outputs.deleted }}" - # build-changed-demos: - # uses: ./.github/workflows/v2-build-demos.yml - # needs: prepare-changed-demos-list - # with: - # ref: ${{ github.event.pull_request.head.sha }} - # # demo-names: ${{ needs.prepare-changed-demos-list.outputs.updated }} - # demo-names: 'tutorial_qpe tutorial_QUBO' - # dev: ${{ github.event.pull_request.base.ref == 'dev' }} - # save-artifact: true - # artifact-name: demo-build-${{ github.event.pull_request.head.sha }} - # keep-going: false - # quiet: false - # batch_size: 10 + build-changed-demos: + uses: ./.github/workflows/v2-build-demos.yml + needs: prepare-changed-demos-list + with: + ref: ${{ github.event.pull_request.head.sha }} + demo-names: ${{ needs.prepare-changed-demos-list.outputs.updated }} + dev: ${{ github.event.pull_request.base.ref == 'dev' }} + save-artifact: true + artifact-name: demo-build-${{ github.event.pull_request.head.sha }} + keep-going: false + quiet: false + batch_size: 10 - # deploy-demos: - # uses: ./.github/workflows/v2-deploy-demos.yml - # needs: build-changed-demos - # with: - # environment: 'swc-staging' - # artifact-name: demo-build-${{ github.event.pull_request.head.sha }} - # preview: true - # branch: ${{ github.event.pull_request.head.ref }} - # secrets: inherit + deploy-demos: + uses: ./.github/workflows/v2-deploy-demos.yml + needs: build-changed-demos + with: + environment: 'swc-staging' + artifact-name: demo-build-${{ github.event.pull_request.head.sha }} + preview: true + branch: ${{ github.event.pull_request.head.ref }} + secrets: inherit \ No newline at end of file diff --git a/demonstrations_v2/gbs/demo.py b/demonstrations_v2/gbs/demo.py index e1ecc9c2ba..b38887236d 100644 --- a/demonstrations_v2/gbs/demo.py +++ b/demonstrations_v2/gbs/demo.py @@ -238,6 +238,7 @@ def gbs_circuit(): # different Fock states at the output, and print them out for i in measure_states: print(f"|{''.join(str(j) for j in i)}>: {probs[i]}") + ############################################################################## # .. rst-class:: sphx-glr-script-out From dac0637e9df0539bbae7a38535e2ff80d4acd151 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Wed, 16 Apr 2025 16:13:49 -0400 Subject: [PATCH 24/60] try again --- .github/workflows/build-v2-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml index 81505a6bb3..689418276a 100644 --- a/.github/workflows/build-v2-pr.yml +++ b/.github/workflows/build-v2-pr.yml @@ -33,7 +33,7 @@ jobs: id: get-changed-demos uses: ./.github/actions/get-changed-demos with: - json: true + json: false - name: Print Changed Demos run: | From 0b3e1b0dcb7072ea1eb8a61210eecbc61e930084 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Wed, 16 Apr 2025 16:18:17 -0400 Subject: [PATCH 25/60] remove newline for testing, add better desc --- .github/workflows/v2-build-demos.yml | 5 ++++- demonstrations_v2/gbs/demo.py | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/v2-build-demos.yml b/.github/workflows/v2-build-demos.yml index eda24cd231..5276ff0cc2 100644 --- a/.github/workflows/v2-build-demos.yml +++ b/.github/workflows/v2-build-demos.yml @@ -8,7 +8,10 @@ on: type: string demo-names: description: | - Only build the demos specified in this list. + Only build the demos specified in a space-separated list. + e.g. demo1 demo2 demo3 + + If not specified, all demos will be built. required: false type: string default: '' diff --git a/demonstrations_v2/gbs/demo.py b/demonstrations_v2/gbs/demo.py index b38887236d..e1ecc9c2ba 100644 --- a/demonstrations_v2/gbs/demo.py +++ b/demonstrations_v2/gbs/demo.py @@ -238,7 +238,6 @@ def gbs_circuit(): # different Fock states at the output, and print them out for i in measure_states: print(f"|{''.join(str(j) for j in i)}>: {probs[i]}") - ############################################################################## # .. rst-class:: sphx-glr-script-out From 10d19c2216f82eef5d2e8a6c548728df9b74b321 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Wed, 16 Apr 2025 16:19:21 -0400 Subject: [PATCH 26/60] fmt --- .github/workflows/v2-build-demos.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/v2-build-demos.yml b/.github/workflows/v2-build-demos.yml index 5276ff0cc2..95e2564f01 100644 --- a/.github/workflows/v2-build-demos.yml +++ b/.github/workflows/v2-build-demos.yml @@ -10,7 +10,7 @@ on: description: | Only build the demos specified in a space-separated list. e.g. demo1 demo2 demo3 - + If not specified, all demos will be built. required: false type: string From d12eb29418eee455a56b7bf4132c0e831881b092 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Wed, 16 Apr 2025 17:16:31 -0400 Subject: [PATCH 27/60] improve readability, leave notes, add permissions. --- .github/workflows/build-v2-pr.yml | 36 +++++++++++++++++-------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml index 689418276a..28679e72ce 100644 --- a/.github/workflows/build-v2-pr.yml +++ b/.github/workflows/build-v2-pr.yml @@ -1,27 +1,29 @@ -name: Build and Deploy V2 Demos on Pull Request +name: Build and Deploy V2 Demo Previews on Pull Requests on: pull_request: branches: [master, dev] -# TODO: Add permissions to this workflow +permissions: + contents: read + pull-requests: write concurrency: group: build-v2-demos-${{ github.ref }} cancel-in-progress: true jobs: - check-if-fork: + validate-pr-source: runs-on: ubuntu-latest steps: - name: Check if PR is a fork if: github.event.pull_request.head.repo.full_name != github.repository run: | - echo "This workflow does not run on forks, and requires a review before being merged into a branch for testing and secondary or final review." + echo "Skipping workflow for forked PRs" exit 1 - prepare-changed-demos-list: + identify-changed-demos: runs-on: ubuntu-latest - needs: check-if-fork + needs: validate-pr-source outputs: updated: ${{ steps.get-changed-demos.outputs.updated }} deleted: ${{ steps.get-changed-demos.outputs.deleted }} @@ -32,20 +34,18 @@ jobs: - name: Get Changed Demos id: get-changed-demos uses: ./.github/actions/get-changed-demos - with: - json: false - - name: Print Changed Demos + - name: Output Changed Demos run: | echo "Updated Demos: ${{ steps.get-changed-demos.outputs.updated }}" echo "Deleted Demos: ${{ steps.get-changed-demos.outputs.deleted }}" - build-changed-demos: + build-updated-demos: uses: ./.github/workflows/v2-build-demos.yml - needs: prepare-changed-demos-list + needs: identify-changed-demos with: ref: ${{ github.event.pull_request.head.sha }} - demo-names: ${{ needs.prepare-changed-demos-list.outputs.updated }} + demo-names: ${{ needs.identify-changed-demos.outputs.updated }} dev: ${{ github.event.pull_request.base.ref == 'dev' }} save-artifact: true artifact-name: demo-build-${{ github.event.pull_request.head.sha }} @@ -53,13 +53,17 @@ jobs: quiet: false batch_size: 10 - deploy-demos: + deploy-preview-demos: uses: ./.github/workflows/v2-deploy-demos.yml - needs: build-changed-demos + needs: build-updated-demos with: - environment: 'swc-staging' + environment: 'swc-staging' ## In a subsequent PR, this should be changed to the appropriate environment that internal and third parties can access artifact-name: demo-build-${{ github.event.pull_request.head.sha }} preview: true branch: ${{ github.event.pull_request.head.ref }} secrets: inherit - \ No newline at end of file + +# TODOS: In subsequent PRs, the following should be added: + # 1. Add a step to determine the SWC environment to deploy to (Always prod?) + # 2. Add a step to post a comment on the PR with the preview URL. + # 3. Determine whether or not we can/want to delete demos. From 69f10afa8cd0e69f525ad549eb9fae69629ab7c9 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Wed, 16 Apr 2025 17:20:13 -0400 Subject: [PATCH 28/60] test condition --- .github/workflows/build-v2-pr.yml | 49 ++++++++++++++++++------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml index 28679e72ce..7fa2e4ce2e 100644 --- a/.github/workflows/build-v2-pr.yml +++ b/.github/workflows/build-v2-pr.yml @@ -39,29 +39,36 @@ jobs: run: | echo "Updated Demos: ${{ steps.get-changed-demos.outputs.updated }}" echo "Deleted Demos: ${{ steps.get-changed-demos.outputs.deleted }}" + + # If no changes are found, exit workflow + - name: Exit if no changes + if: steps.get-changed-demos.outputs.updated == '[]' && steps.get-changed-demos.outputs.deleted == '[]' + run: | + echo "No changes found in demos." + exit 0 - build-updated-demos: - uses: ./.github/workflows/v2-build-demos.yml - needs: identify-changed-demos - with: - ref: ${{ github.event.pull_request.head.sha }} - demo-names: ${{ needs.identify-changed-demos.outputs.updated }} - dev: ${{ github.event.pull_request.base.ref == 'dev' }} - save-artifact: true - artifact-name: demo-build-${{ github.event.pull_request.head.sha }} - keep-going: false - quiet: false - batch_size: 10 + # build-updated-demos: + # uses: ./.github/workflows/v2-build-demos.yml + # needs: identify-changed-demos + # with: + # ref: ${{ github.event.pull_request.head.sha }} + # demo-names: ${{ needs.identify-changed-demos.outputs.updated }} + # dev: ${{ github.event.pull_request.base.ref == 'dev' }} + # save-artifact: true + # artifact-name: demo-build-${{ github.event.pull_request.head.sha }} + # keep-going: false + # quiet: false + # batch_size: 10 - deploy-preview-demos: - uses: ./.github/workflows/v2-deploy-demos.yml - needs: build-updated-demos - with: - environment: 'swc-staging' ## In a subsequent PR, this should be changed to the appropriate environment that internal and third parties can access - artifact-name: demo-build-${{ github.event.pull_request.head.sha }} - preview: true - branch: ${{ github.event.pull_request.head.ref }} - secrets: inherit + # deploy-preview-demos: + # uses: ./.github/workflows/v2-deploy-demos.yml + # needs: build-updated-demos + # with: + # environment: 'swc-staging' ## In a subsequent PR, this should be changed to the appropriate environment that internal and third parties can access + # artifact-name: demo-build-${{ github.event.pull_request.head.sha }} + # preview: true + # branch: ${{ github.event.pull_request.head.ref }} + # secrets: inherit # TODOS: In subsequent PRs, the following should be added: # 1. Add a step to determine the SWC environment to deploy to (Always prod?) From 04c8ecc6c045f148dc24380fa1cda3a85151acd6 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Wed, 16 Apr 2025 17:25:21 -0400 Subject: [PATCH 29/60] test exit --- .github/workflows/build-v2-pr.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml index 7fa2e4ce2e..e2c07deb00 100644 --- a/.github/workflows/build-v2-pr.yml +++ b/.github/workflows/build-v2-pr.yml @@ -42,11 +42,11 @@ jobs: # If no changes are found, exit workflow - name: Exit if no changes - if: steps.get-changed-demos.outputs.updated == '[]' && steps.get-changed-demos.outputs.deleted == '[]' + if: steps.get-changed-demos.outputs.updated == '' || steps.get-changed-demos.outputs.deleted == '' run: | - echo "No changes found in demos." - exit 0 - + echo "No changes found in demos. Exiting workflow." + exit 1 + # build-updated-demos: # uses: ./.github/workflows/v2-build-demos.yml # needs: identify-changed-demos From 3360813f0c09ee3fadf19a62c56a41255ffcdc10 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Wed, 16 Apr 2025 17:29:56 -0400 Subject: [PATCH 30/60] uncomment other jobs, remove delete --- .github/workflows/build-v2-pr.yml | 53 +++++++++++++++---------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml index e2c07deb00..ca429c8fa0 100644 --- a/.github/workflows/build-v2-pr.yml +++ b/.github/workflows/build-v2-pr.yml @@ -40,37 +40,36 @@ jobs: echo "Updated Demos: ${{ steps.get-changed-demos.outputs.updated }}" echo "Deleted Demos: ${{ steps.get-changed-demos.outputs.deleted }}" - # If no changes are found, exit workflow - name: Exit if no changes - if: steps.get-changed-demos.outputs.updated == '' || steps.get-changed-demos.outputs.deleted == '' + if: steps.get-changed-demos.outputs.updated == '' run: | echo "No changes found in demos. Exiting workflow." exit 1 - - # build-updated-demos: - # uses: ./.github/workflows/v2-build-demos.yml - # needs: identify-changed-demos - # with: - # ref: ${{ github.event.pull_request.head.sha }} - # demo-names: ${{ needs.identify-changed-demos.outputs.updated }} - # dev: ${{ github.event.pull_request.base.ref == 'dev' }} - # save-artifact: true - # artifact-name: demo-build-${{ github.event.pull_request.head.sha }} - # keep-going: false - # quiet: false - # batch_size: 10 + + build-updated-demos: + uses: ./.github/workflows/v2-build-demos.yml + needs: identify-changed-demos + with: + ref: ${{ github.event.pull_request.head.sha }} + demo-names: ${{ needs.identify-changed-demos.outputs.updated }} + dev: ${{ github.event.pull_request.base.ref == 'dev' }} + save-artifact: true + artifact-name: demo-build-${{ github.event.pull_request.head.sha }} + keep-going: false + quiet: false + batch_size: 10 - # deploy-preview-demos: - # uses: ./.github/workflows/v2-deploy-demos.yml - # needs: build-updated-demos - # with: - # environment: 'swc-staging' ## In a subsequent PR, this should be changed to the appropriate environment that internal and third parties can access - # artifact-name: demo-build-${{ github.event.pull_request.head.sha }} - # preview: true - # branch: ${{ github.event.pull_request.head.ref }} - # secrets: inherit + deploy-preview-demos: + uses: ./.github/workflows/v2-deploy-demos.yml + needs: build-updated-demos + with: + environment: 'swc-staging' ## In a subsequent PR, this should be changed to the appropriate environment that internal and third parties can access + artifact-name: demo-build-${{ github.event.pull_request.head.sha }} + preview: true + branch: ${{ github.event.pull_request.head.ref }} + secrets: inherit # TODOS: In subsequent PRs, the following should be added: - # 1. Add a step to determine the SWC environment to deploy to (Always prod?) - # 2. Add a step to post a comment on the PR with the preview URL. - # 3. Determine whether or not we can/want to delete demos. +# 1. Add a step to determine the SWC environment to deploy to (Always prod?) +# 2. Add a step to post a comment on the PR with the preview URL. +# 3. Determine whether or not we can/want to delete demos. From b2312d8d20ab0207e93c737f12ba072cc8e21dbf Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Wed, 16 Apr 2025 17:33:42 -0400 Subject: [PATCH 31/60] todo --- .github/workflows/build-v2-pr.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml index ca429c8fa0..4fecb32f13 100644 --- a/.github/workflows/build-v2-pr.yml +++ b/.github/workflows/build-v2-pr.yml @@ -73,3 +73,4 @@ jobs: # 1. Add a step to determine the SWC environment to deploy to (Always prod?) # 2. Add a step to post a comment on the PR with the preview URL. # 3. Determine whether or not we can/want to delete demos. +# 4. Add a logging to tell third parties how they can fork then get approval to merge to a branch within our repo. From 4a5ce59c11a3c357ce59fe4d823f3372ae10c16b Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Wed, 16 Apr 2025 17:54:36 -0400 Subject: [PATCH 32/60] update casing --- .github/workflows/build-v2-pr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/build-v2-pr.yml index 4fecb32f13..2f3370dfc3 100644 --- a/.github/workflows/build-v2-pr.yml +++ b/.github/workflows/build-v2-pr.yml @@ -31,11 +31,11 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Get Changed Demos + - name: Get changed demos id: get-changed-demos uses: ./.github/actions/get-changed-demos - - name: Output Changed Demos + - name: Output changed demos run: | echo "Updated Demos: ${{ steps.get-changed-demos.outputs.updated }}" echo "Deleted Demos: ${{ steps.get-changed-demos.outputs.deleted }}" From 239d95e2ac37b5556641b31860bb5beb9b8d9748 Mon Sep 17 00:00:00 2001 From: Alan Martin <53958929+Alan-eMartin@users.noreply.github.com> Date: Thu, 17 Apr 2025 09:04:28 -0400 Subject: [PATCH 33/60] Update .github/workflows/v2-deploy-demos.yml --- .github/workflows/v2-deploy-demos.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/v2-deploy-demos.yml b/.github/workflows/v2-deploy-demos.yml index 261524b5ad..865dcc9fc1 100644 --- a/.github/workflows/v2-deploy-demos.yml +++ b/.github/workflows/v2-deploy-demos.yml @@ -78,4 +78,4 @@ jobs: ### TODO: ### # - Access whether or not the default branch argument should be set, or if should be removed completely -# - See lines 16 and 34 \ No newline at end of file +# - See lines 16 and 34 From 6fc0139aee2def72a6f151658dea924bde3259b6 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Thu, 17 Apr 2025 11:59:49 -0400 Subject: [PATCH 34/60] rename file to match other v2 --- .github/workflows/{build-v2-pr.yml => v2-build-pr.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{build-v2-pr.yml => v2-build-pr.yml} (100%) diff --git a/.github/workflows/build-v2-pr.yml b/.github/workflows/v2-build-pr.yml similarity index 100% rename from .github/workflows/build-v2-pr.yml rename to .github/workflows/v2-build-pr.yml From 10b7f8b36e5ad9f2840e39bdeb5627a1158ac0b8 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Thu, 17 Apr 2025 20:07:55 -0400 Subject: [PATCH 35/60] add fork warning --- .github/workflows/v2-build-pr.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/v2-build-pr.yml b/.github/workflows/v2-build-pr.yml index 2f3370dfc3..53bc5d6210 100644 --- a/.github/workflows/v2-build-pr.yml +++ b/.github/workflows/v2-build-pr.yml @@ -18,7 +18,17 @@ jobs: - name: Check if PR is a fork if: github.event.pull_request.head.repo.full_name != github.repository run: | - echo "Skipping workflow for forked PRs" + echo "============================================================" + echo "⚠️ Preview build skipped for this PR ⚠️" + echo "" + echo "This pull request is from a forked repository." + echo "For security reasons (e.g., protecting environment secrets)," + echo "our deployment previews only run for branches within the" + echo "main PennyLaneAI repository." + echo "" + echo "If you'd like help testing this change, feel free to ping a" + echo "maintainer — we can move your branch internally to trigger a preview build." + echo "============================================================" exit 1 identify-changed-demos: From f705ff8407fd5f357d837cbf6e1a38089f19e3de Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Mon, 21 Apr 2025 10:20:25 -0400 Subject: [PATCH 36/60] clkean --- .github/workflows/v2-build-demos.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/v2-build-demos.yml b/.github/workflows/v2-build-demos.yml index 95e2564f01..2f60cc73a8 100644 --- a/.github/workflows/v2-build-demos.yml +++ b/.github/workflows/v2-build-demos.yml @@ -215,5 +215,3 @@ jobs: uses: geekyeggo/delete-artifact@v5 with: name: ${{ needs.generate-build-variables.outputs.artifact-name }}-c* - - From 60a3bd65fe5854c8684cee64c4280d8c74d88a8b Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Mon, 21 Apr 2025 10:32:38 -0400 Subject: [PATCH 37/60] try comment --- .github/workflows/v2-build-pr.yml | 46 +++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/.github/workflows/v2-build-pr.yml b/.github/workflows/v2-build-pr.yml index 53bc5d6210..f4280c8e3a 100644 --- a/.github/workflows/v2-build-pr.yml +++ b/.github/workflows/v2-build-pr.yml @@ -79,8 +79,44 @@ jobs: branch: ${{ github.event.pull_request.head.ref }} secrets: inherit -# TODOS: In subsequent PRs, the following should be added: -# 1. Add a step to determine the SWC environment to deploy to (Always prod?) -# 2. Add a step to post a comment on the PR with the preview URL. -# 3. Determine whether or not we can/want to delete demos. -# 4. Add a logging to tell third parties how they can fork then get approval to merge to a branch within our repo. +# XanaduAI/cloud-actions/create-and-update-pull-request-comment@main +# Uses the updated output from the get-changed-demos action to create a comment on the PR +# with the xandu cloud actuibs create-and-update-pull-request-comment@main + comment-on-pr: + runs-on: ubuntu-latest + needs: [identify-changed-demos, build-updated-demos, deploy-preview-demos] + if: needs.identify-changed-demos.outputs.updated != '' + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Build PR Comment Body + id: generate-comment + run: | + updated="${{ needs.identify-changed-demos.outputs.updated }}" + IFS=' ' read -r -a demos <<< "$updated" + + echo "**Thanks for the pull request!**" > comment.md + echo "" >> comment.md + echo "The following demos have been updated and deployed:" >> comment.md + echo "" >> comment.md + + for demo in "${demos[@]}"; do + echo "- [$demo](https://pennylane.ai/qml/demonstrations/$demo?preview=true)" >> comment.md + done + + echo "" >> comment.md + echo "_This comment updates automatically if you push more commits._" >> comment.md + + # Save the content as output + echo "comment_body<> $GITHUB_OUTPUT + cat comment.md >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Comment on PR + uses: XanaduAI/cloud-actions/create-and-update-pull-request-comment@main + with: + github_token: ${{ github.token }} + pull_request_number: ${{ github.event.pull_request.number }} + comment_body: ${{ steps.generate-comment.outputs.comment_body }} From 388920d8164c1262c5ede3d14fbe4670fa71e173 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Mon, 21 Apr 2025 10:49:55 -0400 Subject: [PATCH 38/60] rm comments --- .github/workflows/v2-build-pr.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/v2-build-pr.yml b/.github/workflows/v2-build-pr.yml index f4280c8e3a..ab4b1d4749 100644 --- a/.github/workflows/v2-build-pr.yml +++ b/.github/workflows/v2-build-pr.yml @@ -79,9 +79,6 @@ jobs: branch: ${{ github.event.pull_request.head.ref }} secrets: inherit -# XanaduAI/cloud-actions/create-and-update-pull-request-comment@main -# Uses the updated output from the get-changed-demos action to create a comment on the PR -# with the xandu cloud actuibs create-and-update-pull-request-comment@main comment-on-pr: runs-on: ubuntu-latest needs: [identify-changed-demos, build-updated-demos, deploy-preview-demos] From 12b07c6f2b07c8622d5e427ae3355f0ca08e0cc8 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Mon, 21 Apr 2025 11:07:57 -0400 Subject: [PATCH 39/60] put in summary --- .github/workflows/v2-build-pr.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/v2-build-pr.yml b/.github/workflows/v2-build-pr.yml index ab4b1d4749..d46451a121 100644 --- a/.github/workflows/v2-build-pr.yml +++ b/.github/workflows/v2-build-pr.yml @@ -99,9 +99,13 @@ jobs: echo "The following demos have been updated and deployed:" >> comment.md echo "" >> comment.md - for demo in "${demos[@]}"; do + echo "
Updated Demos" >> comment.md + echo "" >> comment.md + for demo in "${demos[@]}"; do echo "- [$demo](https://pennylane.ai/qml/demonstrations/$demo?preview=true)" >> comment.md - done + done + echo "" >> comment.md + echo "
" >> comment.md echo "" >> comment.md echo "_This comment updates automatically if you push more commits._" >> comment.md From 96f8b5e0611c13a8d7cde4d83d8a4153a303e0d5 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Mon, 21 Apr 2025 13:32:51 -0400 Subject: [PATCH 40/60] add space for testing --- demonstrations_v2/gbs/demo.py | 1 + 1 file changed, 1 insertion(+) diff --git a/demonstrations_v2/gbs/demo.py b/demonstrations_v2/gbs/demo.py index e1ecc9c2ba..a662be1459 100644 --- a/demonstrations_v2/gbs/demo.py +++ b/demonstrations_v2/gbs/demo.py @@ -12,6 +12,7 @@ .. related:: + tutorial_gaussian_transformation Gaussian transformation qsim_beyond_classical Beyond classical computing with qsim qonn Optimizing a quantum optical neural network From a71fc63d238dd9f1f1c8b6d66958157e06b2a9d3 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Mon, 21 Apr 2025 13:40:58 -0400 Subject: [PATCH 41/60] fix: url for pl demos --- .github/workflows/v2-build-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/v2-build-pr.yml b/.github/workflows/v2-build-pr.yml index d46451a121..cb027d3c79 100644 --- a/.github/workflows/v2-build-pr.yml +++ b/.github/workflows/v2-build-pr.yml @@ -102,7 +102,7 @@ jobs: echo "
Updated Demos" >> comment.md echo "" >> comment.md for demo in "${demos[@]}"; do - echo "- [$demo](https://pennylane.ai/qml/demonstrations/$demo?preview=true)" >> comment.md + echo "- [$demo](https://pennylane.ai/qml/demos/$demo?preview=true)" >> comment.md done echo "" >> comment.md echo "
" >> comment.md From c7abf4ecdc70e665cf99accba43edd779a5ca6d9 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Mon, 21 Apr 2025 19:35:58 -0400 Subject: [PATCH 42/60] move back to two, rm comment for now. --- .github/workflows/v2-build-pr.yml | 83 ++-------------------------- .github/workflows/v2-deploy-pr.yml | 88 ++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 78 deletions(-) create mode 100644 .github/workflows/v2-deploy-pr.yml diff --git a/.github/workflows/v2-build-pr.yml b/.github/workflows/v2-build-pr.yml index cb027d3c79..40f4046503 100644 --- a/.github/workflows/v2-build-pr.yml +++ b/.github/workflows/v2-build-pr.yml @@ -1,39 +1,19 @@ -name: Build and Deploy V2 Demo Previews on Pull Requests +name: Build V2 Demo Previews on Pull Requests + on: pull_request: branches: [master, dev] permissions: contents: read - pull-requests: write concurrency: group: build-v2-demos-${{ github.ref }} cancel-in-progress: true jobs: - validate-pr-source: - runs-on: ubuntu-latest - steps: - - name: Check if PR is a fork - if: github.event.pull_request.head.repo.full_name != github.repository - run: | - echo "============================================================" - echo "⚠️ Preview build skipped for this PR ⚠️" - echo "" - echo "This pull request is from a forked repository." - echo "For security reasons (e.g., protecting environment secrets)," - echo "our deployment previews only run for branches within the" - echo "main PennyLaneAI repository." - echo "" - echo "If you'd like help testing this change, feel free to ping a" - echo "maintainer — we can move your branch internally to trigger a preview build." - echo "============================================================" - exit 1 - identify-changed-demos: runs-on: ubuntu-latest - needs: validate-pr-source outputs: updated: ${{ steps.get-changed-demos.outputs.updated }} deleted: ${{ steps.get-changed-demos.outputs.deleted }} @@ -44,18 +24,18 @@ jobs: - name: Get changed demos id: get-changed-demos uses: ./.github/actions/get-changed-demos - + - name: Output changed demos run: | echo "Updated Demos: ${{ steps.get-changed-demos.outputs.updated }}" echo "Deleted Demos: ${{ steps.get-changed-demos.outputs.deleted }}" - + - name: Exit if no changes if: steps.get-changed-demos.outputs.updated == '' run: | echo "No changes found in demos. Exiting workflow." exit 1 - + build-updated-demos: uses: ./.github/workflows/v2-build-demos.yml needs: identify-changed-demos @@ -68,56 +48,3 @@ jobs: keep-going: false quiet: false batch_size: 10 - - deploy-preview-demos: - uses: ./.github/workflows/v2-deploy-demos.yml - needs: build-updated-demos - with: - environment: 'swc-staging' ## In a subsequent PR, this should be changed to the appropriate environment that internal and third parties can access - artifact-name: demo-build-${{ github.event.pull_request.head.sha }} - preview: true - branch: ${{ github.event.pull_request.head.ref }} - secrets: inherit - - comment-on-pr: - runs-on: ubuntu-latest - needs: [identify-changed-demos, build-updated-demos, deploy-preview-demos] - if: needs.identify-changed-demos.outputs.updated != '' - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Build PR Comment Body - id: generate-comment - run: | - updated="${{ needs.identify-changed-demos.outputs.updated }}" - IFS=' ' read -r -a demos <<< "$updated" - - echo "**Thanks for the pull request!**" > comment.md - echo "" >> comment.md - echo "The following demos have been updated and deployed:" >> comment.md - echo "" >> comment.md - - echo "
Updated Demos" >> comment.md - echo "" >> comment.md - for demo in "${demos[@]}"; do - echo "- [$demo](https://pennylane.ai/qml/demos/$demo?preview=true)" >> comment.md - done - echo "" >> comment.md - echo "
" >> comment.md - - echo "" >> comment.md - echo "_This comment updates automatically if you push more commits._" >> comment.md - - # Save the content as output - echo "comment_body<> $GITHUB_OUTPUT - cat comment.md >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - - - name: Comment on PR - uses: XanaduAI/cloud-actions/create-and-update-pull-request-comment@main - with: - github_token: ${{ github.token }} - pull_request_number: ${{ github.event.pull_request.number }} - comment_body: ${{ steps.generate-comment.outputs.comment_body }} diff --git a/.github/workflows/v2-deploy-pr.yml b/.github/workflows/v2-deploy-pr.yml new file mode 100644 index 0000000000..ffe2d8a71c --- /dev/null +++ b/.github/workflows/v2-deploy-pr.yml @@ -0,0 +1,88 @@ +name: Deploy V2 Demo Previews on Pull Requests + +on: + workflow_run: + workflows: ['Build V2 Demo Previews on Pull Requests'] + types: + - completed + +permissions: + contents: read + pull-requests: write + +concurrency: + group: build-v2-demos-${{ github.event.workflow_run.head_branch }} + cancel-in-progress: true + +jobs: + deploy-preview-demos: + uses: ./.github/workflows/v2-deploy-demos.yml + with: + environment: 'swc-staging' # Update this to production later if needed + artifact-name: demo-build-${{ github.event.workflow_run.head_sha }} + preview: true + branch: ${{ github.event.workflow_run.head_branch }} + secrets: inherit + + # comment-on-pr: + # runs-on: ubuntu-latest + # needs: [deploy-preview-demos] + # if: ${{ always() && github.event.workflow_run.conclusion == 'success' }} + + # steps: + # - name: Check PR number exists + # id: check-pr + # run: | + # if [[ -z "${{ github.event.workflow_run.pull_requests[0].number }}" ]]; then + # echo "No PR info found — skipping comment." + # exit 0 + # fi + # continue-on-error: true + + # - name: Get PR number + # id: get-pr + # run: echo "pr_number=${{ github.event.workflow_run.pull_requests[0].number }}" >> $GITHUB_OUTPUT + # if: ${{ success() && github.event.workflow_run.pull_requests != '' }} + + # - name: Download slugs artifact + # uses: actions/download-artifact@v4 + # with: + # name: demo-build-${{ github.event.workflow_run.head_sha }} + # path: dist + + # - name: Read updated slugs from artifact + # id: slugs + # run: | + # echo "updated=$(jq -r '.[]' dist/slugs.json | paste -sd ' ' -)" >> $GITHUB_OUTPUT + + # - name: Build PR Comment Body + # id: generate-comment + # run: | + # updated="${{ steps.slugs.outputs.updated }}" + # IFS=' ' read -r -a demos <<< "$updated" + + # echo "**Thanks for the pull request!**" > comment.md + # echo "" >> comment.md + # echo "The following demos have been updated and deployed:" >> comment.md + # echo "" >> comment.md + + # echo "
Updated Demos" >> comment.md + # echo "" >> comment.md + # for demo in "${demos[@]}"; do + # echo "- [$demo](https://pennylane.ai/qml/demos/$demo?preview=true)" >> comment.md + # done + # echo "" >> comment.md + # echo "
" >> comment.md + # echo "" >> comment.md + # echo "_This comment updates automatically if you push more commits._" >> comment.md + + # echo "comment_body<> $GITHUB_OUTPUT + # cat comment.md >> $GITHUB_OUTPUT + # echo "EOF" >> $GITHUB_OUTPUT + + # - name: Comment on PR + # uses: XanaduAI/cloud-actions/create-and-update-pull-request-comment@main + # with: + # github_token: ${{ github.token }} + # pull_request_number: ${{ steps.get-pr.outputs.pr_number }} + # comment_body: ${{ steps.generate-comment.outputs.comment_body }} From 56598f55b29ebb06da202c9a7147d062a2e3d7f7 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Mon, 21 Apr 2025 19:45:49 -0400 Subject: [PATCH 43/60] perms? --- .github/workflows/v2-deploy-pr.yml | 68 ++---------------------------- 1 file changed, 3 insertions(+), 65 deletions(-) diff --git a/.github/workflows/v2-deploy-pr.yml b/.github/workflows/v2-deploy-pr.yml index ffe2d8a71c..5a9c2c2363 100644 --- a/.github/workflows/v2-deploy-pr.yml +++ b/.github/workflows/v2-deploy-pr.yml @@ -7,8 +7,9 @@ on: - completed permissions: - contents: read - pull-requests: write + actions: read + pull-requests: read + contents: read concurrency: group: build-v2-demos-${{ github.event.workflow_run.head_branch }} @@ -23,66 +24,3 @@ jobs: preview: true branch: ${{ github.event.workflow_run.head_branch }} secrets: inherit - - # comment-on-pr: - # runs-on: ubuntu-latest - # needs: [deploy-preview-demos] - # if: ${{ always() && github.event.workflow_run.conclusion == 'success' }} - - # steps: - # - name: Check PR number exists - # id: check-pr - # run: | - # if [[ -z "${{ github.event.workflow_run.pull_requests[0].number }}" ]]; then - # echo "No PR info found — skipping comment." - # exit 0 - # fi - # continue-on-error: true - - # - name: Get PR number - # id: get-pr - # run: echo "pr_number=${{ github.event.workflow_run.pull_requests[0].number }}" >> $GITHUB_OUTPUT - # if: ${{ success() && github.event.workflow_run.pull_requests != '' }} - - # - name: Download slugs artifact - # uses: actions/download-artifact@v4 - # with: - # name: demo-build-${{ github.event.workflow_run.head_sha }} - # path: dist - - # - name: Read updated slugs from artifact - # id: slugs - # run: | - # echo "updated=$(jq -r '.[]' dist/slugs.json | paste -sd ' ' -)" >> $GITHUB_OUTPUT - - # - name: Build PR Comment Body - # id: generate-comment - # run: | - # updated="${{ steps.slugs.outputs.updated }}" - # IFS=' ' read -r -a demos <<< "$updated" - - # echo "**Thanks for the pull request!**" > comment.md - # echo "" >> comment.md - # echo "The following demos have been updated and deployed:" >> comment.md - # echo "" >> comment.md - - # echo "
Updated Demos" >> comment.md - # echo "" >> comment.md - # for demo in "${demos[@]}"; do - # echo "- [$demo](https://pennylane.ai/qml/demos/$demo?preview=true)" >> comment.md - # done - # echo "" >> comment.md - # echo "
" >> comment.md - # echo "" >> comment.md - # echo "_This comment updates automatically if you push more commits._" >> comment.md - - # echo "comment_body<> $GITHUB_OUTPUT - # cat comment.md >> $GITHUB_OUTPUT - # echo "EOF" >> $GITHUB_OUTPUT - - # - name: Comment on PR - # uses: XanaduAI/cloud-actions/create-and-update-pull-request-comment@main - # with: - # github_token: ${{ github.token }} - # pull_request_number: ${{ steps.get-pr.outputs.pr_number }} - # comment_body: ${{ steps.generate-comment.outputs.comment_body }} From fe992f6f0e7ae86a92fd4f79d10aa34ce063cd59 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Mon, 21 Apr 2025 19:53:30 -0400 Subject: [PATCH 44/60] fix names --- .github/workflows/v2-build-pr.yml | 2 +- .github/workflows/v2-deploy-pr.yml | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/v2-build-pr.yml b/.github/workflows/v2-build-pr.yml index 40f4046503..b98330ea48 100644 --- a/.github/workflows/v2-build-pr.yml +++ b/.github/workflows/v2-build-pr.yml @@ -1,4 +1,4 @@ -name: Build V2 Demo Previews on Pull Requests +name: V2 Build PR on: pull_request: diff --git a/.github/workflows/v2-deploy-pr.yml b/.github/workflows/v2-deploy-pr.yml index 5a9c2c2363..5a10444f61 100644 --- a/.github/workflows/v2-deploy-pr.yml +++ b/.github/workflows/v2-deploy-pr.yml @@ -1,8 +1,9 @@ -name: Deploy V2 Demo Previews on Pull Requests +name: V2 Deploy PR on: workflow_run: - workflows: ['Build V2 Demo Previews on Pull Requests'] + workflows: + - V2 Build PR types: - completed From 2c2fa46aae96e52d1f2d602bfdd59caf01cb2143 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Mon, 21 Apr 2025 20:03:26 -0400 Subject: [PATCH 45/60] debug --- .github/workflows/v2-build-pr.yml | 2 +- .github/workflows/v2-deploy-pr.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/v2-build-pr.yml b/.github/workflows/v2-build-pr.yml index b98330ea48..76d3267f2f 100644 --- a/.github/workflows/v2-build-pr.yml +++ b/.github/workflows/v2-build-pr.yml @@ -8,7 +8,7 @@ permissions: contents: read concurrency: - group: build-v2-demos-${{ github.ref }} + group: build-v2-demos-${{ github.event.pull_request.head.sha }} cancel-in-progress: true jobs: diff --git a/.github/workflows/v2-deploy-pr.yml b/.github/workflows/v2-deploy-pr.yml index 5a10444f61..2edab89d31 100644 --- a/.github/workflows/v2-deploy-pr.yml +++ b/.github/workflows/v2-deploy-pr.yml @@ -13,7 +13,7 @@ permissions: contents: read concurrency: - group: build-v2-demos-${{ github.event.workflow_run.head_branch }} + group: deploy-v2-demos-${{ github.event.workflow_run.head_branch }} cancel-in-progress: true jobs: From 106c6c642dea0ad3359126ccdffefdcbd1c6b911 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Tue, 22 Apr 2025 11:59:29 -0400 Subject: [PATCH 46/60] add branch and save PR number as artifact --- .github/workflows/v2-build-pr.yml | 28 +++++++++++++++++++++++++++- .github/workflows/v2-deploy-pr.yml | 1 + 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/.github/workflows/v2-build-pr.yml b/.github/workflows/v2-build-pr.yml index 76d3267f2f..ec92a3bec5 100644 --- a/.github/workflows/v2-build-pr.yml +++ b/.github/workflows/v2-build-pr.yml @@ -2,7 +2,7 @@ name: V2 Build PR on: pull_request: - branches: [master, dev] + branches: [master, dev, sc-85409-v-demos-are-built-on-pull-request] permissions: contents: read @@ -48,3 +48,29 @@ jobs: keep-going: false quiet: false batch_size: 10 + + # If successful, save the PR number to a artifact called demo-build-pr-number + upload: + needs: build-updated-demos + runs-on: ubuntu-latest + steps: + - name: Save Demo Build PR Number + id: save-pr-number + env: + PR_NUMBER: ${{ github.event.number }} + run: | + mkdir -p ./pr + echo $PR_NUMBER > ./pr/pr_number + - uses: actions/upload-artifact@v4 + with: + name: pr_number + path: pr/ + + - name: Print PR Number from Artifact + id: print-pr-number + run: | + echo "PR Number: ${{ steps.save-pr-number.outputs.PR_NUMBER }}" + echo "PR Number from Artifact: $(cat ./pr/pr_number)" + echo "PR Number from Artifact (without quotes): $(cat ./pr/pr_number | tr -d '\"')" + echo "PR Number from Artifact (without quotes): ${{ steps.save-pr-number.outputs.PR_NUMBER }}" + \ No newline at end of file diff --git a/.github/workflows/v2-deploy-pr.yml b/.github/workflows/v2-deploy-pr.yml index 2edab89d31..bd4af47e03 100644 --- a/.github/workflows/v2-deploy-pr.yml +++ b/.github/workflows/v2-deploy-pr.yml @@ -25,3 +25,4 @@ jobs: preview: true branch: ${{ github.event.workflow_run.head_branch }} secrets: inherit + From c3a79bf1f33a71a94e6f7a42c324918cfc3b45b4 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Tue, 22 Apr 2025 12:14:40 -0400 Subject: [PATCH 47/60] reference the directory not name --- .github/workflows/v2-deploy-pr.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/v2-deploy-pr.yml b/.github/workflows/v2-deploy-pr.yml index bd4af47e03..a7459a3f7c 100644 --- a/.github/workflows/v2-deploy-pr.yml +++ b/.github/workflows/v2-deploy-pr.yml @@ -3,7 +3,7 @@ name: V2 Deploy PR on: workflow_run: workflows: - - V2 Build PR + - ./.github/workflows/v2-build-pr.yml types: - completed @@ -25,4 +25,3 @@ jobs: preview: true branch: ${{ github.event.workflow_run.head_branch }} secrets: inherit - From 4ac06d45fdb51b1012c2d6e7e4908328a7381aa2 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Wed, 23 Apr 2025 14:05:42 -0400 Subject: [PATCH 48/60] add new workflows --- .github/workflows/v2-build-pr.yml | 60 ++++++++------ .github/workflows/v2-deploy-pr.yml | 125 +++++++++++++++++++++++++++-- 2 files changed, 155 insertions(+), 30 deletions(-) diff --git a/.github/workflows/v2-build-pr.yml b/.github/workflows/v2-build-pr.yml index ec92a3bec5..cbcb772058 100644 --- a/.github/workflows/v2-build-pr.yml +++ b/.github/workflows/v2-build-pr.yml @@ -2,7 +2,8 @@ name: V2 Build PR on: pull_request: - branches: [master, dev, sc-85409-v-demos-are-built-on-pull-request] + # remove v2 after testing + branches: [master, dev, v2] permissions: contents: read @@ -12,31 +13,37 @@ concurrency: cancel-in-progress: true jobs: + # Step 1: Identify changed demos identify-changed-demos: runs-on: ubuntu-latest outputs: updated: ${{ steps.get-changed-demos.outputs.updated }} deleted: ${{ steps.get-changed-demos.outputs.deleted }} steps: + # Checkout the repository - name: Checkout uses: actions/checkout@v4 + # Identify changed demos - name: Get changed demos id: get-changed-demos uses: ./.github/actions/get-changed-demos + # Output the changed demos for debugging - name: Output changed demos run: | echo "Updated Demos: ${{ steps.get-changed-demos.outputs.updated }}" echo "Deleted Demos: ${{ steps.get-changed-demos.outputs.deleted }}" + # Exit workflow if no changes are found - name: Exit if no changes if: steps.get-changed-demos.outputs.updated == '' run: | echo "No changes found in demos. Exiting workflow." exit 1 - build-updated-demos: + # Step 2: Build demos + build: uses: ./.github/workflows/v2-build-demos.yml needs: identify-changed-demos with: @@ -48,29 +55,34 @@ jobs: keep-going: false quiet: false batch_size: 10 - - # If successful, save the PR number to a artifact called demo-build-pr-number - upload: - needs: build-updated-demos + + # Step 3: Save build context + save-build-context: runs-on: ubuntu-latest + needs: + - build + - identify-changed-demos steps: - - name: Save Demo Build PR Number - id: save-pr-number - env: - PR_NUMBER: ${{ github.event.number }} + # Save pull request event context to a temporary file + - name: Save Pull Request Event Context + if: github.event_name == 'pull_request' run: | - mkdir -p ./pr - echo $PR_NUMBER > ./pr/pr_number - - uses: actions/upload-artifact@v4 - with: - name: pr_number - path: pr/ + mkdir -p /tmp/pr + cat >/tmp/pr/pr_info.json <> $GITHUB_OUTPUT + fi + + # Unpack the build information if the file exists + - name: Unpack Build Information + if: steps.build_context.outputs.result != '' + run: unzip ${{ steps.build_context.outputs.result }} + + # Read the build information from the unpacked file + - name: Read Build Information + id: read_build_info + if: steps.build_context.outputs.result != '' + uses: actions/github-script@v6 + with: + script: | + const fs = require('fs'); + const buildData = fs.readFileSync('pr_info.json', 'utf8'); + return JSON.parse(buildData); + + # Parse pull request event information + - name: Parse Pull Request Event Information + id: pr_info + if: github.event.workflow_run.event == 'pull_request' && steps.build_context.outputs.result != '' + run: | + echo '${{ steps.read_build_info.outputs.result }}' | jq -r '.id' > pr_id.txt + echo '${{ steps.read_build_info.outputs.result }}' | jq -r '.ref' > pr_ref.txt + echo '${{ steps.read_build_info.outputs.result }}' | jq -r '.ref_name' > pr_ref_name.txt + echo '${{ steps.read_build_info.outputs.result }}' | jq -c '.updated_demos' > updated_demos.json + echo '${{ steps.read_build_info.outputs.result }}' | jq -c '.deleted_demos' > deleted_demos.json + + echo "pr_id=$(cat pr_id.txt)" >> $GITHUB_OUTPUT + echo "pr_ref=$(cat pr_ref.txt)" >> $GITHUB_OUTPUT + echo "pr_ref_name=$(cat pr_ref_name.txt)" >> $GITHUB_OUTPUT + echo "updated_demos=$(cat updated_demos.json)" >> $GITHUB_OUTPUT + echo "deleted_demos=$(cat deleted_demos.json)" >> $GITHUB_OUTPUT + + # Set job outputs for downstream jobs + - name: Set job outputs + if: github.event.workflow_run.event == 'pull_request' && steps.build_context.outputs.result != '' + id: set_job_outputs + run: | + echo "pr_id=${{ steps.pr_info.outputs.pr_id }}" >> $GITHUB_OUTPUT + echo "pr_ref=${{ steps.pr_info.outputs.pr_ref }}" >> $GITHUB_OUTPUT + echo "pr_ref_name=${{ steps.pr_info.outputs.pr_ref_name }}" >> $GITHUB_OUTPUT + echo "updated_demos=${{ steps.pr_info.outputs.updated_demos }}" >> $GITHUB_OUTPUT + echo "deleted_demos=${{ steps.pr_info.outputs.deleted_demos }}" >> $GITHUB_OUTPUT + outputs: + pr_id: ${{ steps.set_job_outputs.outputs.pr_id }} + pr_ref: ${{ steps.set_job_outputs.outputs.pr_ref }} + pr_ref_name: ${{ steps.set_job_outputs.outputs.pr_ref_name }} + updated_demos: ${{ steps.set_job_outputs.outputs.updated_demos }} + deleted_demos: ${{ steps.set_job_outputs.outputs.deleted_demos }} + + # Step 2: Deploy the demos to SWC deploy-preview-demos: uses: ./.github/workflows/v2-deploy-demos.yml + needs: prepare-build-context + if: github.event.workflow_run.event == 'pull_request' && needs.prepare-build-context.result == 'success' with: - environment: 'swc-staging' # Update this to production later if needed - artifact-name: demo-build-${{ github.event.workflow_run.head_sha }} + # TODO: Update SWC environment to "swc-prod" + environment: 'swc-staging' + artifact-name: demo-build-${{ needs.prepare-build-context.outputs.pr_ref }} preview: true - branch: ${{ github.event.workflow_run.head_branch }} + branch: ${{ needs.prepare-build-context.outputs.pr_ref_name }} secrets: inherit + + # Step 3: Generate a comment with the demo names + generate-comment: + runs-on: ubuntu-latest + needs: prepare-build-context + if: github.event.workflow_run.event == 'pull_request' && needs.prepare-build-context.outputs.pr_id != '' + steps: + # Generate a markdown comment with demo names + - name: Create markdown comment from demo names + id: generate-markdown + run: | + demos="demo1 demo2 demo3" + + comment="### Preview(s) are ready! :tada:\n" + comment+="
\n" + comment+="Toggle to view preview links\n" + comment+="\n" + + for demo in $demos; do + comment+="- [$demo](https://pennylane.ai/qml/demos/$demo?preview=true)\n" + done + + comment+="\n" + comment+="
" + + # Set the markdown as an output variable + echo "::set-output name=markdown::$comment" + + # Post the comment on the pull request + - name: Comment on PR + id: comment-on-pr + uses: XanaduAI/cloud-actions/create-and-update-pull-request-comment@main + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + pull_request_number: ${{ needs.prepare-build-context.outputs.pr_id }} + comment_body: ${{ steps.generate-markdown.outputs.markdown }} From 17f56654c36e1d715b5cf6c7e956589b52245ad9 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Wed, 23 Apr 2025 14:17:32 -0400 Subject: [PATCH 49/60] remove redundant commemt --- .github/workflows/v2-build-pr.yml | 6 ------ .github/workflows/v2-deploy-pr.yml | 10 +--------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/.github/workflows/v2-build-pr.yml b/.github/workflows/v2-build-pr.yml index cbcb772058..2ff2aa2492 100644 --- a/.github/workflows/v2-build-pr.yml +++ b/.github/workflows/v2-build-pr.yml @@ -20,22 +20,18 @@ jobs: updated: ${{ steps.get-changed-demos.outputs.updated }} deleted: ${{ steps.get-changed-demos.outputs.deleted }} steps: - # Checkout the repository - name: Checkout uses: actions/checkout@v4 - # Identify changed demos - name: Get changed demos id: get-changed-demos uses: ./.github/actions/get-changed-demos - # Output the changed demos for debugging - name: Output changed demos run: | echo "Updated Demos: ${{ steps.get-changed-demos.outputs.updated }}" echo "Deleted Demos: ${{ steps.get-changed-demos.outputs.deleted }}" - # Exit workflow if no changes are found - name: Exit if no changes if: steps.get-changed-demos.outputs.updated == '' run: | @@ -63,7 +59,6 @@ jobs: - build - identify-changed-demos steps: - # Save pull request event context to a temporary file - name: Save Pull Request Event Context if: github.event_name == 'pull_request' run: | @@ -78,7 +73,6 @@ jobs: } EOL - # Upload the pull request context as an artifact - name: Upload Pull Request Event Context as Artifact if: github.event_name == 'pull_request' uses: actions/upload-artifact@v4 diff --git a/.github/workflows/v2-deploy-pr.yml b/.github/workflows/v2-deploy-pr.yml index 8779db3878..ffb2a2577f 100644 --- a/.github/workflows/v2-deploy-pr.yml +++ b/.github/workflows/v2-deploy-pr.yml @@ -22,7 +22,6 @@ jobs: runs-on: ubuntu-latest if: github.event.workflow_run.conclusion == 'success' steps: - # Download the build context artifact - name: Download Build Context uses: XanaduAI/cloud-actions/download-github-workflow-artifact@main with: @@ -30,7 +29,6 @@ jobs: artifact_name_regex: '^pr_info$' github_token: ${{ github.token }} - # Check if the build context file exists - name: Check if Build Context file exists id: build_context env: @@ -40,12 +38,10 @@ jobs: echo "result=$context_artifact_file_name" >> $GITHUB_OUTPUT fi - # Unpack the build information if the file exists - name: Unpack Build Information if: steps.build_context.outputs.result != '' run: unzip ${{ steps.build_context.outputs.result }} - # Read the build information from the unpacked file - name: Read Build Information id: read_build_info if: steps.build_context.outputs.result != '' @@ -56,7 +52,6 @@ jobs: const buildData = fs.readFileSync('pr_info.json', 'utf8'); return JSON.parse(buildData); - # Parse pull request event information - name: Parse Pull Request Event Information id: pr_info if: github.event.workflow_run.event == 'pull_request' && steps.build_context.outputs.result != '' @@ -73,7 +68,6 @@ jobs: echo "updated_demos=$(cat updated_demos.json)" >> $GITHUB_OUTPUT echo "deleted_demos=$(cat deleted_demos.json)" >> $GITHUB_OUTPUT - # Set job outputs for downstream jobs - name: Set job outputs if: github.event.workflow_run.event == 'pull_request' && steps.build_context.outputs.result != '' id: set_job_outputs @@ -103,13 +97,12 @@ jobs: branch: ${{ needs.prepare-build-context.outputs.pr_ref_name }} secrets: inherit - # Step 3: Generate a comment with the demo names + # Step 3: Create a comment on the PR with the demo links generate-comment: runs-on: ubuntu-latest needs: prepare-build-context if: github.event.workflow_run.event == 'pull_request' && needs.prepare-build-context.outputs.pr_id != '' steps: - # Generate a markdown comment with demo names - name: Create markdown comment from demo names id: generate-markdown run: | @@ -130,7 +123,6 @@ jobs: # Set the markdown as an output variable echo "::set-output name=markdown::$comment" - # Post the comment on the pull request - name: Comment on PR id: comment-on-pr uses: XanaduAI/cloud-actions/create-and-update-pull-request-comment@main From e9be941f0e493a2d33944d721e9734d4a0a83f5b Mon Sep 17 00:00:00 2001 From: Alan Martin <53958929+Alan-eMartin@users.noreply.github.com> Date: Wed, 23 Apr 2025 14:32:11 -0400 Subject: [PATCH 50/60] Update demonstrations_v2/gbs/demo.py --- demonstrations_v2/gbs/demo.py | 1 - 1 file changed, 1 deletion(-) diff --git a/demonstrations_v2/gbs/demo.py b/demonstrations_v2/gbs/demo.py index a662be1459..e1ecc9c2ba 100644 --- a/demonstrations_v2/gbs/demo.py +++ b/demonstrations_v2/gbs/demo.py @@ -12,7 +12,6 @@ .. related:: - tutorial_gaussian_transformation Gaussian transformation qsim_beyond_classical Beyond classical computing with qsim qonn Optimizing a quantum optical neural network From b589e465033bf14a7ad12a45ca2a53b7522c36c5 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Wed, 23 Apr 2025 16:52:21 -0400 Subject: [PATCH 51/60] use variable --- .github/workflows/v2-deploy-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/v2-deploy-pr.yml b/.github/workflows/v2-deploy-pr.yml index ffb2a2577f..9e5e19652d 100644 --- a/.github/workflows/v2-deploy-pr.yml +++ b/.github/workflows/v2-deploy-pr.yml @@ -106,7 +106,7 @@ jobs: - name: Create markdown comment from demo names id: generate-markdown run: | - demos="demo1 demo2 demo3" + demos="${{ needs.prepare-build-context.outputs.updated_demos }}" comment="### Preview(s) are ready! :tada:\n" comment+="
\n" From f69eb3e3454f73eca45542518da177440ec9727f Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Wed, 23 Apr 2025 17:04:02 -0400 Subject: [PATCH 52/60] remove exit code, use skip? --- .github/workflows/v2-build-pr.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/v2-build-pr.yml b/.github/workflows/v2-build-pr.yml index 2ff2aa2492..b2aa43ccb4 100644 --- a/.github/workflows/v2-build-pr.yml +++ b/.github/workflows/v2-build-pr.yml @@ -36,12 +36,12 @@ jobs: if: steps.get-changed-demos.outputs.updated == '' run: | echo "No changes found in demos. Exiting workflow." - exit 1 # Step 2: Build demos build: uses: ./.github/workflows/v2-build-demos.yml needs: identify-changed-demos + if: needs.identify-changed-demos.outputs.updated != '' with: ref: ${{ github.event.pull_request.head.sha }} demo-names: ${{ needs.identify-changed-demos.outputs.updated }} @@ -58,6 +58,7 @@ jobs: needs: - build - identify-changed-demos + if: needs.identify-changed-demos.outputs.updated != '' steps: - name: Save Pull Request Event Context if: github.event_name == 'pull_request' From a6e57020a36994236202daa9581e668285129896 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Thu, 24 Apr 2025 10:51:03 -0400 Subject: [PATCH 53/60] FMT, and remove unnecessary ifs --- .github/workflows/v2-build-pr.yml | 8 ++++---- .github/workflows/v2-deploy-pr.yml | 7 +++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/v2-build-pr.yml b/.github/workflows/v2-build-pr.yml index b2aa43ccb4..880c2d1b42 100644 --- a/.github/workflows/v2-build-pr.yml +++ b/.github/workflows/v2-build-pr.yml @@ -19,6 +19,7 @@ jobs: outputs: updated: ${{ steps.get-changed-demos.outputs.updated }} deleted: ${{ steps.get-changed-demos.outputs.deleted }} + steps: - name: Checkout uses: actions/checkout@v4 @@ -39,9 +40,10 @@ jobs: # Step 2: Build demos build: - uses: ./.github/workflows/v2-build-demos.yml - needs: identify-changed-demos if: needs.identify-changed-demos.outputs.updated != '' + uses: ./.github/workflows/v2-build-demos.yml + needs: + - identify-changed-demos with: ref: ${{ github.event.pull_request.head.sha }} demo-names: ${{ needs.identify-changed-demos.outputs.updated }} @@ -58,7 +60,6 @@ jobs: needs: - build - identify-changed-demos - if: needs.identify-changed-demos.outputs.updated != '' steps: - name: Save Pull Request Event Context if: github.event_name == 'pull_request' @@ -75,7 +76,6 @@ jobs: EOL - name: Upload Pull Request Event Context as Artifact - if: github.event_name == 'pull_request' uses: actions/upload-artifact@v4 with: name: pr_info diff --git a/.github/workflows/v2-deploy-pr.yml b/.github/workflows/v2-deploy-pr.yml index 9e5e19652d..556d11661e 100644 --- a/.github/workflows/v2-deploy-pr.yml +++ b/.github/workflows/v2-deploy-pr.yml @@ -19,8 +19,8 @@ concurrency: jobs: # Step 1: Prepare the build context prepare-build-context: - runs-on: ubuntu-latest if: github.event.workflow_run.conclusion == 'success' + runs-on: ubuntu-latest steps: - name: Download Build Context uses: XanaduAI/cloud-actions/download-github-workflow-artifact@main @@ -86,9 +86,9 @@ jobs: # Step 2: Deploy the demos to SWC deploy-preview-demos: + if: github.event.workflow_run.event == 'pull_request' && needs.prepare-build-context.result == 'success' uses: ./.github/workflows/v2-deploy-demos.yml needs: prepare-build-context - if: github.event.workflow_run.event == 'pull_request' && needs.prepare-build-context.result == 'success' with: # TODO: Update SWC environment to "swc-prod" environment: 'swc-staging' @@ -99,9 +99,9 @@ jobs: # Step 3: Create a comment on the PR with the demo links generate-comment: + if: github.event.workflow_run.event == 'pull_request' && needs.prepare-build-context.outputs.pr_id != '' runs-on: ubuntu-latest needs: prepare-build-context - if: github.event.workflow_run.event == 'pull_request' && needs.prepare-build-context.outputs.pr_id != '' steps: - name: Create markdown comment from demo names id: generate-markdown @@ -120,7 +120,6 @@ jobs: comment+="\n" comment+="
" - # Set the markdown as an output variable echo "::set-output name=markdown::$comment" - name: Comment on PR From 2f07f37dfb2c7675380d6b0d564c86a49d7bf978 Mon Sep 17 00:00:00 2001 From: Alan Martin <53958929+Alan-eMartin@users.noreply.github.com> Date: Mon, 28 Apr 2025 08:53:09 -0400 Subject: [PATCH 54/60] Update .github/workflows/v2-deploy-pr.yml Co-authored-by: Paul Finlay <50180049+doctorperceptron@users.noreply.github.com> --- .github/workflows/v2-deploy-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/v2-deploy-pr.yml b/.github/workflows/v2-deploy-pr.yml index 556d11661e..f2d6493fdf 100644 --- a/.github/workflows/v2-deploy-pr.yml +++ b/.github/workflows/v2-deploy-pr.yml @@ -45,7 +45,7 @@ jobs: - name: Read Build Information id: read_build_info if: steps.build_context.outputs.result != '' - uses: actions/github-script@v6 + uses: actions/github-script@v7 with: script: | const fs = require('fs'); From 373a4b52bccd96d3f5fdd8c8e3c5fe82c9d83eeb Mon Sep 17 00:00:00 2001 From: Alan Martin <53958929+Alan-eMartin@users.noreply.github.com> Date: Mon, 28 Apr 2025 08:57:17 -0400 Subject: [PATCH 55/60] Update .github/workflows/v2-deploy-pr.yml Co-authored-by: Paul Finlay <50180049+doctorperceptron@users.noreply.github.com> --- .github/workflows/v2-deploy-pr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/v2-deploy-pr.yml b/.github/workflows/v2-deploy-pr.yml index f2d6493fdf..be695e0c6a 100644 --- a/.github/workflows/v2-deploy-pr.yml +++ b/.github/workflows/v2-deploy-pr.yml @@ -112,9 +112,9 @@ jobs: comment+="
\n" comment+="Toggle to view preview links\n" comment+="\n" - + # TODO: Switch to prod once testing is complete for demo in $demos; do - comment+="- [$demo](https://pennylane.ai/qml/demos/$demo?preview=true)\n" + comment+="- [$demo](https://staging.pennylane.ai/qml/demos/$demo?preview=true)\n" done comment+="\n" From a402f51a6fa6f1254f1a6fddbbac90a0fabd93e3 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Mon, 28 Apr 2025 09:09:50 -0400 Subject: [PATCH 56/60] rm on pr --- .github/workflows/v2-build-pr.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/v2-build-pr.yml b/.github/workflows/v2-build-pr.yml index 880c2d1b42..6de172691a 100644 --- a/.github/workflows/v2-build-pr.yml +++ b/.github/workflows/v2-build-pr.yml @@ -62,7 +62,6 @@ jobs: - identify-changed-demos steps: - name: Save Pull Request Event Context - if: github.event_name == 'pull_request' run: | mkdir -p /tmp/pr cat >/tmp/pr/pr_info.json < Date: Mon, 28 Apr 2025 16:12:36 -0400 Subject: [PATCH 57/60] rm branch --- .github/workflows/v2-deploy-demos.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.github/workflows/v2-deploy-demos.yml b/.github/workflows/v2-deploy-demos.yml index 865dcc9fc1..e87f8bf30a 100644 --- a/.github/workflows/v2-deploy-demos.yml +++ b/.github/workflows/v2-deploy-demos.yml @@ -13,10 +13,6 @@ on: description: Whether to deploy demos as preview type: boolean required: true - branch: - description: Branch to checkout - type: string - default: sc-81925-qml-repository-ci-pushes-newly-built-demos ## Should this be updated, this seems out of date? Or should it be removed completely? workflow_dispatch: inputs: @@ -31,10 +27,6 @@ on: description: Whether to deploy demos as preview type: boolean required: true - branch: - description: Branch to checkout - type: string - default: sc-81925-qml-repository-ci-pushes-newly-built-demos ## Should this be updated, this seems out of date? Or should it be removed completely? jobs: deploy-demos: @@ -46,7 +38,6 @@ jobs: - name: Checkout uses: actions/checkout@v4 with: - ref: ${{ inputs.branch }} fetch-depth: 1 - name: Configure AWS credentials @@ -75,7 +66,3 @@ jobs: python3 .github/workflows/qml_pipeline_v2/deploy.py \ --preview ${{ inputs.preview }} \ _build/pack/*.zip - -### TODO: ### -# - Access whether or not the default branch argument should be set, or if should be removed completely -# - See lines 16 and 34 From f4b3c81276822c39309c9a8bbf52efa94b80b561 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Mon, 28 Apr 2025 16:13:14 -0400 Subject: [PATCH 58/60] rm usage of branch --- .github/workflows/v2-deploy-pr.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/v2-deploy-pr.yml b/.github/workflows/v2-deploy-pr.yml index be695e0c6a..8ae1b79f8b 100644 --- a/.github/workflows/v2-deploy-pr.yml +++ b/.github/workflows/v2-deploy-pr.yml @@ -94,7 +94,6 @@ jobs: environment: 'swc-staging' artifact-name: demo-build-${{ needs.prepare-build-context.outputs.pr_ref }} preview: true - branch: ${{ needs.prepare-build-context.outputs.pr_ref_name }} secrets: inherit # Step 3: Create a comment on the PR with the demo links From bc9375bc3abde59e9a4890242cdf22587ed4f757 Mon Sep 17 00:00:00 2001 From: Alan Martin Date: Tue, 29 Apr 2025 09:00:10 -0400 Subject: [PATCH 59/60] update how output is created, update gh token --- .github/workflows/v2-deploy-pr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/v2-deploy-pr.yml b/.github/workflows/v2-deploy-pr.yml index 8ae1b79f8b..3b7883176b 100644 --- a/.github/workflows/v2-deploy-pr.yml +++ b/.github/workflows/v2-deploy-pr.yml @@ -119,12 +119,12 @@ jobs: comment+="\n" comment+="
" - echo "::set-output name=markdown::$comment" + echo "markdown=$comment" >> $GITHUB_OUTPUT - name: Comment on PR id: comment-on-pr uses: XanaduAI/cloud-actions/create-and-update-pull-request-comment@main with: - github_token: ${{ secrets.GITHUB_TOKEN }} + github_token: ${{ secrets.github_token }} pull_request_number: ${{ needs.prepare-build-context.outputs.pr_id }} comment_body: ${{ steps.generate-markdown.outputs.markdown }} From f712b96537d298cd8d766310a6420a4264984fbc Mon Sep 17 00:00:00 2001 From: Alan Martin <53958929+Alan-eMartin@users.noreply.github.com> Date: Tue, 29 Apr 2025 09:06:39 -0400 Subject: [PATCH 60/60] SC-89340 | Add ability to deploy demos manually (#1356) **Summary:** Allow internal users to build and deploy **all** or a select list of demos. **Related GitHub Issues:** Internal --------- Co-authored-by: Paul Finlay <50180049+doctorperceptron@users.noreply.github.com> --- .github/workflows/v2-build-and-deploy.yml | 97 +++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 .github/workflows/v2-build-and-deploy.yml diff --git a/.github/workflows/v2-build-and-deploy.yml b/.github/workflows/v2-build-and-deploy.yml new file mode 100644 index 0000000000..a876231920 --- /dev/null +++ b/.github/workflows/v2-build-and-deploy.yml @@ -0,0 +1,97 @@ +name: V2 Build and Deploy Demos + +on: + workflow_dispatch: + inputs: + environment: + description: SWC environment to deploy to + options: + - swc-staging + - swc-prod + - swc-dev + required: true + type: choice + target: + default: stable + description: PennyLane version to build the demos. Either 'latest' or the most recent 'stable' release. + options: + - latest + - stable + required: true + type: choice + demos: + description: Demos to build and deploy, space-separated list of slugs (e.g. "demo1 demo2 demo3"), or leave empty for all demos. + required: false + type: string + as-previews: + default: false + description: | + Whether to deploy the demos as previews. + + **Please note** that demos built with the latest version cannot be published to swc-staging or swc-prod. + They can only be deployed as previews. + required: false + type: boolean + +jobs: + validate-and-parse-inputs: + runs-on: ubuntu-latest + outputs: + branch: ${{ steps.set-branch.outputs.branch }} + steps: + - name: Set branch + id: set-branch + run: | + if [[ "${{ github.event.inputs.target }}" == "stable" ]]; then + echo "branch=master" >> $GITHUB_OUTPUT + elif [[ "${{ github.event.inputs.target }}" == "latest" ]]; then + echo "branch=dev" >> $GITHUB_OUTPUT + else + echo "branch=" >> $GITHUB_OUTPUT + fi + + - name: Validate preview input + id: validate-preview + run: | + if [[ + ("${{ github.event.inputs.environment }}" == "swc-staging" || + "${{ github.event.inputs.environment }}" == "swc-prod") && + "${{ github.event.inputs.target }}" == "latest" && + "${{ github.event.inputs.as-previews }}" == "false" + ]]; then + echo "=========================" + echo "🚫 Invalid input detected:" + echo "Demos built with the latest version cannot be published to 'swc-staging' or 'swc-prod'." + echo "They can only be deployed as previews." + echo "Please set the 'as-previews' input to 'true' in your workflow configuration." + echo "=========================" + exit 1 + fi + + build: + needs: validate-and-parse-inputs + if: > + (needs.validate-and-parse-inputs.outputs.branch == 'master') || + (needs.validate-and-parse-inputs.outputs.branch == 'dev') + uses: ./.github/workflows/v2-build-demos.yml + with: + ref: ${{ needs.validate-and-parse-inputs.outputs.branch }} + demo-names: ${{ github.event.inputs.demos }} + dev: ${{ github.event.inputs.target == 'latest' }} + save-artifact: true + artifact-name: build-and-deploy-${{ github.event.inputs.target }} + keep-going: false + quiet: false + batch_size: 10 + + deploy: + uses: ./.github/workflows/v2-deploy-demos.yml + needs: + - validate-and-parse-inputs + - build + secrets: inherit + with: + environment: ${{ github.event.inputs.environment }} + artifact-name: build-and-deploy-${{ github.event.inputs.target }} + preview: ${{ github.event.inputs.as-previews }} + branch: ${{ needs.validate-and-parse-inputs.outputs.branch }} \ No newline at end of file