From 9aa3cc88bd5aa11f12a13d92697de2e1d8bedede Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Wed, 18 Oct 2023 17:29:20 +0000 Subject: [PATCH 01/44] trying status of CI as a workflow action --- .github/workflows/orion_status.yaml | 57 +++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/orion_status.yaml diff --git a/.github/workflows/orion_status.yaml b/.github/workflows/orion_status.yaml new file mode 100644 index 0000000000..38eb189b2e --- /dev/null +++ b/.github/workflows/orion_status.yaml @@ -0,0 +1,57 @@ +name: OrionStatus + +on: + workflow_dispatch: + pull_request: + types: [labeled] + +jobs: + + getlabels: + runs-on: ubuntu-latest + outputs: + labels: ${{ steps.id.outputs.labels }} + steps: + - name: Get Label Steps + id: id + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + OWNER: ${{ github.repository_owner }} + REPO_NAME: ${{ github.event.repository.name }} + PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }} + run: | + LABELS1="$(gh api repos/$OWNER/$REPO_NAME/pulls/$PULL_REQUEST_NUMBER --jq '.labels.[].name')" + LABELS=$(echo "$LABELS1" | tr '\n' ' ') + echo "labels=$LABELS" >> $GITHUB_OUTPUT + + Ready: + if: contains( needs.getlabels.outputs.labels, 'CI-Orion-Ready') + runs-on: ubuntu-latest + needs: + - getlabels + + steps: + - name: Ready + run: echo "Ready" + + Building: + if: contains( needs.getlabels.outputs.labels, 'CI-Orion-Building') + runs-on: ubuntu-latest + needs: + - getlabels + - Ready + + steps: + - name: Building + run: echo "Building" + + Passed: + if: contains( needs.getlabels.outputs.labels, 'CI-Orion-Passed') + runs-on: ubuntu-latest + needs: + - getlabels + - Building + + steps: + - name: Passed + run: echo "Passed" From 92f2306f340ef297f469451df9ac323df5e8260f Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Wed, 18 Oct 2023 18:20:45 +0000 Subject: [PATCH 02/44] added PR number as input --- .github/workflows/orion_status.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/orion_status.yaml b/.github/workflows/orion_status.yaml index 38eb189b2e..a673d5093f 100644 --- a/.github/workflows/orion_status.yaml +++ b/.github/workflows/orion_status.yaml @@ -2,8 +2,11 @@ name: OrionStatus on: workflow_dispatch: - pull_request: - types: [labeled] + inputs: + pr_number: + description: PR number + type: string + pull_request: [labeled] jobs: @@ -18,7 +21,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} OWNER: ${{ github.repository_owner }} REPO_NAME: ${{ github.event.repository.name }} - PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }} + PULL_REQUEST_NUMBER: ${{ inputs.pr_number }} run: | LABELS1="$(gh api repos/$OWNER/$REPO_NAME/pulls/$PULL_REQUEST_NUMBER --jq '.labels.[].name')" LABELS=$(echo "$LABELS1" | tr '\n' ' ') From 8c4b2f0246bf0f1709f317ac349d5a43e48ab53b Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Wed, 18 Oct 2023 18:24:37 +0000 Subject: [PATCH 03/44] Update orion_status.yaml type labeled on new line --- .github/workflows/orion_status.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/orion_status.yaml b/.github/workflows/orion_status.yaml index a673d5093f..210e41fb1f 100644 --- a/.github/workflows/orion_status.yaml +++ b/.github/workflows/orion_status.yaml @@ -6,7 +6,8 @@ on: pr_number: description: PR number type: string - pull_request: [labeled] + pull_request: + types: [labeled] jobs: From 74aa7347c606d6a9edcd842f27af8f5c8fb85901 Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Wed, 18 Oct 2023 18:37:54 +0000 Subject: [PATCH 04/44] take out PR on on --- .github/workflows/orion_status.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/orion_status.yaml b/.github/workflows/orion_status.yaml index a673d5093f..80bb6861c5 100644 --- a/.github/workflows/orion_status.yaml +++ b/.github/workflows/orion_status.yaml @@ -6,7 +6,6 @@ on: pr_number: description: PR number type: string - pull_request: [labeled] jobs: From 9b8d071e4d6a550d027719e09d06814673f6992f Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Wed, 18 Oct 2023 19:07:17 +0000 Subject: [PATCH 05/44] take out PR on on do loops --- .github/workflows/orion_status.yaml | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/orion_status.yaml b/.github/workflows/orion_status.yaml index 80bb6861c5..b92c27031b 100644 --- a/.github/workflows/orion_status.yaml +++ b/.github/workflows/orion_status.yaml @@ -27,17 +27,19 @@ jobs: echo "labels=$LABELS" >> $GITHUB_OUTPUT Ready: - if: contains( needs.getlabels.outputs.labels, 'CI-Orion-Ready') runs-on: ubuntu-latest needs: - getlabels steps: - name: Ready - run: echo "Ready" + run: | + until[ $ready ] + do + ready=$(${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Ready') }}) + done Building: - if: contains( needs.getlabels.outputs.labels, 'CI-Orion-Building') runs-on: ubuntu-latest needs: - getlabels @@ -45,10 +47,13 @@ jobs: steps: - name: Building - run: echo "Building" + run: | + until[ $building ] + do + building=$(${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Building') }}) + done Passed: - if: contains( needs.getlabels.outputs.labels, 'CI-Orion-Passed') runs-on: ubuntu-latest needs: - getlabels @@ -56,4 +61,8 @@ jobs: steps: - name: Passed - run: echo "Passed" + run: | + until[ $passed ] + do + passed=$(${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Passed') }}) + done From de4fd80d356447194bc6e9386bc8b77b21dc63db Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Wed, 18 Oct 2023 19:15:24 +0000 Subject: [PATCH 06/44] take out PR on on do loops syntax until --- .github/workflows/orion_status.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/orion_status.yaml b/.github/workflows/orion_status.yaml index b92c27031b..cc745e4d1d 100644 --- a/.github/workflows/orion_status.yaml +++ b/.github/workflows/orion_status.yaml @@ -34,7 +34,8 @@ jobs: steps: - name: Ready run: | - until[ $ready ] + ready=False + until [ $ready ]; do ready=$(${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Ready') }}) done @@ -48,7 +49,8 @@ jobs: steps: - name: Building run: | - until[ $building ] + building=False + until [ $building ]; do building=$(${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Building') }}) done @@ -62,7 +64,8 @@ jobs: steps: - name: Passed run: | - until[ $passed ] + passed=False + until [ $passed ]; do passed=$(${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Passed') }}) done From 3623231113fda22da14de68a0c30d6301619fb78 Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Wed, 18 Oct 2023 19:32:20 +0000 Subject: [PATCH 07/44] take out PR on on do loops syntax until singleton --- .github/workflows/orion_status.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/orion_status.yaml b/.github/workflows/orion_status.yaml index cc745e4d1d..86750b1f02 100644 --- a/.github/workflows/orion_status.yaml +++ b/.github/workflows/orion_status.yaml @@ -35,7 +35,7 @@ jobs: - name: Ready run: | ready=False - until [ $ready ]; + until $ready do ready=$(${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Ready') }}) done @@ -50,7 +50,7 @@ jobs: - name: Building run: | building=False - until [ $building ]; + until $building do building=$(${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Building') }}) done @@ -65,7 +65,7 @@ jobs: - name: Passed run: | passed=False - until [ $passed ]; + until $passed do passed=$(${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Passed') }}) done From 218a084cfcef6032419d9df0bd40a1d6840009be Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Wed, 18 Oct 2023 19:37:54 +0000 Subject: [PATCH 08/44] take out PR on on do loops syntax until set faulse --- .github/workflows/orion_status.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/orion_status.yaml b/.github/workflows/orion_status.yaml index 86750b1f02..7c29c23ed3 100644 --- a/.github/workflows/orion_status.yaml +++ b/.github/workflows/orion_status.yaml @@ -34,7 +34,7 @@ jobs: steps: - name: Ready run: | - ready=False + ready=false until $ready do ready=$(${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Ready') }}) @@ -49,7 +49,7 @@ jobs: steps: - name: Building run: | - building=False + building=false until $building do building=$(${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Building') }}) @@ -64,7 +64,7 @@ jobs: steps: - name: Passed run: | - passed=False + passed=false until $passed do passed=$(${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Passed') }}) From 83d5c791058b0486c7d506f88d28fb2303ad113d Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Wed, 18 Oct 2023 19:53:11 +0000 Subject: [PATCH 09/44] take out PR on on do loops syntax until direct --- .github/workflows/orion_status.yaml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/orion_status.yaml b/.github/workflows/orion_status.yaml index 7c29c23ed3..743d89b9fe 100644 --- a/.github/workflows/orion_status.yaml +++ b/.github/workflows/orion_status.yaml @@ -34,10 +34,8 @@ jobs: steps: - name: Ready run: | - ready=false - until $ready + until ${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Ready') }} do - ready=$(${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Ready') }}) done Building: @@ -49,10 +47,8 @@ jobs: steps: - name: Building run: | - building=false - until $building + until ${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Building') }} do - building=$(${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Building') }}) done Passed: @@ -64,8 +60,6 @@ jobs: steps: - name: Passed run: | - passed=false - until $passed + until ${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Passed') }} do - passed=$(${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Passed') }}) done From de55f1a651e70204e0164fc5ef00f9faf6aaa9de Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Wed, 18 Oct 2023 20:01:32 +0000 Subject: [PATCH 10/44] take out PR on on do loops needed noop --- .github/workflows/orion_status.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/orion_status.yaml b/.github/workflows/orion_status.yaml index 743d89b9fe..e5d62e19f6 100644 --- a/.github/workflows/orion_status.yaml +++ b/.github/workflows/orion_status.yaml @@ -36,7 +36,8 @@ jobs: run: | until ${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Ready') }} do - done + noop="" + done Building: runs-on: ubuntu-latest @@ -49,7 +50,8 @@ jobs: run: | until ${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Building') }} do - done + noop="" + done Passed: runs-on: ubuntu-latest @@ -62,4 +64,5 @@ jobs: run: | until ${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Passed') }} do - done + noop="" + done From 5b3e6cc3a6b3b3b44a9e12032c866d6137749f27 Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Wed, 18 Oct 2023 21:06:49 +0000 Subject: [PATCH 11/44] take out PR jobs with no steps --- .github/workflows/orion_status.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/orion_status.yaml b/.github/workflows/orion_status.yaml index e5d62e19f6..eacfa374d9 100644 --- a/.github/workflows/orion_status.yaml +++ b/.github/workflows/orion_status.yaml @@ -31,7 +31,6 @@ jobs: needs: - getlabels - steps: - name: Ready run: | until ${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Ready') }} @@ -45,7 +44,6 @@ jobs: - getlabels - Ready - steps: - name: Building run: | until ${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Building') }} @@ -59,7 +57,6 @@ jobs: - getlabels - Building - steps: - name: Passed run: | until ${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Passed') }} From 022dd282373d24e702ef059948b65a1cd89144b8 Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Wed, 18 Oct 2023 21:07:44 +0000 Subject: [PATCH 12/44] take out PR jobs need steps --- .github/workflows/orion_status.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/orion_status.yaml b/.github/workflows/orion_status.yaml index eacfa374d9..cc483383dc 100644 --- a/.github/workflows/orion_status.yaml +++ b/.github/workflows/orion_status.yaml @@ -31,6 +31,7 @@ jobs: needs: - getlabels + steps: - name: Ready run: | until ${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Ready') }} @@ -44,6 +45,7 @@ jobs: - getlabels - Ready + steps: - name: Building run: | until ${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Building') }} @@ -57,9 +59,10 @@ jobs: - getlabels - Building + steps: - name: Passed run: | until ${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Passed') }} do - noop="" + noop="" done From c9c8ae25820be9f8ca8a29d37e360d7a0845005f Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Wed, 18 Oct 2023 21:09:01 +0000 Subject: [PATCH 13/44] take out PR jobs need steps --- .github/workflows/orion_status.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/orion_status.yaml b/.github/workflows/orion_status.yaml index cc483383dc..5c53186e56 100644 --- a/.github/workflows/orion_status.yaml +++ b/.github/workflows/orion_status.yaml @@ -36,7 +36,7 @@ jobs: run: | until ${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Ready') }} do - noop="" + sleep 10m done Building: @@ -50,7 +50,7 @@ jobs: run: | until ${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Building') }} do - noop="" + sleep 10m done Passed: @@ -64,5 +64,5 @@ jobs: run: | until ${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Passed') }} do - noop="" + sleep 10m done From 74a5b5a85b6fc3667c621cf9ff757f2f6dbca14e Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Thu, 19 Oct 2023 19:06:17 +0000 Subject: [PATCH 14/44] added reusable workflow for getting lables for each job --- .github/workflows/getlabels.yaml | 57 +++++++++++++++++++++++++++++ .github/workflows/orion_status.yaml | 17 --------- 2 files changed, 57 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/getlabels.yaml diff --git a/.github/workflows/getlabels.yaml b/.github/workflows/getlabels.yaml new file mode 100644 index 0000000000..dda30b2183 --- /dev/null +++ b/.github/workflows/getlabels.yaml @@ -0,0 +1,57 @@ +on: + workflow_call: + inputs: + pr_number: + required: true + type: string + max_runtime: + required: false + type: string + stage: + required: true + type: string + + outputs: + state: + description: "The return state of Stage (true/false)" + value: ${{ jobs.getlabels.outputs.state }} + + secrets: + token: + required: true +jobs: + + getlabels: + runs-on: ubuntu-latest + outputs: + state: ${{ steps.id.outputs.state }} + steps: + - name: Get Label Steps + id: id + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + OWNER: ${{ github.repository_owner }} + REPO_NAME: ${{ github.event.repository.name }} + PULL_REQUEST_NUMBER: ${{ inputs.pr_number }} + STAGE: ${{ inputs.stage }} + MAX_TIME: ${{ inputs.max_runtime }} + run: | + DONE=false + count=0 + until false + do + LABELS1="$(gh api repos/$OWNER/$REPO_NAME/pulls/$PULL_REQUEST_NUMBER --jq '.labels.[].name')" + LABELS=$(echo "$LABELS1" | tr '\n' ' ') + check_label="CI-Orion-${STAGE}" + if [[ "${LABELS}" == *"${check_label}"* ]]; then + DONE=true + break + fi + sleep 10m + count=$((count+10)) + if [[ ${count} -gt ${MAX_TIME} ]]; then + DONE=false + break + fi + done + echo "state=$DONE" >> $GITHUB_OUPUT diff --git a/.github/workflows/orion_status.yaml b/.github/workflows/orion_status.yaml index 5c53186e56..8800609508 100644 --- a/.github/workflows/orion_status.yaml +++ b/.github/workflows/orion_status.yaml @@ -9,23 +9,6 @@ on: jobs: - getlabels: - runs-on: ubuntu-latest - outputs: - labels: ${{ steps.id.outputs.labels }} - steps: - - name: Get Label Steps - id: id - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - OWNER: ${{ github.repository_owner }} - REPO_NAME: ${{ github.event.repository.name }} - PULL_REQUEST_NUMBER: ${{ inputs.pr_number }} - run: | - LABELS1="$(gh api repos/$OWNER/$REPO_NAME/pulls/$PULL_REQUEST_NUMBER --jq '.labels.[].name')" - LABELS=$(echo "$LABELS1" | tr '\n' ' ') - echo "labels=$LABELS" >> $GITHUB_OUTPUT - Ready: runs-on: ubuntu-latest needs: From 9e306ef382b4844d78e28e5ded0d8212661482f8 Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Thu, 19 Oct 2023 19:14:11 +0000 Subject: [PATCH 15/44] fixed uses path --- .github/workflows/orion_status.yaml | 78 +++++++++++++++++------------ 1 file changed, 47 insertions(+), 31 deletions(-) diff --git a/.github/workflows/orion_status.yaml b/.github/workflows/orion_status.yaml index 8800609508..d56a050129 100644 --- a/.github/workflows/orion_status.yaml +++ b/.github/workflows/orion_status.yaml @@ -6,46 +6,62 @@ on: pr_number: description: PR number type: string + max_runtime: + description: Maximum time out time for running experment + type: string jobs: + get_Ready: + uses: ./.github/workflows/getlabels.yaml + with: + pr_number: inputs.pr_number + max_runtime: 20 + stage: "Ready" + secrets: inherit + Ready: runs-on: ubuntu-latest - needs: - - getlabels - + needs: get_Ready steps: - - name: Ready - run: | - until ${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Ready') }} - do - sleep 10m - done + - run: | + if [[ ${{ needs.get_Ready.outputs.state }} ]]; then + echo "Waiting for Ready State timmed out" + exit 1 + fi + + get_Building: + uses: ./.github/workflows/getlabels.yaml + with: + pr_number: inputs.pr_number + max_runtime: 40 + stage: "Building" + secrets: inherit Building: runs-on: ubuntu-latest - needs: - - getlabels - - Ready - + needs: get_Building steps: - - name: Building - run: | - until ${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Building') }} - do - sleep 10m - done - - Passed: - runs-on: ubuntu-latest - needs: - - getlabels - - Building + - run: | + if [[ ${{ needs.get_Building.outputs.state }} ]]; then + echo "Waiting for Ready State timmed out" + exit 1 + fi + get_Running: + uses: ./.github/workflows/getlabels.yaml + with: + pr_number: inputs.pr_number + max_runtime: 60 + stage: "Running" + secrets: inherit + + Running: + runs-on: ubuntu-latest + needs: get_Running steps: - - name: Passed - run: | - until ${{ contains( needs.getlabels.outputs.labels, 'CI-Orion-Passed') }} - do - sleep 10m - done + - run: | + if [[ ${{ needs.get_Running.outputs.state }} ]]; then + echo "Waiting for Ready State timmed out" + exit 1 + fi \ No newline at end of file From 1430ab38082525044b85286b51d8584aedbf63b3 Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Thu, 19 Oct 2023 19:39:17 +0000 Subject: [PATCH 16/44] added dependances for main jobs and name in getlabels --- .github/workflows/getlabels.yaml | 2 ++ .github/workflows/orion_status.yaml | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/getlabels.yaml b/.github/workflows/getlabels.yaml index dda30b2183..ffc40cc924 100644 --- a/.github/workflows/getlabels.yaml +++ b/.github/workflows/getlabels.yaml @@ -1,3 +1,5 @@ +name: Get Labels + on: workflow_call: inputs: diff --git a/.github/workflows/orion_status.yaml b/.github/workflows/orion_status.yaml index d56a050129..b2a80a40b3 100644 --- a/.github/workflows/orion_status.yaml +++ b/.github/workflows/orion_status.yaml @@ -40,7 +40,7 @@ jobs: Building: runs-on: ubuntu-latest - needs: get_Building + needs: [get_Building, Ready] steps: - run: | if [[ ${{ needs.get_Building.outputs.state }} ]]; then @@ -58,7 +58,7 @@ jobs: Running: runs-on: ubuntu-latest - needs: get_Running + needs: [get_Running, Building] steps: - run: | if [[ ${{ needs.get_Running.outputs.state }} ]]; then From 56b07342064b4d4d3404180241002368858191f8 Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Thu, 19 Oct 2023 20:06:10 +0000 Subject: [PATCH 17/44] change order in needs --- .github/workflows/orion_status.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/orion_status.yaml b/.github/workflows/orion_status.yaml index b2a80a40b3..7cc7a1252f 100644 --- a/.github/workflows/orion_status.yaml +++ b/.github/workflows/orion_status.yaml @@ -40,7 +40,7 @@ jobs: Building: runs-on: ubuntu-latest - needs: [get_Building, Ready] + needs: [Ready, get_Building] steps: - run: | if [[ ${{ needs.get_Building.outputs.state }} ]]; then @@ -58,7 +58,7 @@ jobs: Running: runs-on: ubuntu-latest - needs: [get_Running, Building] + needs: [Building, get_Running] steps: - run: | if [[ ${{ needs.get_Running.outputs.state }} ]]; then From 7e14adb123904628109c64c7d288c9a49d8f15c2 Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Sat, 21 Oct 2023 01:27:34 +0000 Subject: [PATCH 18/44] took out poll --- .github/workflows/getlabels.yaml | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/.github/workflows/getlabels.yaml b/.github/workflows/getlabels.yaml index ffc40cc924..c9dcbc6153 100644 --- a/.github/workflows/getlabels.yaml +++ b/.github/workflows/getlabels.yaml @@ -38,22 +38,11 @@ jobs: STAGE: ${{ inputs.stage }} MAX_TIME: ${{ inputs.max_runtime }} run: | - DONE=false - count=0 - until false - do - LABELS1="$(gh api repos/$OWNER/$REPO_NAME/pulls/$PULL_REQUEST_NUMBER --jq '.labels.[].name')" - LABELS=$(echo "$LABELS1" | tr '\n' ' ') - check_label="CI-Orion-${STAGE}" - if [[ "${LABELS}" == *"${check_label}"* ]]; then - DONE=true - break - fi - sleep 10m - count=$((count+10)) - if [[ ${count} -gt ${MAX_TIME} ]]; then - DONE=false - break - fi - done + LABELS1="$(gh api repos/$OWNER/$REPO_NAME/pulls/$PULL_REQUEST_NUMBER --jq '.labels.[].name')" + LABELS=$(echo "$LABELS1" | tr '\n' ' ') + check_label="CI-Orion-${STAGE}" + if [[ "${LABELS}" == *"${check_label}"* ]]; then + DONE=true + break + fi echo "state=$DONE" >> $GITHUB_OUPUT From 0615fad5eb03f5e743ddd8b7d8ab1154c6e5fe8c Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Sat, 21 Oct 2023 01:31:03 +0000 Subject: [PATCH 19/44] took out secrets required line --- .github/workflows/getlabels.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/getlabels.yaml b/.github/workflows/getlabels.yaml index c9dcbc6153..156dcc3320 100644 --- a/.github/workflows/getlabels.yaml +++ b/.github/workflows/getlabels.yaml @@ -18,9 +18,6 @@ on: description: "The return state of Stage (true/false)" value: ${{ jobs.getlabels.outputs.state }} - secrets: - token: - required: true jobs: getlabels: From a9145c79014be6ac4674067de7aa9920d6c762c8 Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Sat, 21 Oct 2023 01:33:39 +0000 Subject: [PATCH 20/44] took out secrets required line --- .github/workflows/getlabels.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/getlabels.yaml b/.github/workflows/getlabels.yaml index 156dcc3320..3c5f441477 100644 --- a/.github/workflows/getlabels.yaml +++ b/.github/workflows/getlabels.yaml @@ -35,6 +35,7 @@ jobs: STAGE: ${{ inputs.stage }} MAX_TIME: ${{ inputs.max_runtime }} run: | + echo "gh api repos/$OWNER/$REPO_NAME/pulls/$PULL_REQUEST_NUMBER --jq '.labels.[].name'" LABELS1="$(gh api repos/$OWNER/$REPO_NAME/pulls/$PULL_REQUEST_NUMBER --jq '.labels.[].name')" LABELS=$(echo "$LABELS1" | tr '\n' ' ') check_label="CI-Orion-${STAGE}" From 9b8d608932c135256ad1f32ffea10baffd82f180 Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Sat, 21 Oct 2023 01:37:40 +0000 Subject: [PATCH 21/44] added {{}} on inputs.pr_number --- .github/workflows/orion_status.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/orion_status.yaml b/.github/workflows/orion_status.yaml index 7cc7a1252f..3bcd3cb5c3 100644 --- a/.github/workflows/orion_status.yaml +++ b/.github/workflows/orion_status.yaml @@ -15,7 +15,7 @@ jobs: get_Ready: uses: ./.github/workflows/getlabels.yaml with: - pr_number: inputs.pr_number + pr_number: ${{ inputs.pr_number }} max_runtime: 20 stage: "Ready" secrets: inherit From ac1b51cc79271c5e6baa0bef4586e64efd03e4f9 Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Sat, 21 Oct 2023 01:42:21 +0000 Subject: [PATCH 22/44] fixed other pr_number assiginments --- .github/workflows/getlabels.yaml | 27 +++++++++++++++++++-------- .github/workflows/orion_status.yaml | 4 ++-- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/.github/workflows/getlabels.yaml b/.github/workflows/getlabels.yaml index 3c5f441477..3d6bfaffad 100644 --- a/.github/workflows/getlabels.yaml +++ b/.github/workflows/getlabels.yaml @@ -35,12 +35,23 @@ jobs: STAGE: ${{ inputs.stage }} MAX_TIME: ${{ inputs.max_runtime }} run: | - echo "gh api repos/$OWNER/$REPO_NAME/pulls/$PULL_REQUEST_NUMBER --jq '.labels.[].name'" - LABELS1="$(gh api repos/$OWNER/$REPO_NAME/pulls/$PULL_REQUEST_NUMBER --jq '.labels.[].name')" - LABELS=$(echo "$LABELS1" | tr '\n' ' ') - check_label="CI-Orion-${STAGE}" - if [[ "${LABELS}" == *"${check_label}"* ]]; then - DONE=true - break - fi + DONE=false + count=0 + until false + do + echo "$(gh api repos/$OWNER/$REPO_NAME/pulls/$PULL_REQUEST_NUMBER --jq '.labels.[].name'" + LABELS1="$(gh api repos/$OWNER/$REPO_NAME/pulls/$PULL_REQUEST_NUMBER --jq '.labels.[].name')" + LABELS=$(echo "$LABELS1" | tr '\n' ' ') + check_label="CI-Orion-${STAGE}" + if [[ "${LABELS}" == *"${check_label}"* ]]; then + DONE=true + break + fi + sleep 10m + count=$((count+10)) + if [[ ${count} -gt ${MAX_TIME} ]]; then + DONE=false + break + fi + done echo "state=$DONE" >> $GITHUB_OUPUT diff --git a/.github/workflows/orion_status.yaml b/.github/workflows/orion_status.yaml index 3bcd3cb5c3..e331411734 100644 --- a/.github/workflows/orion_status.yaml +++ b/.github/workflows/orion_status.yaml @@ -33,7 +33,7 @@ jobs: get_Building: uses: ./.github/workflows/getlabels.yaml with: - pr_number: inputs.pr_number + pr_number: ${{ inputs.pr_number }} max_runtime: 40 stage: "Building" secrets: inherit @@ -51,7 +51,7 @@ jobs: get_Running: uses: ./.github/workflows/getlabels.yaml with: - pr_number: inputs.pr_number + pr_number: ${{ inputs.pr_number }} max_runtime: 60 stage: "Running" secrets: inherit From 404a4543078bfd6cdbf7d90a3f0afb90d6196e6d Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Sat, 21 Oct 2023 01:43:48 +0000 Subject: [PATCH 23/44] EOF error working --- .github/workflows/getlabels.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/getlabels.yaml b/.github/workflows/getlabels.yaml index 3d6bfaffad..993d5a7153 100644 --- a/.github/workflows/getlabels.yaml +++ b/.github/workflows/getlabels.yaml @@ -54,4 +54,4 @@ jobs: break fi done - echo "state=$DONE" >> $GITHUB_OUPUT + echo "state=$DONE" >> $GITHUB_OUPUT From 381832a197fde0e4ad63a120c9017e8d45f164fa Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Sat, 21 Oct 2023 01:45:43 +0000 Subject: [PATCH 24/44] EOF error working II --- .github/workflows/getlabels.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/getlabels.yaml b/.github/workflows/getlabels.yaml index 993d5a7153..2372bbb9a5 100644 --- a/.github/workflows/getlabels.yaml +++ b/.github/workflows/getlabels.yaml @@ -39,7 +39,7 @@ jobs: count=0 until false do - echo "$(gh api repos/$OWNER/$REPO_NAME/pulls/$PULL_REQUEST_NUMBER --jq '.labels.[].name'" + echo "gh api repos/$OWNER/$REPO_NAME/pulls/$PULL_REQUEST_NUMBER --jq '.labels.[].name'" LABELS1="$(gh api repos/$OWNER/$REPO_NAME/pulls/$PULL_REQUEST_NUMBER --jq '.labels.[].name')" LABELS=$(echo "$LABELS1" | tr '\n' ' ') check_label="CI-Orion-${STAGE}" From 3f6bd46d73ec96621ee178abe40f5a97cd068f49 Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Sat, 21 Oct 2023 01:52:33 +0000 Subject: [PATCH 25/44] ambiguous redrirect to GITHUB_OUTPUT --- .github/workflows/getlabels.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/getlabels.yaml b/.github/workflows/getlabels.yaml index 2372bbb9a5..020e937e45 100644 --- a/.github/workflows/getlabels.yaml +++ b/.github/workflows/getlabels.yaml @@ -54,4 +54,5 @@ jobs: break fi done - echo "state=$DONE" >> $GITHUB_OUPUT + echo "state=$DONE" + echo "state=$DONE" >> $env:GITHUB_OUPUT From ab5d110b795c758578ed9d4be63c915728c5ed77 Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Sat, 21 Oct 2023 02:13:02 +0000 Subject: [PATCH 26/44] tryig to get needs output from get_Ready --- .github/workflows/getlabels.yaml | 9 ++++----- .github/workflows/orion_status.yaml | 5 +++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/getlabels.yaml b/.github/workflows/getlabels.yaml index 020e937e45..15fc204c2a 100644 --- a/.github/workflows/getlabels.yaml +++ b/.github/workflows/getlabels.yaml @@ -2,6 +2,10 @@ name: Get Labels on: workflow_call: + outputs: + state: + description: "The return state of Stage (true/false)" + value: ${{ jobs.getlabels.outputs.state }} inputs: pr_number: required: true @@ -13,11 +17,6 @@ on: required: true type: string - outputs: - state: - description: "The return state of Stage (true/false)" - value: ${{ jobs.getlabels.outputs.state }} - jobs: getlabels: diff --git a/.github/workflows/orion_status.yaml b/.github/workflows/orion_status.yaml index e331411734..b3c76a34dc 100644 --- a/.github/workflows/orion_status.yaml +++ b/.github/workflows/orion_status.yaml @@ -30,8 +30,9 @@ jobs: exit 1 fi - get_Building: + get_Building: uses: ./.github/workflows/getlabels.yaml + needs: Ready with: pr_number: ${{ inputs.pr_number }} max_runtime: 40 @@ -40,7 +41,7 @@ jobs: Building: runs-on: ubuntu-latest - needs: [Ready, get_Building] + needs: get_Building steps: - run: | if [[ ${{ needs.get_Building.outputs.state }} ]]; then From 35c4877f2a953035a9fcd25f8f5328d1b3034db2 Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Sat, 21 Oct 2023 02:26:54 +0000 Subject: [PATCH 27/44] still not getting outputs --- .github/workflows/getlabels.yaml | 2 +- .github/workflows/orion_status.yaml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/getlabels.yaml b/.github/workflows/getlabels.yaml index 15fc204c2a..8789da3cdb 100644 --- a/.github/workflows/getlabels.yaml +++ b/.github/workflows/getlabels.yaml @@ -54,4 +54,4 @@ jobs: fi done echo "state=$DONE" - echo "state=$DONE" >> $env:GITHUB_OUPUT + echo "state=$DONE" >> "${GITHUB_OUPUT}" diff --git a/.github/workflows/orion_status.yaml b/.github/workflows/orion_status.yaml index b3c76a34dc..d607f1725e 100644 --- a/.github/workflows/orion_status.yaml +++ b/.github/workflows/orion_status.yaml @@ -51,6 +51,7 @@ jobs: get_Running: uses: ./.github/workflows/getlabels.yaml + needs: Building with: pr_number: ${{ inputs.pr_number }} max_runtime: 60 @@ -59,7 +60,7 @@ jobs: Running: runs-on: ubuntu-latest - needs: [Building, get_Running] + needs: get_Running steps: - run: | if [[ ${{ needs.get_Running.outputs.state }} ]]; then From 725e5258559a8b6a0f6d95ff592aa31315656170 Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Sat, 21 Oct 2023 02:34:03 +0000 Subject: [PATCH 28/44] quotes on GITHUB_OUTPUT --- .github/workflows/getlabels.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/getlabels.yaml b/.github/workflows/getlabels.yaml index 8789da3cdb..7f9e1c0902 100644 --- a/.github/workflows/getlabels.yaml +++ b/.github/workflows/getlabels.yaml @@ -54,4 +54,4 @@ jobs: fi done echo "state=$DONE" - echo "state=$DONE" >> "${GITHUB_OUPUT}" + echo "state=$DONE" >> ${GITHUB_OUPUT} From 461297d10f29a920b5c5e4b9394d0de8a40f38e9 Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Sat, 21 Oct 2023 02:49:06 +0000 Subject: [PATCH 29/44] trying crazy Sys IO --- .github/workflows/getlabels.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/getlabels.yaml b/.github/workflows/getlabels.yaml index 7f9e1c0902..c8193482e3 100644 --- a/.github/workflows/getlabels.yaml +++ b/.github/workflows/getlabels.yaml @@ -54,4 +54,7 @@ jobs: fi done echo "state=$DONE" - echo "state=$DONE" >> ${GITHUB_OUPUT} + var file = Environment.GetEnvironmentVariable("GITHUB_OUTPUT"); + var content = System.IO.File.ReadAllText(file); + System.IO.File.WriteAllText(file, content + "state=${DONE}" + "\n"); + # echo "state=$DONE" >> ${GITHUB_OUPUT} From 9bdf6f51c443bfd3a2249c54e4d0599baed27728 Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Sat, 21 Oct 2023 03:07:41 +0000 Subject: [PATCH 30/44] addeing yml file --- .github/workflows/getlabels.yml | 57 +++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/getlabels.yml diff --git a/.github/workflows/getlabels.yml b/.github/workflows/getlabels.yml new file mode 100644 index 0000000000..e8ebc733f1 --- /dev/null +++ b/.github/workflows/getlabels.yml @@ -0,0 +1,57 @@ +name: Get Labels + +on: + workflow_call: + outputs: + state: + description: "The return state of Stage (true/false)" + value: ${{ jobs.getlabels.outputs.state }} + inputs: + pr_number: + required: true + type: string + max_runtime: + required: false + type: string + stage: + required: true + type: string + +jobs: + + getlabels: + runs-on: ubuntu-latest + outputs: + state: ${{ steps.id.outputs.state }} + steps: + - name: Get Label Steps + id: id + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + OWNER: ${{ github.repository_owner }} + REPO_NAME: ${{ github.event.repository.name }} + PULL_REQUEST_NUMBER: ${{ inputs.pr_number }} + STAGE: ${{ inputs.stage }} + MAX_TIME: ${{ inputs.max_runtime }} + run: | + DONE=false + count=0 + until false + do + echo "gh api repos/$OWNER/$REPO_NAME/pulls/$PULL_REQUEST_NUMBER --jq '.labels.[].name'" + LABELS1="$(gh api repos/$OWNER/$REPO_NAME/pulls/$PULL_REQUEST_NUMBER --jq '.labels.[].name')" + LABELS=$(echo "$LABELS1" | tr '\n' ' ') + check_label="CI-Orion-${STAGE}" + if [[ "${LABELS}" == *"${check_label}"* ]]; then + DONE=true + break + fi + sleep 10m + count=$((count+10)) + if [[ ${count} -gt ${MAX_TIME} ]]; then + DONE=false + break + fi + done + echo "state=${DONE}" + echo "state=${DONE}" >> ${GITHUB_OUPUT} From 3e7a55982e36e55f30cf57deade49e036c9fae36 Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Sat, 21 Oct 2023 03:08:22 +0000 Subject: [PATCH 31/44] remove yml file --- .github/workflows/getlabels.yml | 57 --------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 .github/workflows/getlabels.yml diff --git a/.github/workflows/getlabels.yml b/.github/workflows/getlabels.yml deleted file mode 100644 index e8ebc733f1..0000000000 --- a/.github/workflows/getlabels.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: Get Labels - -on: - workflow_call: - outputs: - state: - description: "The return state of Stage (true/false)" - value: ${{ jobs.getlabels.outputs.state }} - inputs: - pr_number: - required: true - type: string - max_runtime: - required: false - type: string - stage: - required: true - type: string - -jobs: - - getlabels: - runs-on: ubuntu-latest - outputs: - state: ${{ steps.id.outputs.state }} - steps: - - name: Get Label Steps - id: id - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - OWNER: ${{ github.repository_owner }} - REPO_NAME: ${{ github.event.repository.name }} - PULL_REQUEST_NUMBER: ${{ inputs.pr_number }} - STAGE: ${{ inputs.stage }} - MAX_TIME: ${{ inputs.max_runtime }} - run: | - DONE=false - count=0 - until false - do - echo "gh api repos/$OWNER/$REPO_NAME/pulls/$PULL_REQUEST_NUMBER --jq '.labels.[].name'" - LABELS1="$(gh api repos/$OWNER/$REPO_NAME/pulls/$PULL_REQUEST_NUMBER --jq '.labels.[].name')" - LABELS=$(echo "$LABELS1" | tr '\n' ' ') - check_label="CI-Orion-${STAGE}" - if [[ "${LABELS}" == *"${check_label}"* ]]; then - DONE=true - break - fi - sleep 10m - count=$((count+10)) - if [[ ${count} -gt ${MAX_TIME} ]]; then - DONE=false - break - fi - done - echo "state=${DONE}" - echo "state=${DONE}" >> ${GITHUB_OUPUT} From b6566149215f90e4afb000d6390b60754185ed00 Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Sat, 21 Oct 2023 03:09:13 +0000 Subject: [PATCH 32/44] added () on DONE --- .github/workflows/getlabels.yaml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/getlabels.yaml b/.github/workflows/getlabels.yaml index c8193482e3..e8ebc733f1 100644 --- a/.github/workflows/getlabels.yaml +++ b/.github/workflows/getlabels.yaml @@ -53,8 +53,5 @@ jobs: break fi done - echo "state=$DONE" - var file = Environment.GetEnvironmentVariable("GITHUB_OUTPUT"); - var content = System.IO.File.ReadAllText(file); - System.IO.File.WriteAllText(file, content + "state=${DONE}" + "\n"); - # echo "state=$DONE" >> ${GITHUB_OUPUT} + echo "state=${DONE}" + echo "state=${DONE}" >> ${GITHUB_OUPUT} From ed3429e3f3c1cf4a0258b0d7f14c256ef71e1c3c Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Sat, 21 Oct 2023 03:16:05 +0000 Subject: [PATCH 33/44] adding env back to GITHUB_OUPUT --- .github/workflows/getlabels.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/getlabels.yaml b/.github/workflows/getlabels.yaml index e8ebc733f1..b861658a85 100644 --- a/.github/workflows/getlabels.yaml +++ b/.github/workflows/getlabels.yaml @@ -54,4 +54,4 @@ jobs: fi done echo "state=${DONE}" - echo "state=${DONE}" >> ${GITHUB_OUPUT} + echo "state=${DONE}" >> $env:GITHUB_OUTPUT From 00e92e286387b4bca03285420a93b47ec1844f31 Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Sat, 21 Oct 2023 03:24:48 +0000 Subject: [PATCH 34/44] added read write permissions to reuse --- .github/workflows/getlabels.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/getlabels.yaml b/.github/workflows/getlabels.yaml index b861658a85..156ee222a5 100644 --- a/.github/workflows/getlabels.yaml +++ b/.github/workflows/getlabels.yaml @@ -17,6 +17,10 @@ on: required: true type: string +permissions: + contents: read + packages: write + jobs: getlabels: @@ -54,4 +58,4 @@ jobs: fi done echo "state=${DONE}" - echo "state=${DONE}" >> $env:GITHUB_OUTPUT + echo "state=${DONE}" >> $GITHUB_OUTPUT From 7cda4501f36017947fe8564011c9cde106e38ee0 Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Sat, 21 Oct 2023 03:34:14 +0000 Subject: [PATCH 35/44] fixed logic in status workflow for on set --- .github/workflows/orion_status.yaml | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/orion_status.yaml b/.github/workflows/orion_status.yaml index d607f1725e..3be30a6239 100644 --- a/.github/workflows/orion_status.yaml +++ b/.github/workflows/orion_status.yaml @@ -13,7 +13,7 @@ on: jobs: get_Ready: - uses: ./.github/workflows/getlabels.yaml + uses: ./.github/workflows/getlabels.yml with: pr_number: ${{ inputs.pr_number }} max_runtime: 20 @@ -25,9 +25,11 @@ jobs: needs: get_Ready steps: - run: | - if [[ ${{ needs.get_Ready.outputs.state }} ]]; then - echo "Waiting for Ready State timmed out" + if [[ "${{ needs.get_Ready.outputs.state }}" == "false" ]]; then + echo "Ready Timmed out" exit 1 + elif [[ "${{ needs.get_Ready.outputs.state }}" == "true" ]]; then + echo "Ready Set" fi get_Building: @@ -44,10 +46,12 @@ jobs: needs: get_Building steps: - run: | - if [[ ${{ needs.get_Building.outputs.state }} ]]; then - echo "Waiting for Ready State timmed out" + if [[ "${{ needs.get_Building.outputs.state }}" == "false" ]]; then + echo "Building Timmed out" exit 1 - fi + elif [[ "${{ needs.get_Building.outputs.state }}" == "true" ]]; then + echo "Building Set" + fi get_Running: uses: ./.github/workflows/getlabels.yaml @@ -63,7 +67,9 @@ jobs: needs: get_Running steps: - run: | - if [[ ${{ needs.get_Running.outputs.state }} ]]; then - echo "Waiting for Ready State timmed out" + if [[ "${{ needs.get_Running.outputs.state }}" == "false" ]]; then + echo "Running Timmed out" exit 1 + elif [[ "${{ needs.get_Running.outputs.state }}" == "true" ]]; then + echo "Running Set" fi \ No newline at end of file From 522e4e30d4f224e4cc81cff42ef29ac699b784cf Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Sat, 21 Oct 2023 03:37:30 +0000 Subject: [PATCH 36/44] noop on getlables --- .github/workflows/getlabels.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/getlabels.yaml b/.github/workflows/getlabels.yaml index 156ee222a5..cff128217d 100644 --- a/.github/workflows/getlabels.yaml +++ b/.github/workflows/getlabels.yaml @@ -16,7 +16,6 @@ on: stage: required: true type: string - permissions: contents: read packages: write From 752210cfed4f4e0b50f7e5123c70b9b000745348 Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Sat, 21 Oct 2023 03:39:26 +0000 Subject: [PATCH 37/44] issue with orion status --- .github/workflows/orion_status.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/orion_status.yaml b/.github/workflows/orion_status.yaml index 3be30a6239..a9ce1def1b 100644 --- a/.github/workflows/orion_status.yaml +++ b/.github/workflows/orion_status.yaml @@ -25,10 +25,10 @@ jobs: needs: get_Ready steps: - run: | - if [[ "${{ needs.get_Ready.outputs.state }}" == "false" ]]; then + if [[ ${{ needs.get_Ready.outputs.state }} == "false" ]]; then echo "Ready Timmed out" exit 1 - elif [[ "${{ needs.get_Ready.outputs.state }}" == "true" ]]; then + elif [[ ${{ needs.get_Ready.outputs.state }} == "true" ]]; then echo "Ready Set" fi From 56b6a5f2d2bf8c84b53739fe64afb443b6ae76b7 Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Sat, 21 Oct 2023 03:42:10 +0000 Subject: [PATCH 38/44] misspelled yaml as yml --- .github/workflows/orion_status.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/orion_status.yaml b/.github/workflows/orion_status.yaml index a9ce1def1b..76d5571271 100644 --- a/.github/workflows/orion_status.yaml +++ b/.github/workflows/orion_status.yaml @@ -13,7 +13,7 @@ on: jobs: get_Ready: - uses: ./.github/workflows/getlabels.yml + uses: ./.github/workflows/getlabels.yaml with: pr_number: ${{ inputs.pr_number }} max_runtime: 20 @@ -25,10 +25,10 @@ jobs: needs: get_Ready steps: - run: | - if [[ ${{ needs.get_Ready.outputs.state }} == "false" ]]; then + if [[ "${{ needs.get_Ready.outputs.state }}" == "false" ]]; then echo "Ready Timmed out" exit 1 - elif [[ ${{ needs.get_Ready.outputs.state }} == "true" ]]; then + elif [[ "${{ needs.get_Ready.outputs.state }}" == "true" ]]; then echo "Ready Set" fi From f1767468407454c2cf6bc258eda4a00f49e48369 Mon Sep 17 00:00:00 2001 From: "terrance.mcguinness" Date: Fri, 15 Dec 2023 15:10:53 -0500 Subject: [PATCH 39/44] no op for self test --- ci/scripts/driver.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/scripts/driver.sh b/ci/scripts/driver.sh index a0edb4b4c3..e2d41c2dbe 100755 --- a/ci/scripts/driver.sh +++ b/ci/scripts/driver.sh @@ -12,6 +12,7 @@ set -eux # development branch for the global-workflow repo. It then stages tests directories per # PR number and calls clone-build_ci.sh to perform a clone and full build from the PR. # It then is ready to run a suite of regression tests with various configurations +# no-up for self-test ####################################################################################### ################################################################# From 3cff605a0ddb072156ff65245b194456189f0d54 Mon Sep 17 00:00:00 2001 From: "terrance.mcguinness" Date: Fri, 15 Dec 2023 15:13:34 -0500 Subject: [PATCH 40/44] no op for self test --- ci/scripts/driver.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/scripts/driver.sh b/ci/scripts/driver.sh index e2d41c2dbe..a0edb4b4c3 100755 --- a/ci/scripts/driver.sh +++ b/ci/scripts/driver.sh @@ -12,7 +12,6 @@ set -eux # development branch for the global-workflow repo. It then stages tests directories per # PR number and calls clone-build_ci.sh to perform a clone and full build from the PR. # It then is ready to run a suite of regression tests with various configurations -# no-up for self-test ####################################################################################### ################################################################# From cef725054194d3c7518a8a4a573c4a6e578b2610 Mon Sep 17 00:00:00 2001 From: tmcguinness Date: Mon, 11 Mar 2024 22:01:13 +0000 Subject: [PATCH 41/44] adde pygithug into pr_list_database --- ci/scripts/githubpr.py | 74 ++++++++++++++++++++++++++++++ ci/scripts/pr_list_database.py | 82 ++++++++++++++++++++++------------ ci/scripts/workflow | 1 + 3 files changed, 128 insertions(+), 29 deletions(-) create mode 100755 ci/scripts/githubpr.py create mode 120000 ci/scripts/workflow diff --git a/ci/scripts/githubpr.py b/ci/scripts/githubpr.py new file mode 100755 index 0000000000..d96df46ab5 --- /dev/null +++ b/ci/scripts/githubpr.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python3 + +import os, sys +import re + +from github import Github +from wxflow import which +from workflow.hosts import Host + +class GitHubPR: + """ + GitHubPR A class for interacting with GitHub pull requests. + + Attributes + ---------- + gh : Github + The Github instance for interacting with the GitHub API. + repo : Repository + The GitHub repository. + host : Host + The host machine. + """ + + def __init__(self): + """ + __init__ Initialize a new GitHubPR instance. + + This method authenticates with the GitHub API using the 'gh' CLI tool, + gets the repository from the 'REPO_URL' environment variable, and + initializes the host machine. + """ + gh_cli = which('gh') + gh_cli.add_default_arg(['auth', 'status','--show-token']) + gh_access_token=gh_cli(output=str, error=str).split('\n')[3].split(': ')[1] + gh = Github(gh_access_token) + self.gh = gh + + repo_url = os.environ.get("REPO_URL") + match = re.search(r"github\.com/(.+)", repo_url) + repo_identifier = match.group(1)[:-4] + repo = gh.get_repo(repo_identifier) + self.repo = repo + self.host = Host() + + def get_open_pr_list(self,state='Ready'): + """ + get_open_pr_list Get a list of open pull requests. + + Parameters + ---------- + state : str, optional + The state of the pull requests to get (default is 'Ready'). + + Returns + ------- + list + A list of pull request numbers that are open and match the specified state. + list + A list of pull request numbers that have the 'Kill' label. + """ + pulls = self.repo.get_pulls(state='closed', sort='updated', direction='desc') + pr_list = [] + pr_kill_list = [] + for pull in pulls: + labels = pull.get_labels() + ci_labels = [s for s in labels if 'CI' in s.name] + for label in ci_labels: + if 'Kill' in label.name: + pr_kill_list.append(pull.number) + continue + if self.host.machine.capitalize() in label.name: + if state in label.name: + pr_list.append(pull.number) + return pr_list, pr_kill_list \ No newline at end of file diff --git a/ci/scripts/pr_list_database.py b/ci/scripts/pr_list_database.py index f525d64987..fc04bbe986 100755 --- a/ci/scripts/pr_list_database.py +++ b/ci/scripts/pr_list_database.py @@ -3,37 +3,20 @@ import sys import os from wxflow import SQLiteDB, SQLiteDBError +from githubpr import GitHubPR from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter, REMAINDER def full_path(string): - """ - full_path Get the absolute path of a file or directory. - - Parameters - ---------- - string : str - The relative path of the file or directory. - - Returns - ------- - str - The absolute path of the file or directory. - - Raises - ------ - NotADirectoryError - If the provided string does not represent a valid file or directory. - """ if os.path.isfile(string) or os.path.isdir(os.path.dirname(string)): return os.path.abspath(string) else: raise NotADirectoryError(string) -def create_table(db: SQLiteDB): +def create(db: SQLiteDB): """ - Create a new table in a database. + Create a new database. Parameters ---------- @@ -43,7 +26,7 @@ def create_table(db: SQLiteDB): db.create_table('pr_list', ['pr INTEGER PRIMARY KEY UNIQUE', 'state TEXT', 'status TEXT', 'reset_id INTEGER', 'cases TEXT']) -def add_pr(db: SQLiteDB, pr: str): +def add_pr(db: SQLiteDB, pr: str) -> bool: """ Add a pull request to the database. @@ -57,9 +40,11 @@ def add_pr(db: SQLiteDB, pr: str): entities = (pr, 'Open', 'Ready', 0, 'ci_repo') try: db.insert_data('pr_list', entities) + return True except (SQLiteDBError.IntegrityError) as e: if 'unique' in str(e).lower(): print(f"pr {pr} already is in list: nothing added") + return False def update_pr(db: SQLiteDB, args): @@ -68,7 +53,7 @@ def update_pr(db: SQLiteDB, args): Parameters ---------- - db : SQLiteDB + ci_database : SQLiteDB The database to update the pull request in. args : argparse.Namespace The command line arguments. @@ -83,7 +68,7 @@ def update_pr(db: SQLiteDB, args): db.update_data('pr_list', update, value, 'pr', args.update_pr[0]) -def display_db(db, display): +def display(db, display) -> list: """ Display the database. @@ -91,8 +76,8 @@ def display_db(db, display): ---------- ci_database : SQLiteDB The database to display. - display : list - The command line argument values. + args : argparse.Namespace + The command line arguments. Returns ------- @@ -101,14 +86,42 @@ def display_db(db, display): """ values = [] if len(display) == 1: - rows = db.fetch_data('pr_list', ['pr', 'state', 'status', 'reset_id', 'cases'], f'pr = {display[0]}') - else: + rows = db.fetch_data('pr_list', ['pr', 'state', 'status', 'reset_id', 'cases'], f"pr = '{display[0]}'") + if len(display) == 2: + #rows = db.fetch_data('pr_list', ['pr', 'state', 'status', 'reset_id', 'cases'], f"state = '{display[0]}' AND status = '{display[1]}'") + rows = db.fetch_data('pr_list', ['pr'], f"state = '{display[0]}' AND status = '{display[1]}'") + if len(display) == 0: rows = db.fetch_data('pr_list', ['pr', 'state', 'status', 'reset_id', 'cases']) for row in rows: values.append(' '.join(map(str, row))) return values +def update_database(db: SQLiteDB) -> list: + """ + Update the database from the GitHub PRs + - only PRs from host machine are added to the database + - if the PR is already in the database it its added to the kill list + + Parameters + ---------- + ci_database : SQLiteDB + The database to update. + + Returns + ------- + list + The kill list of pull requests. + """ + gh = GitHubPR() + pr_ready_list, pr_kill_list = gh.get_open_pr_list() + for pr in pr_ready_list: + if not add_pr(db, str(pr)): + if pr not in pr_kill_list: + pr_kill_list.append(pr) + pr_kill_list = list(set(pr_kill_list)) + return pr_kill_list + def input_args(): """ @@ -132,6 +145,8 @@ def input_args(): parser.add_argument('--update_pr', nargs=REMAINDER, metavar=('pr', 'state', 'status', 'reset_id', 'cases'), help='updates state and status of a given pr', required=False) parser.add_argument('--display', nargs='*', help='output pr table', required=False) + parser.add_argument('--list_open_ready', action='store_true', required=False) + parser.add_argument('--update_database', help='use labels from Open GitHub PRs to update database state and produces a kill list', action='store_true', required=False) args = parser.parse_args() return args @@ -149,7 +164,7 @@ def input_args(): ci_database.connect() if args.create: - create_table(ci_database) + create(ci_database) if args.add_pr: add_pr(ci_database, args.add_pr[0]) if args.update_pr: @@ -157,7 +172,16 @@ def input_args(): if args.remove_pr: ci_database.remove_data('pr_list', 'PR', args.remove_pr[0]) if args.display is not None: - for rows in display_db(ci_database, args.display): + for rows in display(ci_database, args.display): print(rows) + if args.list_open_ready: + for rows in display(ci_database, ['Open', 'Ready']): + print(rows, end=' ') + print() + if args.update_database: + pr_kill_list = update_database(ci_database) + for pr in pr_kill_list: + print(pr, end=' ') + print() ci_database.disconnect() diff --git a/ci/scripts/workflow b/ci/scripts/workflow new file mode 120000 index 0000000000..b3927c5ade --- /dev/null +++ b/ci/scripts/workflow @@ -0,0 +1 @@ +../../workflow \ No newline at end of file From 44f3f46e8fe8e3fd48a918a3d5475370e379b095 Mon Sep 17 00:00:00 2001 From: Terry McGuinness Date: Tue, 12 Mar 2024 12:13:09 -0500 Subject: [PATCH 42/44] remove extra gitworkfow work stuck in my forked develop branch --- .github/workflows/getlabels.yaml | 60 ----------------------- .github/workflows/orion_status.yaml | 75 ----------------------------- 2 files changed, 135 deletions(-) delete mode 100644 .github/workflows/getlabels.yaml delete mode 100644 .github/workflows/orion_status.yaml diff --git a/.github/workflows/getlabels.yaml b/.github/workflows/getlabels.yaml deleted file mode 100644 index cff128217d..0000000000 --- a/.github/workflows/getlabels.yaml +++ /dev/null @@ -1,60 +0,0 @@ -name: Get Labels - -on: - workflow_call: - outputs: - state: - description: "The return state of Stage (true/false)" - value: ${{ jobs.getlabels.outputs.state }} - inputs: - pr_number: - required: true - type: string - max_runtime: - required: false - type: string - stage: - required: true - type: string -permissions: - contents: read - packages: write - -jobs: - - getlabels: - runs-on: ubuntu-latest - outputs: - state: ${{ steps.id.outputs.state }} - steps: - - name: Get Label Steps - id: id - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - OWNER: ${{ github.repository_owner }} - REPO_NAME: ${{ github.event.repository.name }} - PULL_REQUEST_NUMBER: ${{ inputs.pr_number }} - STAGE: ${{ inputs.stage }} - MAX_TIME: ${{ inputs.max_runtime }} - run: | - DONE=false - count=0 - until false - do - echo "gh api repos/$OWNER/$REPO_NAME/pulls/$PULL_REQUEST_NUMBER --jq '.labels.[].name'" - LABELS1="$(gh api repos/$OWNER/$REPO_NAME/pulls/$PULL_REQUEST_NUMBER --jq '.labels.[].name')" - LABELS=$(echo "$LABELS1" | tr '\n' ' ') - check_label="CI-Orion-${STAGE}" - if [[ "${LABELS}" == *"${check_label}"* ]]; then - DONE=true - break - fi - sleep 10m - count=$((count+10)) - if [[ ${count} -gt ${MAX_TIME} ]]; then - DONE=false - break - fi - done - echo "state=${DONE}" - echo "state=${DONE}" >> $GITHUB_OUTPUT diff --git a/.github/workflows/orion_status.yaml b/.github/workflows/orion_status.yaml deleted file mode 100644 index 76d5571271..0000000000 --- a/.github/workflows/orion_status.yaml +++ /dev/null @@ -1,75 +0,0 @@ -name: OrionStatus - -on: - workflow_dispatch: - inputs: - pr_number: - description: PR number - type: string - max_runtime: - description: Maximum time out time for running experment - type: string - -jobs: - - get_Ready: - uses: ./.github/workflows/getlabels.yaml - with: - pr_number: ${{ inputs.pr_number }} - max_runtime: 20 - stage: "Ready" - secrets: inherit - - Ready: - runs-on: ubuntu-latest - needs: get_Ready - steps: - - run: | - if [[ "${{ needs.get_Ready.outputs.state }}" == "false" ]]; then - echo "Ready Timmed out" - exit 1 - elif [[ "${{ needs.get_Ready.outputs.state }}" == "true" ]]; then - echo "Ready Set" - fi - - get_Building: - uses: ./.github/workflows/getlabels.yaml - needs: Ready - with: - pr_number: ${{ inputs.pr_number }} - max_runtime: 40 - stage: "Building" - secrets: inherit - - Building: - runs-on: ubuntu-latest - needs: get_Building - steps: - - run: | - if [[ "${{ needs.get_Building.outputs.state }}" == "false" ]]; then - echo "Building Timmed out" - exit 1 - elif [[ "${{ needs.get_Building.outputs.state }}" == "true" ]]; then - echo "Building Set" - fi - - get_Running: - uses: ./.github/workflows/getlabels.yaml - needs: Building - with: - pr_number: ${{ inputs.pr_number }} - max_runtime: 60 - stage: "Running" - secrets: inherit - - Running: - runs-on: ubuntu-latest - needs: get_Running - steps: - - run: | - if [[ "${{ needs.get_Running.outputs.state }}" == "false" ]]; then - echo "Running Timmed out" - exit 1 - elif [[ "${{ needs.get_Running.outputs.state }}" == "true" ]]; then - echo "Running Set" - fi \ No newline at end of file From 09819a35eeb601c1871a1cc6d9b092d83b4b44d5 Mon Sep 17 00:00:00 2001 From: tmcguinness Date: Thu, 21 Mar 2024 16:13:12 +0000 Subject: [PATCH 43/44] preppended HOME to eror log paths in the error.log file to pass to GitHub PR message --- ci/Jenkinsfile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile index 6f27804a3c..8f9ec1859c 100644 --- a/ci/Jenkinsfile +++ b/ci/Jenkinsfile @@ -155,18 +155,19 @@ pipeline { sh(script: "${HOMEgfs}/ci/scripts/utils/ci_utils_wrapper.sh cancel_all_batch_jobs ${HOME}/RUNTESTS") ws(HOME) { if (fileExists('RUNTESTS/error.logs')) { - def error_logs = sh(script: "cat RUNTESTS/error.logs", returnStdout: true).trim() - try { - pullRequest.comment("Experiment ${Case} failed on ${Machine}\n\nError logs:\n\n${error_logs}") - } catch (Exception error) { - echo "Failed to comment on PR: ${error.getMessage()}" - } def fileContent = readFile 'RUNTESTS/error.logs' def lines = fileContent.readLines() for (line in lines) { echo "archiving: ${line}" archiveArtifacts artifacts: "${line}", fingerprint: true } + sh(script: 'sed -i "s#RUNTESTS#${HOME}/RUNTESTS#g" RUNTESTS/error.logs') + def error_logs = sh(script: "cat RUNTESTS/error.logs", returnStdout: true).trim() + try { + pullRequest.comment("Experiment ${Case} failed on ${Machine}\n\nError logs:\n\n${error_logs}") + } catch (Exception error) { + echo "Failed to comment on PR: ${error.getMessage()}" + } } } error("Failed to run experiments ${Case} on ${Machine}") From 170d0d832bac6d52294ea268a4a44095b03f2fe0 Mon Sep 17 00:00:00 2001 From: tmcguinness Date: Thu, 21 Mar 2024 16:18:07 +0000 Subject: [PATCH 44/44] re-aline files to develop --- ci/scripts/githubpr.py | 74 ------------------------------ ci/scripts/pr_list_database.py | 82 ++++++++++++---------------------- ci/scripts/workflow | 1 - 3 files changed, 29 insertions(+), 128 deletions(-) delete mode 100755 ci/scripts/githubpr.py delete mode 120000 ci/scripts/workflow diff --git a/ci/scripts/githubpr.py b/ci/scripts/githubpr.py deleted file mode 100755 index d96df46ab5..0000000000 --- a/ci/scripts/githubpr.py +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env python3 - -import os, sys -import re - -from github import Github -from wxflow import which -from workflow.hosts import Host - -class GitHubPR: - """ - GitHubPR A class for interacting with GitHub pull requests. - - Attributes - ---------- - gh : Github - The Github instance for interacting with the GitHub API. - repo : Repository - The GitHub repository. - host : Host - The host machine. - """ - - def __init__(self): - """ - __init__ Initialize a new GitHubPR instance. - - This method authenticates with the GitHub API using the 'gh' CLI tool, - gets the repository from the 'REPO_URL' environment variable, and - initializes the host machine. - """ - gh_cli = which('gh') - gh_cli.add_default_arg(['auth', 'status','--show-token']) - gh_access_token=gh_cli(output=str, error=str).split('\n')[3].split(': ')[1] - gh = Github(gh_access_token) - self.gh = gh - - repo_url = os.environ.get("REPO_URL") - match = re.search(r"github\.com/(.+)", repo_url) - repo_identifier = match.group(1)[:-4] - repo = gh.get_repo(repo_identifier) - self.repo = repo - self.host = Host() - - def get_open_pr_list(self,state='Ready'): - """ - get_open_pr_list Get a list of open pull requests. - - Parameters - ---------- - state : str, optional - The state of the pull requests to get (default is 'Ready'). - - Returns - ------- - list - A list of pull request numbers that are open and match the specified state. - list - A list of pull request numbers that have the 'Kill' label. - """ - pulls = self.repo.get_pulls(state='closed', sort='updated', direction='desc') - pr_list = [] - pr_kill_list = [] - for pull in pulls: - labels = pull.get_labels() - ci_labels = [s for s in labels if 'CI' in s.name] - for label in ci_labels: - if 'Kill' in label.name: - pr_kill_list.append(pull.number) - continue - if self.host.machine.capitalize() in label.name: - if state in label.name: - pr_list.append(pull.number) - return pr_list, pr_kill_list \ No newline at end of file diff --git a/ci/scripts/pr_list_database.py b/ci/scripts/pr_list_database.py index fc04bbe986..f525d64987 100755 --- a/ci/scripts/pr_list_database.py +++ b/ci/scripts/pr_list_database.py @@ -3,20 +3,37 @@ import sys import os from wxflow import SQLiteDB, SQLiteDBError -from githubpr import GitHubPR from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter, REMAINDER def full_path(string): + """ + full_path Get the absolute path of a file or directory. + + Parameters + ---------- + string : str + The relative path of the file or directory. + + Returns + ------- + str + The absolute path of the file or directory. + + Raises + ------ + NotADirectoryError + If the provided string does not represent a valid file or directory. + """ if os.path.isfile(string) or os.path.isdir(os.path.dirname(string)): return os.path.abspath(string) else: raise NotADirectoryError(string) -def create(db: SQLiteDB): +def create_table(db: SQLiteDB): """ - Create a new database. + Create a new table in a database. Parameters ---------- @@ -26,7 +43,7 @@ def create(db: SQLiteDB): db.create_table('pr_list', ['pr INTEGER PRIMARY KEY UNIQUE', 'state TEXT', 'status TEXT', 'reset_id INTEGER', 'cases TEXT']) -def add_pr(db: SQLiteDB, pr: str) -> bool: +def add_pr(db: SQLiteDB, pr: str): """ Add a pull request to the database. @@ -40,11 +57,9 @@ def add_pr(db: SQLiteDB, pr: str) -> bool: entities = (pr, 'Open', 'Ready', 0, 'ci_repo') try: db.insert_data('pr_list', entities) - return True except (SQLiteDBError.IntegrityError) as e: if 'unique' in str(e).lower(): print(f"pr {pr} already is in list: nothing added") - return False def update_pr(db: SQLiteDB, args): @@ -53,7 +68,7 @@ def update_pr(db: SQLiteDB, args): Parameters ---------- - ci_database : SQLiteDB + db : SQLiteDB The database to update the pull request in. args : argparse.Namespace The command line arguments. @@ -68,7 +83,7 @@ def update_pr(db: SQLiteDB, args): db.update_data('pr_list', update, value, 'pr', args.update_pr[0]) -def display(db, display) -> list: +def display_db(db, display): """ Display the database. @@ -76,8 +91,8 @@ def display(db, display) -> list: ---------- ci_database : SQLiteDB The database to display. - args : argparse.Namespace - The command line arguments. + display : list + The command line argument values. Returns ------- @@ -86,42 +101,14 @@ def display(db, display) -> list: """ values = [] if len(display) == 1: - rows = db.fetch_data('pr_list', ['pr', 'state', 'status', 'reset_id', 'cases'], f"pr = '{display[0]}'") - if len(display) == 2: - #rows = db.fetch_data('pr_list', ['pr', 'state', 'status', 'reset_id', 'cases'], f"state = '{display[0]}' AND status = '{display[1]}'") - rows = db.fetch_data('pr_list', ['pr'], f"state = '{display[0]}' AND status = '{display[1]}'") - if len(display) == 0: + rows = db.fetch_data('pr_list', ['pr', 'state', 'status', 'reset_id', 'cases'], f'pr = {display[0]}') + else: rows = db.fetch_data('pr_list', ['pr', 'state', 'status', 'reset_id', 'cases']) for row in rows: values.append(' '.join(map(str, row))) return values -def update_database(db: SQLiteDB) -> list: - """ - Update the database from the GitHub PRs - - only PRs from host machine are added to the database - - if the PR is already in the database it its added to the kill list - - Parameters - ---------- - ci_database : SQLiteDB - The database to update. - - Returns - ------- - list - The kill list of pull requests. - """ - gh = GitHubPR() - pr_ready_list, pr_kill_list = gh.get_open_pr_list() - for pr in pr_ready_list: - if not add_pr(db, str(pr)): - if pr not in pr_kill_list: - pr_kill_list.append(pr) - pr_kill_list = list(set(pr_kill_list)) - return pr_kill_list - def input_args(): """ @@ -145,8 +132,6 @@ def input_args(): parser.add_argument('--update_pr', nargs=REMAINDER, metavar=('pr', 'state', 'status', 'reset_id', 'cases'), help='updates state and status of a given pr', required=False) parser.add_argument('--display', nargs='*', help='output pr table', required=False) - parser.add_argument('--list_open_ready', action='store_true', required=False) - parser.add_argument('--update_database', help='use labels from Open GitHub PRs to update database state and produces a kill list', action='store_true', required=False) args = parser.parse_args() return args @@ -164,7 +149,7 @@ def input_args(): ci_database.connect() if args.create: - create(ci_database) + create_table(ci_database) if args.add_pr: add_pr(ci_database, args.add_pr[0]) if args.update_pr: @@ -172,16 +157,7 @@ def input_args(): if args.remove_pr: ci_database.remove_data('pr_list', 'PR', args.remove_pr[0]) if args.display is not None: - for rows in display(ci_database, args.display): + for rows in display_db(ci_database, args.display): print(rows) - if args.list_open_ready: - for rows in display(ci_database, ['Open', 'Ready']): - print(rows, end=' ') - print() - if args.update_database: - pr_kill_list = update_database(ci_database) - for pr in pr_kill_list: - print(pr, end=' ') - print() ci_database.disconnect() diff --git a/ci/scripts/workflow b/ci/scripts/workflow deleted file mode 120000 index b3927c5ade..0000000000 --- a/ci/scripts/workflow +++ /dev/null @@ -1 +0,0 @@ -../../workflow \ No newline at end of file