From 369e7483f91136f4ce5cbd25417f9a42fd81834d Mon Sep 17 00:00:00 2001 From: Mike McDonald <61101829+mikemcd3912@users.noreply.github.com> Date: Fri, 17 Nov 2023 15:28:16 -0800 Subject: [PATCH 1/6] Convert testJob.yaml to daily Cronjob --- .../Testers/Sample/testJob.yaml | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/eks-anywhere-common/Testers/Sample/testJob.yaml b/eks-anywhere-common/Testers/Sample/testJob.yaml index 4c013973..11c171c2 100644 --- a/eks-anywhere-common/Testers/Sample/testJob.yaml +++ b/eks-anywhere-common/Testers/Sample/testJob.yaml @@ -1,17 +1,21 @@ apiVersion: batch/v1 -kind: Job +kind: CronJob metadata: - name: sample-common-testjob + name: sample-common-daily-test-cronjob namespace: default spec: - backoffLimit: 1 - template: + schedule: "10 10 * * *" + jobTemplate: spec: - containers: - - name: job - image: busybox - args: - - /bin/sh - - -c - - date; echo sleeping....; sleep 5s; exit 1; - restartPolicy: Never + template: + spec: + containers: + - name: job + image: busybox + args: + - /bin/sh + - -c + - date; echo sleeping....; sleep 5s; exit 0; + restartPolicy: Never + successfulJobsHistoryLimit: 3 + failedJobsHistoryLimit: 1 From e6000b1b919b6edc0f1ab24f1490aee345e37bd6 Mon Sep 17 00:00:00 2001 From: mikemcd3912 Date: Mon, 20 Nov 2023 16:01:01 +0000 Subject: [PATCH 2/6] Converting testjob.yaml files from each environment to Cronjob --- .../Testers/Sample/testJob.yaml | 28 +++++++++++-------- .../Testers/Sample/testJob.yaml | 28 +++++++++++-------- eks-anywhere-snow/Testers/Sample/testJob.yaml | 28 +++++++++++-------- .../Testers/Sample/testJob.yaml | 28 +++++++++++-------- .../Testers/Sample/testJob.yaml | 28 +++++++++++-------- 5 files changed, 80 insertions(+), 60 deletions(-) diff --git a/eks-anywhere-baremetal/Testers/Sample/testJob.yaml b/eks-anywhere-baremetal/Testers/Sample/testJob.yaml index 3f3a2a40..b39dacf9 100644 --- a/eks-anywhere-baremetal/Testers/Sample/testJob.yaml +++ b/eks-anywhere-baremetal/Testers/Sample/testJob.yaml @@ -1,17 +1,21 @@ apiVersion: batch/v1 -kind: Job +kind: CronJob metadata: - name: sample-baremetal-testjob + name: sample-baremetal-daily-test-cronjob namespace: default spec: - backoffLimit: 1 - template: + schedule: "10 10 * * *" + jobTemplate: spec: - containers: - - name: job - image: busybox - args: - - /bin/sh - - -c - - date; echo sleeping....; sleep 5s; exit 1; - restartPolicy: Never + template: + spec: + containers: + - name: job + image: busybox + args: + - /bin/sh + - -c + - date; echo sleeping....; sleep 5s; exit 0; + restartPolicy: Never + successfulJobsHistoryLimit: 3 + failedJobsHistoryLimit: 1 \ No newline at end of file diff --git a/eks-anywhere-nutanix/Testers/Sample/testJob.yaml b/eks-anywhere-nutanix/Testers/Sample/testJob.yaml index d75d3e9f..559c24c9 100644 --- a/eks-anywhere-nutanix/Testers/Sample/testJob.yaml +++ b/eks-anywhere-nutanix/Testers/Sample/testJob.yaml @@ -1,17 +1,21 @@ apiVersion: batch/v1 -kind: Job +kind: CronJob metadata: - name: sample-nutanix-testjob + name: sample-nutanix-daily-test-cronjob namespace: default spec: - backoffLimit: 1 - template: + schedule: "10 10 * * *" + jobTemplate: spec: - containers: - - name: job - image: busybox - args: - - /bin/sh - - -c - - date; echo sleeping....; sleep 5s; exit 1; - restartPolicy: Never + template: + spec: + containers: + - name: job + image: busybox + args: + - /bin/sh + - -c + - date; echo sleeping....; sleep 5s; exit 0; + restartPolicy: Never + successfulJobsHistoryLimit: 3 + failedJobsHistoryLimit: 1 \ No newline at end of file diff --git a/eks-anywhere-snow/Testers/Sample/testJob.yaml b/eks-anywhere-snow/Testers/Sample/testJob.yaml index 2d927190..e42866ef 100644 --- a/eks-anywhere-snow/Testers/Sample/testJob.yaml +++ b/eks-anywhere-snow/Testers/Sample/testJob.yaml @@ -1,17 +1,21 @@ apiVersion: batch/v1 -kind: Job +kind: CronJob metadata: - name: sample-snow-testjob + name: sample-snow-daily-test-cronjob namespace: default spec: - backoffLimit: 1 - template: + schedule: "10 10 * * *" + jobTemplate: spec: - containers: - - name: job - image: busybox - args: - - /bin/sh - - -c - - date; echo sleeping....; sleep 5s; exit 1; - restartPolicy: Never + template: + spec: + containers: + - name: job + image: busybox + args: + - /bin/sh + - -c + - date; echo sleeping....; sleep 5s; exit 0; + restartPolicy: Never + successfulJobsHistoryLimit: 3 + failedJobsHistoryLimit: 1 \ No newline at end of file diff --git a/eks-anywhere-vsphere/Testers/Sample/testJob.yaml b/eks-anywhere-vsphere/Testers/Sample/testJob.yaml index b29c4f02..3501c87e 100644 --- a/eks-anywhere-vsphere/Testers/Sample/testJob.yaml +++ b/eks-anywhere-vsphere/Testers/Sample/testJob.yaml @@ -1,17 +1,21 @@ apiVersion: batch/v1 -kind: Job +kind: CronJob metadata: - name: sample-vsphere-testjob + name: sample-vsphere-daily-test-cronjob namespace: default spec: - backoffLimit: 1 - template: + schedule: "10 10 * * *" + jobTemplate: spec: - containers: - - name: job - image: busybox - args: - - /bin/sh - - -c - - date; echo sleeping....; sleep 5s; exit 1; - restartPolicy: Never + template: + spec: + containers: + - name: job + image: busybox + args: + - /bin/sh + - -c + - date; echo sleeping....; sleep 5s; exit 0; + restartPolicy: Never + successfulJobsHistoryLimit: 3 + failedJobsHistoryLimit: 1 \ No newline at end of file diff --git a/eks-local-clusters-outposts/Testers/Sample/testJob.yaml b/eks-local-clusters-outposts/Testers/Sample/testJob.yaml index c8952a71..a80465d2 100644 --- a/eks-local-clusters-outposts/Testers/Sample/testJob.yaml +++ b/eks-local-clusters-outposts/Testers/Sample/testJob.yaml @@ -1,17 +1,21 @@ apiVersion: batch/v1 -kind: Job +kind: CronJob metadata: - name: sample-rover-testjob + name: sample-outposts-daily-test-cronjob namespace: default spec: - backoffLimit: 1 - template: + schedule: "10 10 * * *" + jobTemplate: spec: - containers: - - name: job - image: busybox - args: - - /bin/sh - - -c - - date; echo sleeping....; sleep 5s; exit 1; - restartPolicy: Never + template: + spec: + containers: + - name: job + image: busybox + args: + - /bin/sh + - -c + - date; echo sleeping....; sleep 5s; exit 0; + restartPolicy: Never + successfulJobsHistoryLimit: 3 + failedJobsHistoryLimit: 1 \ No newline at end of file From 32b0c253c8d825ec013d2bb406add6ec3e80815d Mon Sep 17 00:00:00 2001 From: mikemcd3912 Date: Mon, 20 Nov 2023 16:05:44 +0000 Subject: [PATCH 3/6] Local/Outposts job name udpate --- eks-local-clusters-outposts/Testers/Sample/testJob.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eks-local-clusters-outposts/Testers/Sample/testJob.yaml b/eks-local-clusters-outposts/Testers/Sample/testJob.yaml index a80465d2..9e2d3bc6 100644 --- a/eks-local-clusters-outposts/Testers/Sample/testJob.yaml +++ b/eks-local-clusters-outposts/Testers/Sample/testJob.yaml @@ -1,7 +1,7 @@ apiVersion: batch/v1 kind: CronJob metadata: - name: sample-outposts-daily-test-cronjob + name: sample-local-daily-test-cronjob namespace: default spec: schedule: "10 10 * * *" From daf52e3fcfaebe9d80fa57d4531339d4eec8cfbd Mon Sep 17 00:00:00 2001 From: mikemcd3912 Date: Tue, 21 Nov 2023 17:54:00 +0000 Subject: [PATCH 4/6] Updating GH Action to exclude Validated Partner and GH action update PR's --- .github/workflows/close-pull-request.yaml | 3 +++ .github/workflows/new-pull-request.yaml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/close-pull-request.yaml b/.github/workflows/close-pull-request.yaml index 65a68835..1619be40 100644 --- a/.github/workflows/close-pull-request.yaml +++ b/.github/workflows/close-pull-request.yaml @@ -3,6 +3,9 @@ on: pull_request_target: branches: [main] types: [closed] + paths-ignore: + - 'ValidatedPartners/**' + - '.github/**' jobs: merge-master-back-to-dev: if: github.event.pull_request.merged == false diff --git a/.github/workflows/new-pull-request.yaml b/.github/workflows/new-pull-request.yaml index d88c8765..207e6fbb 100644 --- a/.github/workflows/new-pull-request.yaml +++ b/.github/workflows/new-pull-request.yaml @@ -4,6 +4,9 @@ on: pull_request_target: branches: [main] types: [opened, reopened, synchronize] + paths-ignore: + - 'ValidatedPartners/**' + - '.github/**' jobs: build: From 4c75526c617a3be9c3ec8b5e047beed21db60586 Mon Sep 17 00:00:00 2001 From: mikemcd3912 Date: Tue, 21 Nov 2023 18:00:39 +0000 Subject: [PATCH 5/6] Updating Validated Partner Path to ignore --- .github/workflows/close-pull-request.yaml | 2 +- .github/workflows/new-pull-request.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/close-pull-request.yaml b/.github/workflows/close-pull-request.yaml index 1619be40..7bb19568 100644 --- a/.github/workflows/close-pull-request.yaml +++ b/.github/workflows/close-pull-request.yaml @@ -4,7 +4,7 @@ on: branches: [main] types: [closed] paths-ignore: - - 'ValidatedPartners/**' + - 'Validated_Partners/**' - '.github/**' jobs: merge-master-back-to-dev: diff --git a/.github/workflows/new-pull-request.yaml b/.github/workflows/new-pull-request.yaml index 207e6fbb..a1997303 100644 --- a/.github/workflows/new-pull-request.yaml +++ b/.github/workflows/new-pull-request.yaml @@ -5,7 +5,7 @@ on: branches: [main] types: [opened, reopened, synchronize] paths-ignore: - - 'ValidatedPartners/**' + - 'Validated_Partners/**' - '.github/**' jobs: From 30933ea51ce6b673c7006afa9f2496f7f1d54ada Mon Sep 17 00:00:00 2001 From: mikemcd3912 Date: Wed, 29 Nov 2023 22:01:37 +0000 Subject: [PATCH 6/6] Updating GH Action to evaluate each file subdirectory for individual processing --- .github/workflows/new-pull-request.yaml | 139 +++++++++++------------- 1 file changed, 63 insertions(+), 76 deletions(-) diff --git a/.github/workflows/new-pull-request.yaml b/.github/workflows/new-pull-request.yaml index a1997303..db69cad7 100644 --- a/.github/workflows/new-pull-request.yaml +++ b/.github/workflows/new-pull-request.yaml @@ -24,86 +24,73 @@ jobs: run: | # Pull files down into a filename array files=$(curl -s "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" | jq -r '.[].filename') - echo $files - filearr=($files) - # Find Namespace File in uploads list or in modified file subdirectory - namespace_file=$(echo "$files" | grep "namespace.yaml") - subdirectory=$(dirname ${filearr[0]}) - if [ -z $namespace_file ]; then - git fetch --all - git config --local user.email "dev@null" - git config --local user.name "Conformitron Bot" - git checkout developer_branch - git pull - if [ -f "${subdirectory}/namespace.yaml" ]; then - namespace_file="${subdirectory}/namespace.yaml" - echo "namespace file = $namespace_file" - else - echo "No Namespace file found in existing subdirectory" - exit 200 - fi - elif [[ -n $namespace_file ]]; then - echo "Namespace File: $namespace_file" - else - echo "No Namespace file found in commit or subdirectory" - fi - - # Parse namespace data - namespace_file="${namespace_file}" - if [ -n "$namespace_file" ]; then - subdirectory=$(dirname $namespace_file) - echo "Sub Directory = $subdirectory" - - # get namespace from pr - git checkout pr - namespace_name=$(grep -E '^\s*metadata:\s*$|^\s*name:\s*' "$namespace_file" | awk -F':' '{gsub(/ /, "", $2); print $2}') - - git fetch --all - git config --local user.email "dev@null" - git config --local user.name "Conformitron Bot" - # fetch most recent update to dev - git checkout developer_branch - git pull - - if [[ ! -z $namespace_name ]]; then - echo "$namespace_name" - namespace=$(echo $namespace_name | xargs echo -n) - echo $namespace - config_map_file="config-map-${{ github.event.pull_request.number }}.yml" - echo $config_map_file - echo "apiVersion: v1" >> $config_map_file - echo "kind: ConfigMap" >> $config_map_file - echo "metadata:" >> $config_map_file - echo " name: $namespace-configmap" >> $config_map_file - echo " namespace: $namespace" >> $config_map_file - echo " labels:" >> $config_map_file - echo " bot: conformitron" >> $config_map_file - echo "data:" >> $config_map_file - echo " Namespace: ${namespace}" >> $config_map_file - echo " prNumber: \"${{ github.event.pull_request.number }}\"" >> $config_map_file - echo " commitHash: ${{ github.event.pull_request.head.sha }}" >> $config_map_file - echo $subdirectory - echo $config_map_file + # Move updated files over to dev branch + git fetch --all + git config --local user.email "dev@null" + git config --local user.name "Conformitron Bot" + # fetch most recent update to dev + git checkout developer_branch + git pull - mkdir -p ./$subdirectory/ - mv "$config_map_file" ./$subdirectory/ - git add . - - else - echo "No Namespace found" - exit 100 - fi - else - echo "No namespace.yaml file found" - exit 200 - fi - - # Move updated files over for item in $files; do git checkout pr -- $item git add $item - echo $item + echo "Moving $item" done - git commit -m "Adding new and changed files for ${namespace}_PR_${{ github.event.pull_request.number }}" + + # Find Namespace File(s) in uploads list and generate/update configmap for each + for filename in $files + do + echo "Filename = $filename" + + # Parse namespace data + if [ $(echo "$filename" | grep -c "namespace.yaml") ]; then + subdirectory=$(dirname $filename) + echo "Sub Directory = $subdirectory" + + # get namespace from dev branch directory where the updated file is being placed + if [ -f "${subdirectory}/namespace.yaml" ]; then + namespace_file="${subdirectory}/namespace.yaml" + echo "namespace file = $namespace_file" + namespace_name=$(grep -E '^\s*metadata:\s*$|^\s*name:\s*' "$namespace_file" | awk -F':' '{gsub(/ /, "", $2); print $2}') + else + echo "No Namespace file found in existing subdirectory" + exit 200 + fi + + if [[ -n $namespace_name ]]; then + echo "$namespace_name" + namespace=$(echo $namespace_name | xargs echo -n) + echo $namespace + config_map_file="config-map-${{ github.event.pull_request.number }}.yml" + echo $config_map_file + echo "apiVersion: v1" >> $config_map_file + echo "kind: ConfigMap" >> $config_map_file + echo "metadata:" >> $config_map_file + echo " name: $namespace-configmap" >> $config_map_file + echo " namespace: $namespace" >> $config_map_file + echo " labels:" >> $config_map_file + echo " bot: conformitron" >> $config_map_file + echo "data:" >> $config_map_file + echo " Namespace: ${namespace}" >> $config_map_file + echo " prNumber: \"${{ github.event.pull_request.number }}\"" >> $config_map_file + echo " commitHash: ${{ github.event.pull_request.head.sha }}" >> $config_map_file + echo $subdirectory + echo $config_map_file + + mkdir -p ./$subdirectory/ + mv "$config_map_file" ./$subdirectory/ + git add . + + else + echo "No Namespace found, Invalid namespace file" + exit 100 + fi + else + echo "Not a namespace.yaml file" + fi + done + + git commit -m "Adding new and changed files for PR_${{ github.event.pull_request.number }}" git push