From 621ecc8ab259fc68595457f2439ceb8e9ce1b9b0 Mon Sep 17 00:00:00 2001 From: pyth0n1c <87383215+pyth0n1c@users.noreply.github.com> Date: Mon, 30 Aug 2021 11:57:40 -0700 Subject: [PATCH 01/11] Testing the syntax for the source branch for a pull request. --- .github/workflows/detection-testing.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/detection-testing.yml b/.github/workflows/detection-testing.yml index 241c21d3ec..0a7ff7afc1 100644 --- a/.github/workflows/detection-testing.yml +++ b/.github/workflows/detection-testing.yml @@ -30,9 +30,8 @@ jobs: runs-on: ubuntu-latest environment: Detection-Testing-Approval needs: [validate-tag-if-present] - #Only run when we are pushing to the head of a branch or on a PR. - #This implicitly means that we do not run on a tag - if: startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/pull/') + #Only run when tagged + if: startsWith(github.ref, 'refs/heads/') steps: - name: Checkout Repo @@ -80,6 +79,11 @@ jobs: source venv/bin/activate pip install -q -r requirements.txt + echo "First give the full ref GITHUB_REF: ${{ GITHUB_REF }}" + echo "Pull request's base branch is: ${BASE_BRANCH}" + echo "Then give the github.event.pull_request.head.ref: ${{ github.event.pull_request.head.ref }}" + + if [[ ! -z "${{ github.event.issue.pull_request }}" && ! -z "${{ github.event.issue.number }}" ]]; then python3 main.py -b develop -pr ${{ github.event.issue.number }} From 196a7a07f922181a185b0a8874f2cd90ffce7fa5 Mon Sep 17 00:00:00 2001 From: pyth0n1c <87383215+pyth0n1c@users.noreply.github.com> Date: Mon, 30 Aug 2021 12:00:05 -0700 Subject: [PATCH 02/11] Wrong escape sequence for GITHUB_REF --- .github/workflows/detection-testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/detection-testing.yml b/.github/workflows/detection-testing.yml index 0a7ff7afc1..c981d38e83 100644 --- a/.github/workflows/detection-testing.yml +++ b/.github/workflows/detection-testing.yml @@ -79,7 +79,7 @@ jobs: source venv/bin/activate pip install -q -r requirements.txt - echo "First give the full ref GITHUB_REF: ${{ GITHUB_REF }}" + echo "First give the full ref GITHUB_REF: ${ GITHUB_REF }" echo "Pull request's base branch is: ${BASE_BRANCH}" echo "Then give the github.event.pull_request.head.ref: ${{ github.event.pull_request.head.ref }}" From 7500d66b3252bb8f933db4a6ab7857921738eebd Mon Sep 17 00:00:00 2001 From: pyth0n1c <87383215+pyth0n1c@users.noreply.github.com> Date: Mon, 30 Aug 2021 12:03:47 -0700 Subject: [PATCH 03/11] Fixing bad github_ref substitution due to spacing. --- .github/workflows/detection-testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/detection-testing.yml b/.github/workflows/detection-testing.yml index c981d38e83..b078517546 100644 --- a/.github/workflows/detection-testing.yml +++ b/.github/workflows/detection-testing.yml @@ -79,7 +79,7 @@ jobs: source venv/bin/activate pip install -q -r requirements.txt - echo "First give the full ref GITHUB_REF: ${ GITHUB_REF }" + echo "First give the full ref GITHUB_REF: ${GITHUB_REF}" echo "Pull request's base branch is: ${BASE_BRANCH}" echo "Then give the github.event.pull_request.head.ref: ${{ github.event.pull_request.head.ref }}" From 3d6b2e074dc7f8f5d4e80f8712ce7a84c06633d3 Mon Sep 17 00:00:00 2001 From: pyth0n1c <87383215+pyth0n1c@users.noreply.github.com> Date: Mon, 30 Aug 2021 12:08:51 -0700 Subject: [PATCH 04/11] Fixed detection testing to run on PR and push instead of just push. We were bailing on PR --- .github/workflows/detection-testing.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/detection-testing.yml b/.github/workflows/detection-testing.yml index b078517546..da39d3e038 100644 --- a/.github/workflows/detection-testing.yml +++ b/.github/workflows/detection-testing.yml @@ -30,8 +30,6 @@ jobs: runs-on: ubuntu-latest environment: Detection-Testing-Approval needs: [validate-tag-if-present] - #Only run when tagged - if: startsWith(github.ref, 'refs/heads/') steps: - name: Checkout Repo From c76f9c7c617392daa6a8d770e2f8c29500501ab2 Mon Sep 17 00:00:00 2001 From: pyth0n1c <87383215+pyth0n1c@users.noreply.github.com> Date: Mon, 30 Aug 2021 13:14:15 -0700 Subject: [PATCH 05/11] Fixed github actions testing behavior for Push vs PR for detection testing. Now checking out of proper source branch and running main.py on the proper source brach and PR number. --- .github/workflows/detection-testing.yml | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/detection-testing.yml b/.github/workflows/detection-testing.yml index da39d3e038..eaa30fe0bc 100644 --- a/.github/workflows/detection-testing.yml +++ b/.github/workflows/detection-testing.yml @@ -34,9 +34,16 @@ jobs: - name: Checkout Repo uses: actions/checkout@v2 - with: - ref: 'develop' + + #The following branch name only works (and is only used) for a push + #to a branch. We used a different method for getting the source branch + #from a PR + - name: Get branch and PR required for detection testing main.py + id: vars + run: | + echo "::set-output name=branch::${GITHUB_REF#refs/heads/}" + - name: Install System Packages run: | sudo apt update -qq @@ -77,14 +84,10 @@ jobs: source venv/bin/activate pip install -q -r requirements.txt - echo "First give the full ref GITHUB_REF: ${GITHUB_REF}" - echo "Pull request's base branch is: ${BASE_BRANCH}" - echo "Then give the github.event.pull_request.head.ref: ${{ github.event.pull_request.head.ref }}" - - if [[ ! -z "${{ github.event.issue.pull_request }}" && ! -z "${{ github.event.issue.number }}" ]]; then - python3 main.py -b develop -pr ${{ github.event.issue.number }} - + echo "Pull request from source branch [${{ github.event.pull_request.head.ref }}] for PR number [${{ github.event.issue.number }}]" + python3 main.py -b ${{ github.event.pull_request.head.ref }} -pr ${{ github.event.issue.number }} else - python3 main.py -b develop + echo "Push from branch [${{ steps.vars.outputs.branch }}]" + python3 main.py -b ${{ steps.vars.outputs.branch }} fi From 851e0bd536630ef5dc7b4b269500098d7f5dca19 Mon Sep 17 00:00:00 2001 From: pyth0n1c <87383215+pyth0n1c@users.noreply.github.com> Date: Mon, 30 Aug 2021 13:15:28 -0700 Subject: [PATCH 06/11] Removed duplicate id from detection-testing.yml --- .github/workflows/detection-testing.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/detection-testing.yml b/.github/workflows/detection-testing.yml index eaa30fe0bc..c4ca7971e5 100644 --- a/.github/workflows/detection-testing.yml +++ b/.github/workflows/detection-testing.yml @@ -62,10 +62,6 @@ jobs: source venv/bin/activate python3 -m pip install -q -r requirements.txt - - name: Get branch and PR required for detection testing main.py - id: vars - run: | - echo ::set-output name=tag::${GITHUB_REF#refs/tags/} #Set up credentials in the environment so that boto will be able to find them - uses: aws-actions/configure-aws-credentials@v1 From 5bb24d5fc9cf78d0bd78405aa12621ee0bf73d86 Mon Sep 17 00:00:00 2001 From: pyth0n1c <87383215+pyth0n1c@users.noreply.github.com> Date: Mon, 30 Aug 2021 13:22:47 -0700 Subject: [PATCH 07/11] Fixed variable name for pull request number. --- .github/workflows/detection-testing.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/detection-testing.yml b/.github/workflows/detection-testing.yml index c4ca7971e5..b7fc8ae6b8 100644 --- a/.github/workflows/detection-testing.yml +++ b/.github/workflows/detection-testing.yml @@ -80,9 +80,9 @@ jobs: source venv/bin/activate pip install -q -r requirements.txt - if [[ ! -z "${{ github.event.issue.pull_request }}" && ! -z "${{ github.event.issue.number }}" ]]; then + if [[ ! -z "${{ github.event.issue.pull_request }}" && ! -z "${{ github.event.pull_request.number }}" ]]; then echo "Pull request from source branch [${{ github.event.pull_request.head.ref }}] for PR number [${{ github.event.issue.number }}]" - python3 main.py -b ${{ github.event.pull_request.head.ref }} -pr ${{ github.event.issue.number }} + python3 main.py -b ${{ github.event.pull_request.head.ref }} -pr ${{ github.event.pull_request.number }} else echo "Push from branch [${{ steps.vars.outputs.branch }}]" python3 main.py -b ${{ steps.vars.outputs.branch }} From 8429e518634d80a5dee0ade5a2f229534640eed8 Mon Sep 17 00:00:00 2001 From: pyth0n1c <87383215+pyth0n1c@users.noreply.github.com> Date: Mon, 30 Aug 2021 14:18:46 -0700 Subject: [PATCH 08/11] Testing what is being passed to detectrion testing. --- .github/workflows/detection-testing.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/detection-testing.yml b/.github/workflows/detection-testing.yml index b7fc8ae6b8..d1bf1291b5 100644 --- a/.github/workflows/detection-testing.yml +++ b/.github/workflows/detection-testing.yml @@ -82,8 +82,8 @@ jobs: if [[ ! -z "${{ github.event.issue.pull_request }}" && ! -z "${{ github.event.pull_request.number }}" ]]; then echo "Pull request from source branch [${{ github.event.pull_request.head.ref }}] for PR number [${{ github.event.issue.number }}]" - python3 main.py -b ${{ github.event.pull_request.head.ref }} -pr ${{ github.event.pull_request.number }} + #python3 main.py -b ${{ github.event.pull_request.head.ref }} -pr ${{ github.event.pull_request.number }} else echo "Push from branch [${{ steps.vars.outputs.branch }}]" - python3 main.py -b ${{ steps.vars.outputs.branch }} + #python3 main.py -b ${{ steps.vars.outputs.branch }} fi From 9ad3e184e2bbe8a090164c7d8cdb889875090c3e Mon Sep 17 00:00:00 2001 From: pyth0n1c <87383215+pyth0n1c@users.noreply.github.com> Date: Mon, 30 Aug 2021 14:24:51 -0700 Subject: [PATCH 09/11] Priting out pr number and ohter variables --- .github/workflows/detection-testing.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/detection-testing.yml b/.github/workflows/detection-testing.yml index d1bf1291b5..5a9e7eaa04 100644 --- a/.github/workflows/detection-testing.yml +++ b/.github/workflows/detection-testing.yml @@ -80,6 +80,9 @@ jobs: source venv/bin/activate pip install -q -r requirements.txt + echo "github.event.issue.pull_request : [${{ github.event.issue.pull_request }}]" + echo "github.event.pull_request.number: [${{ github.event.pull_request.number }}]" + echo "steps.vars.outputs.branch : [${{ steps.vars.outputs.branch }}]" if [[ ! -z "${{ github.event.issue.pull_request }}" && ! -z "${{ github.event.pull_request.number }}" ]]; then echo "Pull request from source branch [${{ github.event.pull_request.head.ref }}] for PR number [${{ github.event.issue.number }}]" #python3 main.py -b ${{ github.event.pull_request.head.ref }} -pr ${{ github.event.pull_request.number }} From 289360bc8de302ca94e8cd1b871e04dc4ede26ab Mon Sep 17 00:00:00 2001 From: pyth0n1c <87383215+pyth0n1c@users.noreply.github.com> Date: Mon, 30 Aug 2021 14:35:20 -0700 Subject: [PATCH 10/11] Print out more env variables associated with pull request. --- .github/workflows/detection-testing.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/detection-testing.yml b/.github/workflows/detection-testing.yml index 5a9e7eaa04..f9c704b332 100644 --- a/.github/workflows/detection-testing.yml +++ b/.github/workflows/detection-testing.yml @@ -80,9 +80,12 @@ jobs: source venv/bin/activate pip install -q -r requirements.txt - echo "github.event.issue.pull_request : [${{ github.event.issue.pull_request }}]" - echo "github.event.pull_request.number: [${{ github.event.pull_request.number }}]" - echo "steps.vars.outputs.branch : [${{ steps.vars.outputs.branch }}]" + echo "github.event.issue.pull_request : [${{ github.event.issue.pull_request }}]" + echo "github.event.pull_request.number : [${{ github.event.pull_request.number }}]" + echo "steps.vars.outputs.branch : [${{ steps.vars.outputs.branch }}]" + echo "github.event.pull_request.head.ref: [${{ github.event.pull_request.head.ref }}]" + + if [[ ! -z "${{ github.event.issue.pull_request }}" && ! -z "${{ github.event.pull_request.number }}" ]]; then echo "Pull request from source branch [${{ github.event.pull_request.head.ref }}] for PR number [${{ github.event.issue.number }}]" #python3 main.py -b ${{ github.event.pull_request.head.ref }} -pr ${{ github.event.pull_request.number }} From bddb7a7835b9851155baac3ca6887e0b254fd060 Mon Sep 17 00:00:00 2001 From: pyth0n1c <87383215+pyth0n1c@users.noreply.github.com> Date: Mon, 30 Aug 2021 14:41:20 -0700 Subject: [PATCH 11/11] Fixed correct branch and PR number for both pushes and PRs for detection testing. --- .github/workflows/detection-testing.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/detection-testing.yml b/.github/workflows/detection-testing.yml index f9c704b332..4c249d4452 100644 --- a/.github/workflows/detection-testing.yml +++ b/.github/workflows/detection-testing.yml @@ -85,11 +85,10 @@ jobs: echo "steps.vars.outputs.branch : [${{ steps.vars.outputs.branch }}]" echo "github.event.pull_request.head.ref: [${{ github.event.pull_request.head.ref }}]" - - if [[ ! -z "${{ github.event.issue.pull_request }}" && ! -z "${{ github.event.pull_request.number }}" ]]; then + if [[ ! -z "${{ github.event.pull_request.head.ref }}" && ! -z "${{ github.event.pull_request.number }}" ]]; then echo "Pull request from source branch [${{ github.event.pull_request.head.ref }}] for PR number [${{ github.event.issue.number }}]" - #python3 main.py -b ${{ github.event.pull_request.head.ref }} -pr ${{ github.event.pull_request.number }} + python3 main.py -b ${{ github.event.pull_request.head.ref }} -pr ${{ github.event.pull_request.number }} else echo "Push from branch [${{ steps.vars.outputs.branch }}]" - #python3 main.py -b ${{ steps.vars.outputs.branch }} + python3 main.py -b ${{ steps.vars.outputs.branch }} fi