From 9c1cf4f6f102ffc649d9b93410c2d7cdbdf62bb6 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 26 Jul 2024 11:40:47 -0400 Subject: [PATCH 01/26] test --- score/score.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/score/score.yaml b/score/score.yaml index bbb98b3..83b0326 100644 --- a/score/score.yaml +++ b/score/score.yaml @@ -12,7 +12,7 @@ containers: memory: "64Mi" cpu: "25m" variables: - MESSAGE: "Hello, World!" + MESSAGE: "Hello, Test!" resources: dns: type: dns From 3e83cc56c260f843b595ef1c969d9464cc7d6fbe Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 26 Jul 2024 11:54:37 -0400 Subject: [PATCH 02/26] test missing var --- score/score.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/score/score.yaml b/score/score.yaml index 83b0326..519bd07 100644 --- a/score/score.yaml +++ b/score/score.yaml @@ -13,6 +13,7 @@ containers: cpu: "25m" variables: MESSAGE: "Hello, Test!" + MISSING_VAR: ${resources.env.nonexistent-var} resources: dns: type: dns From f97968382027a8f0243eb104c56d06385b4e4c55 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 26 Jul 2024 12:15:11 -0400 Subject: [PATCH 03/26] Fix missing environment resource --- score/score.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/score/score.yaml b/score/score.yaml index 519bd07..578c30a 100644 --- a/score/score.yaml +++ b/score/score.yaml @@ -15,6 +15,8 @@ containers: MESSAGE: "Hello, Test!" MISSING_VAR: ${resources.env.nonexistent-var} resources: + env: + type: environment dns: type: dns route: From 446ac6c06a7472f47f35280ffd63925469f8a49a Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 26 Jul 2024 12:31:21 -0400 Subject: [PATCH 04/26] add failure with non existing container image --- score/score.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/score/score.yaml b/score/score.yaml index 578c30a..f2184bc 100644 --- a/score/score.yaml +++ b/score/score.yaml @@ -3,7 +3,7 @@ metadata: name: my-sample-workload containers: my-sample-container: - image: . + image: ghcr.io/mathieu-benoit/my-sample-workload:pouet resources: limits: memory: "256Mi" @@ -13,10 +13,7 @@ containers: cpu: "25m" variables: MESSAGE: "Hello, Test!" - MISSING_VAR: ${resources.env.nonexistent-var} resources: - env: - type: environment dns: type: dns route: From 54263d92c3b0f1158315e7d61b59676f1fb57fe8 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 26 Jul 2024 13:01:44 -0400 Subject: [PATCH 05/26] Fix container image name across pipelines --- .github/workflows/close-pr.yml | 6 ++---- .github/workflows/push-tag.yml | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/close-pr.yml b/.github/workflows/close-pr.yml index aa8bc99..496b585 100644 --- a/.github/workflows/close-pr.yml +++ b/.github/workflows/close-pr.yml @@ -8,6 +8,7 @@ on: - closed env: ENVIRONMENT_ID: pr-${{ github.event.number }} + IMAGE_NAME: ${{ secrets.REGISTRY_LOCATION }}-docker.pkg.dev/${{ secrets.PROJECT_ID }}/${{ secrets.REGISTRY_NAME }}/my-sample-workload HUMCTL_VERSION: '*' jobs: ob-pr-closed: @@ -31,9 +32,6 @@ jobs: - uses: google-github-actions/setup-gcloud@v2 with: version: latest - - name: prepare environment variables - run: | - echo "IMAGE_NAME=${{ secrets.REGISTRY_LOCATION }}-docker.pkg.dev/${{ secrets.PROJECT_ID }}/${{ secrets.REGISTRY_NAME }}/${{ vars.APP_NAME }}" >> $GITHUB_ENV - name: sign-in to gar run: | gcloud auth configure-docker \ @@ -42,7 +40,7 @@ jobs: - name: delete container image in gar run: | gcloud artifacts docker images delete \ - ${IMAGE_NAME}:${{ env.ENVIRONMENT_ID }} \ + ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} \ --delete-tags \ --quiet diff --git a/.github/workflows/push-tag.yml b/.github/workflows/push-tag.yml index ae2f4a0..7107519 100644 --- a/.github/workflows/push-tag.yml +++ b/.github/workflows/push-tag.yml @@ -11,7 +11,7 @@ on: - 'v*' env: IMAGE_TAG: ${{ github.ref_name }} - IMAGE_NAME: ${{ secrets.REGISTRY_LOCATION }}-docker.pkg.dev/${{ secrets.PROJECT_ID }}/${{ secrets.REGISTRY_NAME }}/my-sample-app + IMAGE_NAME: ${{ secrets.REGISTRY_LOCATION }}-docker.pkg.dev/${{ secrets.PROJECT_ID }}/${{ secrets.REGISTRY_NAME }}/my-sample-workload ENVIRONMENT_ID: development WORKLOAD_NAME: my-sample-workload HUMCTL_VERSION: '*' From d0b9a1c0df19a23cef4c3145ce29b342dd6c3695 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 26 Jul 2024 13:05:48 -0400 Subject: [PATCH 06/26] disable score-k8s for now --- .github/workflows/open-pr.yml | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/.github/workflows/open-pr.yml b/.github/workflows/open-pr.yml index 7483962..8f30092 100644 --- a/.github/workflows/open-pr.yml +++ b/.github/workflows/open-pr.yml @@ -51,28 +51,6 @@ jobs: - name: make compose-test run: | make compose-test - - name: make kind-create-cluster - run: | - make kind-create-cluster - - name: make kind-load-image - run: | - make kind-load-image - - name: install score-k8s - uses: score-spec/setup-score@v3 - with: - file: score-k8s - token: ${{ secrets.GITHUB_TOKEN }} - version: ${{ env.SCORE_K8S_VERSION }} - - name: make k8s-up - id: k8s-up - run: | - make k8s-up - - name: catch k8s-up errors - if: ${{ failure() && steps.k8s-up.outcome == 'failure' }} - run: | - kubectl get events - kubectl logs \ - -l app.kubernetes.io/name=${{ env.WORKLOAD_NAME }} - name: authenticate to google cloud uses: google-github-actions/auth@v2 with: From 934da332b480f237f718128a6b6d520951c094d3 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 26 Jul 2024 13:17:40 -0400 Subject: [PATCH 07/26] RUNTIME_ERRORS --- .github/workflows/open-pr.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/open-pr.yml b/.github/workflows/open-pr.yml index 8f30092..add6fa3 100644 --- a/.github/workflows/open-pr.yml +++ b/.github/workflows/open-pr.yml @@ -180,6 +180,15 @@ jobs: echo "" >> pr_message.txt echo "" >> pr_message.txt fi + + RUNTIME_ERRORS=$(humctl api get /orgs/${{ secrets.HUMANITEC_ORG }}/apps/${{ vars.APP_NAME }}/envs/${{ env.ENVIRONMENT_ID }}/runtime \ + --token ${{ secrets.HUMANITEC_TOKEN }} \ + | grep '"status": "Failure"' -B 10) + echo "" >> pr_message.txt + echo "### Runtime errors:" >> pr_message.txt + echo "" >> pr_message.txt + echo "$RUNTIME_ERRORS" >> pr_message.txt + echo "" >> pr_message.txt echo "### [View in Humanitec]($ENV_URL)" >> pr_message.txt echo "Deployment ID: $DEPLOYMENT_ID" >> pr_message.txt From 66a1d18987101c9c77419338af9bebfc9810f276 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 26 Jul 2024 13:22:18 -0400 Subject: [PATCH 08/26] if RUNTIME_ERRORS --- .github/workflows/open-pr.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/open-pr.yml b/.github/workflows/open-pr.yml index add6fa3..f60a983 100644 --- a/.github/workflows/open-pr.yml +++ b/.github/workflows/open-pr.yml @@ -184,11 +184,13 @@ jobs: RUNTIME_ERRORS=$(humctl api get /orgs/${{ secrets.HUMANITEC_ORG }}/apps/${{ vars.APP_NAME }}/envs/${{ env.ENVIRONMENT_ID }}/runtime \ --token ${{ secrets.HUMANITEC_TOKEN }} \ | grep '"status": "Failure"' -B 10) - echo "" >> pr_message.txt - echo "### Runtime errors:" >> pr_message.txt - echo "" >> pr_message.txt - echo "$RUNTIME_ERRORS" >> pr_message.txt - echo "" >> pr_message.txt + if [ "$RUNTIME_ERRORS" != "" ]; then + echo "" >> pr_message.txt + echo "### Runtime errors:" >> pr_message.txt + echo "" >> pr_message.txt + echo "$RUNTIME_ERRORS" >> pr_message.txt + echo "" >> pr_message.txt + fi echo "### [View in Humanitec]($ENV_URL)" >> pr_message.txt echo "Deployment ID: $DEPLOYMENT_ID" >> pr_message.txt From 3a57ed6e06671c30e7054655ecb2188b544ac384 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 26 Jul 2024 13:29:01 -0400 Subject: [PATCH 09/26] if [ "$DEPLOYMENT_ERRORS" = "[]" && "$RUNTIME_ERRORS" = "" ] --- .github/workflows/open-pr.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/open-pr.yml b/.github/workflows/open-pr.yml index f60a983..0f61e0f 100644 --- a/.github/workflows/open-pr.yml +++ b/.github/workflows/open-pr.yml @@ -154,7 +154,10 @@ jobs: --org ${{ secrets.HUMANITEC_ORG }} \ --app ${{ vars.APP_NAME }} \ --env ${{ env.ENVIRONMENT_ID }} -o json) - if [ "$DEPLOYMENT_ERRORS" = "[]" ]; then + RUNTIME_ERRORS=$(humctl api get /orgs/${{ secrets.HUMANITEC_ORG }}/apps/${{ vars.APP_NAME }}/envs/${{ env.ENVIRONMENT_ID }}/runtime \ + --token ${{ secrets.HUMANITEC_TOKEN }} \ + | grep '"status": "Failure"' -B 10) + if [ "$DEPLOYMENT_ERRORS" = "[]" && "$RUNTIME_ERRORS" = "" ]; then echo "## Deployment successfully completed for ${{ env.ENVIRONMENT_NAME }}! :tada:" >> pr_message.txt echo "" >> pr_message.txt else @@ -181,9 +184,7 @@ jobs: echo "" >> pr_message.txt fi - RUNTIME_ERRORS=$(humctl api get /orgs/${{ secrets.HUMANITEC_ORG }}/apps/${{ vars.APP_NAME }}/envs/${{ env.ENVIRONMENT_ID }}/runtime \ - --token ${{ secrets.HUMANITEC_TOKEN }} \ - | grep '"status": "Failure"' -B 10) + if [ "$RUNTIME_ERRORS" != "" ]; then echo "" >> pr_message.txt echo "### Runtime errors:" >> pr_message.txt From f02e75f27ad213deb9dc08de27d519f183b6a7e1 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 26 Jul 2024 13:39:12 -0400 Subject: [PATCH 10/26] RUNTIME_ERRORS --- .github/workflows/open-pr.yml | 55 ++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/.github/workflows/open-pr.yml b/.github/workflows/open-pr.yml index 0f61e0f..b4afe79 100644 --- a/.github/workflows/open-pr.yml +++ b/.github/workflows/open-pr.yml @@ -163,34 +163,35 @@ jobs: else echo "## Deployment failed for ${{ env.ENVIRONMENT_NAME }}! :x:" >> pr_message.txt echo "" >> pr_message.txt - echo "### Errors:" >> pr_message.txt - echo "" >> pr_message.txt - echo '```json' >> pr_message.txt - echo "" >> pr_message.txt - echo "$DEPLOYMENT_ERRORS" | jq .[0].status.message -r >> pr_message.txt - echo "" >> pr_message.txt - echo '```' >> pr_message.txt - echo "" >> pr_message.txt - echo "
Errors details" >> pr_message.txt - echo "" >> pr_message.txt - echo "### Errors details:" >> pr_message.txt - echo '```json' >> pr_message.txt - echo "" >> pr_message.txt - echo "$DEPLOYMENT_ERRORS" >> pr_message.txt - echo "" >> pr_message.txt - echo '```' >> pr_message.txt - echo "" >> pr_message.txt - echo "
" >> pr_message.txt - echo "" >> pr_message.txt - fi + + if [ "$DEPLOYMENT_ERRORS" != "[]" ]; then + echo "### Deployment Errors:" >> pr_message.txt + echo "" >> pr_message.txt + echo '```json' >> pr_message.txt + echo "" >> pr_message.txt + echo "$DEPLOYMENT_ERRORS" | jq .[0].status.message -r >> pr_message.txt + echo "" >> pr_message.txt + echo '```' >> pr_message.txt + echo "" >> pr_message.txt + echo "
Errors details" >> pr_message.txt + echo "" >> pr_message.txt + echo "### Errors details:" >> pr_message.txt + echo '```json' >> pr_message.txt + echo "" >> pr_message.txt + echo "$DEPLOYMENT_ERRORS" >> pr_message.txt + echo "" >> pr_message.txt + echo '```' >> pr_message.txt + echo "" >> pr_message.txt + echo "
" >> pr_message.txt + echo "" >> pr_message.txt + fi - - if [ "$RUNTIME_ERRORS" != "" ]; then - echo "" >> pr_message.txt - echo "### Runtime errors:" >> pr_message.txt - echo "" >> pr_message.txt - echo "$RUNTIME_ERRORS" >> pr_message.txt - echo "" >> pr_message.txt + if [ "$RUNTIME_ERRORS" != "" ]; then + echo "### Runtime errors:" >> pr_message.txt + echo "" >> pr_message.txt + echo "$RUNTIME_ERRORS" >> pr_message.txt + echo "" >> pr_message.txt + fi fi echo "### [View in Humanitec]($ENV_URL)" >> pr_message.txt From 678eb0e2f33b1cc4840503d73dd7e6355836d02e Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 26 Jul 2024 13:49:11 -0400 Subject: [PATCH 11/26] -A 1 --- .github/workflows/open-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/open-pr.yml b/.github/workflows/open-pr.yml index b4afe79..98f674a 100644 --- a/.github/workflows/open-pr.yml +++ b/.github/workflows/open-pr.yml @@ -156,7 +156,7 @@ jobs: --env ${{ env.ENVIRONMENT_ID }} -o json) RUNTIME_ERRORS=$(humctl api get /orgs/${{ secrets.HUMANITEC_ORG }}/apps/${{ vars.APP_NAME }}/envs/${{ env.ENVIRONMENT_ID }}/runtime \ --token ${{ secrets.HUMANITEC_TOKEN }} \ - | grep '"status": "Failure"' -B 10) + | grep '"status": "Failure"' -B 10 -A 1) if [ "$DEPLOYMENT_ERRORS" = "[]" && "$RUNTIME_ERRORS" = "" ]; then echo "## Deployment successfully completed for ${{ env.ENVIRONMENT_NAME }}! :tada:" >> pr_message.txt echo "" >> pr_message.txt From dc0c693bd139442d41dd9d2ece183c07bf5c34b2 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 26 Jul 2024 13:54:31 -0400 Subject: [PATCH 12/26] Rollback tmp tests --- .github/workflows/open-pr.yml | 22 ++++++++++++++++++++++ score/score.yaml | 4 ++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.github/workflows/open-pr.yml b/.github/workflows/open-pr.yml index 98f674a..3cc80af 100644 --- a/.github/workflows/open-pr.yml +++ b/.github/workflows/open-pr.yml @@ -51,6 +51,28 @@ jobs: - name: make compose-test run: | make compose-test + - name: make kind-create-cluster + run: | + make kind-create-cluster + - name: make kind-load-image + run: | + make kind-load-image + - name: install score-k8s + uses: score-spec/setup-score@v3 + with: + file: score-k8s + token: ${{ secrets.GITHUB_TOKEN }} + version: ${{ env.SCORE_K8S_VERSION }} + - name: make k8s-up + id: k8s-up + run: | + make k8s-up + - name: catch k8s-up errors + if: ${{ failure() && steps.k8s-up.outcome == 'failure' }} + run: | + kubectl get events + kubectl logs \ + -l app.kubernetes.io/name=${{ env.WORKLOAD_NAME }} - name: authenticate to google cloud uses: google-github-actions/auth@v2 with: diff --git a/score/score.yaml b/score/score.yaml index f2184bc..bbb98b3 100644 --- a/score/score.yaml +++ b/score/score.yaml @@ -3,7 +3,7 @@ metadata: name: my-sample-workload containers: my-sample-container: - image: ghcr.io/mathieu-benoit/my-sample-workload:pouet + image: . resources: limits: memory: "256Mi" @@ -12,7 +12,7 @@ containers: memory: "64Mi" cpu: "25m" variables: - MESSAGE: "Hello, Test!" + MESSAGE: "Hello, World!" resources: dns: type: dns From db2648dfeedf4752c2e2654edfe221376082ed1e Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 26 Jul 2024 14:04:18 -0400 Subject: [PATCH 13/26] Rollback other changes not related to this PR --- .github/workflows/close-pr.yml | 6 ++++-- .github/workflows/push-tag.yml | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/close-pr.yml b/.github/workflows/close-pr.yml index 496b585..aa8bc99 100644 --- a/.github/workflows/close-pr.yml +++ b/.github/workflows/close-pr.yml @@ -8,7 +8,6 @@ on: - closed env: ENVIRONMENT_ID: pr-${{ github.event.number }} - IMAGE_NAME: ${{ secrets.REGISTRY_LOCATION }}-docker.pkg.dev/${{ secrets.PROJECT_ID }}/${{ secrets.REGISTRY_NAME }}/my-sample-workload HUMCTL_VERSION: '*' jobs: ob-pr-closed: @@ -32,6 +31,9 @@ jobs: - uses: google-github-actions/setup-gcloud@v2 with: version: latest + - name: prepare environment variables + run: | + echo "IMAGE_NAME=${{ secrets.REGISTRY_LOCATION }}-docker.pkg.dev/${{ secrets.PROJECT_ID }}/${{ secrets.REGISTRY_NAME }}/${{ vars.APP_NAME }}" >> $GITHUB_ENV - name: sign-in to gar run: | gcloud auth configure-docker \ @@ -40,7 +42,7 @@ jobs: - name: delete container image in gar run: | gcloud artifacts docker images delete \ - ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} \ + ${IMAGE_NAME}:${{ env.ENVIRONMENT_ID }} \ --delete-tags \ --quiet diff --git a/.github/workflows/push-tag.yml b/.github/workflows/push-tag.yml index 7107519..ae2f4a0 100644 --- a/.github/workflows/push-tag.yml +++ b/.github/workflows/push-tag.yml @@ -11,7 +11,7 @@ on: - 'v*' env: IMAGE_TAG: ${{ github.ref_name }} - IMAGE_NAME: ${{ secrets.REGISTRY_LOCATION }}-docker.pkg.dev/${{ secrets.PROJECT_ID }}/${{ secrets.REGISTRY_NAME }}/my-sample-workload + IMAGE_NAME: ${{ secrets.REGISTRY_LOCATION }}-docker.pkg.dev/${{ secrets.PROJECT_ID }}/${{ secrets.REGISTRY_NAME }}/my-sample-app ENVIRONMENT_ID: development WORKLOAD_NAME: my-sample-workload HUMCTL_VERSION: '*' From 428f181376138ddbbf6ebf746f6fd6253d2a25ce Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 26 Jul 2024 14:42:57 -0400 Subject: [PATCH 14/26] || true --- .github/workflows/open-pr.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/open-pr.yml b/.github/workflows/open-pr.yml index 3cc80af..058a3a1 100644 --- a/.github/workflows/open-pr.yml +++ b/.github/workflows/open-pr.yml @@ -178,7 +178,8 @@ jobs: --env ${{ env.ENVIRONMENT_ID }} -o json) RUNTIME_ERRORS=$(humctl api get /orgs/${{ secrets.HUMANITEC_ORG }}/apps/${{ vars.APP_NAME }}/envs/${{ env.ENVIRONMENT_ID }}/runtime \ --token ${{ secrets.HUMANITEC_TOKEN }} \ - | grep '"status": "Failure"' -B 10 -A 1) + | grep '"status": "Failure"' -B 10 -A 1 \ + || true) if [ "$DEPLOYMENT_ERRORS" = "[]" && "$RUNTIME_ERRORS" = "" ]; then echo "## Deployment successfully completed for ${{ env.ENVIRONMENT_NAME }}! :tada:" >> pr_message.txt echo "" >> pr_message.txt From e2d71e401d81070174c2a14dd65139fc1f90efe4 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 26 Jul 2024 14:56:03 -0400 Subject: [PATCH 15/26] || true --- .github/workflows/open-pr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/open-pr.yml b/.github/workflows/open-pr.yml index 058a3a1..cb9393b 100644 --- a/.github/workflows/open-pr.yml +++ b/.github/workflows/open-pr.yml @@ -178,8 +178,8 @@ jobs: --env ${{ env.ENVIRONMENT_ID }} -o json) RUNTIME_ERRORS=$(humctl api get /orgs/${{ secrets.HUMANITEC_ORG }}/apps/${{ vars.APP_NAME }}/envs/${{ env.ENVIRONMENT_ID }}/runtime \ --token ${{ secrets.HUMANITEC_TOKEN }} \ - | grep '"status": "Failure"' -B 10 -A 1 \ - || true) + | grep '"status": "Failure"' -B 10 -A 1) \ + || true if [ "$DEPLOYMENT_ERRORS" = "[]" && "$RUNTIME_ERRORS" = "" ]; then echo "## Deployment successfully completed for ${{ env.ENVIRONMENT_NAME }}! :tada:" >> pr_message.txt echo "" >> pr_message.txt From a1e8ea2f3a37ff35c1cfe89afe6f4c02b120cfb3 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Sat, 27 Jul 2024 07:52:26 -0400 Subject: [PATCH 16/26] -z "$RUNTIME_ERRORS" --- .github/workflows/open-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/open-pr.yml b/.github/workflows/open-pr.yml index cb9393b..ffd5d76 100644 --- a/.github/workflows/open-pr.yml +++ b/.github/workflows/open-pr.yml @@ -180,7 +180,7 @@ jobs: --token ${{ secrets.HUMANITEC_TOKEN }} \ | grep '"status": "Failure"' -B 10 -A 1) \ || true - if [ "$DEPLOYMENT_ERRORS" = "[]" && "$RUNTIME_ERRORS" = "" ]; then + if [ "$DEPLOYMENT_ERRORS" = "[]" && -z "$RUNTIME_ERRORS" ]; then echo "## Deployment successfully completed for ${{ env.ENVIRONMENT_NAME }}! :tada:" >> pr_message.txt echo "" >> pr_message.txt else From 22cf8bbf15fab5ce360b22ca64e006a2a62a75bb Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Sat, 27 Jul 2024 08:36:58 -0400 Subject: [PATCH 17/26] [[ && ]] --- .github/workflows/open-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/open-pr.yml b/.github/workflows/open-pr.yml index ffd5d76..a578dfe 100644 --- a/.github/workflows/open-pr.yml +++ b/.github/workflows/open-pr.yml @@ -180,7 +180,7 @@ jobs: --token ${{ secrets.HUMANITEC_TOKEN }} \ | grep '"status": "Failure"' -B 10 -A 1) \ || true - if [ "$DEPLOYMENT_ERRORS" = "[]" && -z "$RUNTIME_ERRORS" ]; then + if [[ "$DEPLOYMENT_ERRORS" = "[]" && -z "$RUNTIME_ERRORS" ]]; then echo "## Deployment successfully completed for ${{ env.ENVIRONMENT_NAME }}! :tada:" >> pr_message.txt echo "" >> pr_message.txt else From 9584d9d3356bb1589344668a380fd07b753a103a Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Sat, 27 Jul 2024 10:28:15 -0400 Subject: [PATCH 18/26] Graphviz link --- .github/workflows/open-pr.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/open-pr.yml b/.github/workflows/open-pr.yml index a578dfe..172c757 100644 --- a/.github/workflows/open-pr.yml +++ b/.github/workflows/open-pr.yml @@ -209,7 +209,7 @@ jobs: echo "" >> pr_message.txt fi - if [ "$RUNTIME_ERRORS" != "" ]; then + if [ -n "$RUNTIME_ERRORS" ]; then echo "### Runtime errors:" >> pr_message.txt echo "" >> pr_message.txt echo "$RUNTIME_ERRORS" >> pr_message.txt @@ -261,6 +261,7 @@ jobs: echo "
Resources Graph" >> pr_message.txt echo "" >> pr_message.txt echo "### Resources Graph:" >> pr_message.txt + echo "Use a [Graphviz](https://graphviz.org) viewer for a visual representation." >> pr_message.txt echo '```none' >> pr_message.txt echo "" >> pr_message.txt humctl resources graph \ From f6a1082e1dfd1651f6a8182bb20865644f94fb79 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Tue, 30 Jul 2024 12:00:49 -0400 Subject: [PATCH 19/26] Test exit 0 --- .github/workflows/open-pr.yml | 4 +++- score/score.yaml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/open-pr.yml b/.github/workflows/open-pr.yml index 172c757..e3d7784 100644 --- a/.github/workflows/open-pr.yml +++ b/.github/workflows/open-pr.yml @@ -275,7 +275,9 @@ jobs: echo "
" >> pr_message.txt fi - cat pr_message.txt + if [ -n "$RUNTIME_ERRORS" ]; then + exit 0 + fi - name: comment pr if: ${{ always() }} run: | diff --git a/score/score.yaml b/score/score.yaml index bbb98b3..fb78ef5 100644 --- a/score/score.yaml +++ b/score/score.yaml @@ -3,7 +3,7 @@ metadata: name: my-sample-workload containers: my-sample-container: - image: . + image: ghcr.io/mathieu-benoit/my-sample-workload:pouet resources: limits: memory: "256Mi" From d9d0ad1cf07ca991ecd73ff6472092b95e1dc803 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Tue, 30 Jul 2024 12:09:23 -0400 Subject: [PATCH 20/26] Skip score-k8s for now --- .github/workflows/open-pr.yml | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/.github/workflows/open-pr.yml b/.github/workflows/open-pr.yml index e3d7784..a498382 100644 --- a/.github/workflows/open-pr.yml +++ b/.github/workflows/open-pr.yml @@ -51,28 +51,6 @@ jobs: - name: make compose-test run: | make compose-test - - name: make kind-create-cluster - run: | - make kind-create-cluster - - name: make kind-load-image - run: | - make kind-load-image - - name: install score-k8s - uses: score-spec/setup-score@v3 - with: - file: score-k8s - token: ${{ secrets.GITHUB_TOKEN }} - version: ${{ env.SCORE_K8S_VERSION }} - - name: make k8s-up - id: k8s-up - run: | - make k8s-up - - name: catch k8s-up errors - if: ${{ failure() && steps.k8s-up.outcome == 'failure' }} - run: | - kubectl get events - kubectl logs \ - -l app.kubernetes.io/name=${{ env.WORKLOAD_NAME }} - name: authenticate to google cloud uses: google-github-actions/auth@v2 with: From d2b68f0784e0cb263e230400d4e9d95b84b764e9 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Tue, 30 Jul 2024 12:52:02 -0400 Subject: [PATCH 21/26] Fixing image error, now testing missing var --- .github/workflows/open-pr.yml | 22 ++++++++++++++++++++++ score/score.yaml | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/open-pr.yml b/.github/workflows/open-pr.yml index a498382..e3d7784 100644 --- a/.github/workflows/open-pr.yml +++ b/.github/workflows/open-pr.yml @@ -51,6 +51,28 @@ jobs: - name: make compose-test run: | make compose-test + - name: make kind-create-cluster + run: | + make kind-create-cluster + - name: make kind-load-image + run: | + make kind-load-image + - name: install score-k8s + uses: score-spec/setup-score@v3 + with: + file: score-k8s + token: ${{ secrets.GITHUB_TOKEN }} + version: ${{ env.SCORE_K8S_VERSION }} + - name: make k8s-up + id: k8s-up + run: | + make k8s-up + - name: catch k8s-up errors + if: ${{ failure() && steps.k8s-up.outcome == 'failure' }} + run: | + kubectl get events + kubectl logs \ + -l app.kubernetes.io/name=${{ env.WORKLOAD_NAME }} - name: authenticate to google cloud uses: google-github-actions/auth@v2 with: diff --git a/score/score.yaml b/score/score.yaml index fb78ef5..b6ffd03 100644 --- a/score/score.yaml +++ b/score/score.yaml @@ -3,7 +3,7 @@ metadata: name: my-sample-workload containers: my-sample-container: - image: ghcr.io/mathieu-benoit/my-sample-workload:pouet + image: . resources: limits: memory: "256Mi" @@ -13,6 +13,7 @@ containers: cpu: "25m" variables: MESSAGE: "Hello, World!" + MISSING_VAR: ${resources.env.nonexistent-var} resources: dns: type: dns From 332b66e0ebe0e7ac228d81a0dcb0541dc8a293ac Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Tue, 30 Jul 2024 12:53:14 -0400 Subject: [PATCH 22/26] MISSING_VAR --- score/score.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/score/score.yaml b/score/score.yaml index b6ffd03..2fb1b92 100644 --- a/score/score.yaml +++ b/score/score.yaml @@ -15,6 +15,8 @@ containers: MESSAGE: "Hello, World!" MISSING_VAR: ${resources.env.nonexistent-var} resources: + env: + type: environment dns: type: dns route: From e926ee6458c95395e2224a89aa1b03f517b3aa3f Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Tue, 30 Jul 2024 12:57:39 -0400 Subject: [PATCH 23/26] skip score-k8s --- .github/workflows/open-pr.yml | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/.github/workflows/open-pr.yml b/.github/workflows/open-pr.yml index e3d7784..a498382 100644 --- a/.github/workflows/open-pr.yml +++ b/.github/workflows/open-pr.yml @@ -51,28 +51,6 @@ jobs: - name: make compose-test run: | make compose-test - - name: make kind-create-cluster - run: | - make kind-create-cluster - - name: make kind-load-image - run: | - make kind-load-image - - name: install score-k8s - uses: score-spec/setup-score@v3 - with: - file: score-k8s - token: ${{ secrets.GITHUB_TOKEN }} - version: ${{ env.SCORE_K8S_VERSION }} - - name: make k8s-up - id: k8s-up - run: | - make k8s-up - - name: catch k8s-up errors - if: ${{ failure() && steps.k8s-up.outcome == 'failure' }} - run: | - kubectl get events - kubectl logs \ - -l app.kubernetes.io/name=${{ env.WORKLOAD_NAME }} - name: authenticate to google cloud uses: google-github-actions/auth@v2 with: From b812fe6a0827fb931e2fa6178bbc8ce597d05acf Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Tue, 30 Jul 2024 13:04:24 -0400 Subject: [PATCH 24/26] remove exit 0 --- .github/workflows/open-pr.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/open-pr.yml b/.github/workflows/open-pr.yml index a498382..f3e0b74 100644 --- a/.github/workflows/open-pr.yml +++ b/.github/workflows/open-pr.yml @@ -252,10 +252,6 @@ jobs: echo "" >> pr_message.txt echo "" >> pr_message.txt fi - - if [ -n "$RUNTIME_ERRORS" ]; then - exit 0 - fi - name: comment pr if: ${{ always() }} run: | From 654ef4fb4a19bc7876310f09ec23688a91c2cfb3 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Tue, 30 Jul 2024 13:24:40 -0400 Subject: [PATCH 25/26] Fix errors for tests --- .github/workflows/open-pr.yml | 22 ++++++++++++++++++++++ score/score.yaml | 3 --- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/.github/workflows/open-pr.yml b/.github/workflows/open-pr.yml index f3e0b74..694b97f 100644 --- a/.github/workflows/open-pr.yml +++ b/.github/workflows/open-pr.yml @@ -51,6 +51,28 @@ jobs: - name: make compose-test run: | make compose-test + - name: make kind-create-cluster + run: | + make kind-create-cluster + - name: make kind-load-image + run: | + make kind-load-image + - name: install score-k8s + uses: score-spec/setup-score@v3 + with: + file: score-k8s + token: ${{ secrets.GITHUB_TOKEN }} + version: ${{ env.SCORE_K8S_VERSION }} + - name: make k8s-up + id: k8s-up + run: | + make k8s-up + - name: catch k8s-up errors + if: ${{ failure() && steps.k8s-up.outcome == 'failure' }} + run: | + kubectl get events + kubectl logs \ + -l app.kubernetes.io/name=${{ env.WORKLOAD_NAME }} - name: authenticate to google cloud uses: google-github-actions/auth@v2 with: diff --git a/score/score.yaml b/score/score.yaml index 2fb1b92..bbb98b3 100644 --- a/score/score.yaml +++ b/score/score.yaml @@ -13,10 +13,7 @@ containers: cpu: "25m" variables: MESSAGE: "Hello, World!" - MISSING_VAR: ${resources.env.nonexistent-var} resources: - env: - type: environment dns: type: dns route: From 2da007fca82dda88ef78b8f9296ff593c5abf2f7 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Tue, 30 Jul 2024 14:01:21 -0400 Subject: [PATCH 26/26] Catch Runtime errors in push-tag too --- .github/workflows/open-pr.yml | 8 ++++---- .github/workflows/push-tag.yml | 26 ++++++++++++++++++++------ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/.github/workflows/open-pr.yml b/.github/workflows/open-pr.yml index 694b97f..e1c4db3 100644 --- a/.github/workflows/open-pr.yml +++ b/.github/workflows/open-pr.yml @@ -188,7 +188,7 @@ jobs: echo "" >> pr_message.txt if [ "$DEPLOYMENT_ERRORS" != "[]" ]; then - echo "### Deployment Errors:" >> pr_message.txt + echo "### Deployment errors:" >> pr_message.txt echo "" >> pr_message.txt echo '```json' >> pr_message.txt echo "" >> pr_message.txt @@ -196,9 +196,9 @@ jobs: echo "" >> pr_message.txt echo '```' >> pr_message.txt echo "" >> pr_message.txt - echo "
Errors details" >> pr_message.txt + echo "
Deployment errors details" >> pr_message.txt echo "" >> pr_message.txt - echo "### Errors details:" >> pr_message.txt + echo "### Deployment errors details:" >> pr_message.txt echo '```json' >> pr_message.txt echo "" >> pr_message.txt echo "$DEPLOYMENT_ERRORS" >> pr_message.txt @@ -221,7 +221,7 @@ jobs: echo "Deployment ID: $DEPLOYMENT_ID" >> pr_message.txt echo "" >> pr_message.txt - echo "### Domains:" >> pr_message.txt + echo "### URLs:" >> pr_message.txt echo "" >> pr_message.txt echo "$DOMAINS" >> pr_message.txt echo "" >> pr_message.txt diff --git a/.github/workflows/push-tag.yml b/.github/workflows/push-tag.yml index ae2f4a0..074fbc5 100644 --- a/.github/workflows/push-tag.yml +++ b/.github/workflows/push-tag.yml @@ -139,23 +139,37 @@ jobs: --org ${{ secrets.HUMANITEC_ORG }} \ --app ${{ vars.APP_NAME }} \ --env ${{ env.ENVIRONMENT_ID }} -o json) - if [ "$DEPLOYMENT_ERRORS" = "[]" ]; then + RUNTIME_ERRORS=$(humctl api get /orgs/${{ secrets.HUMANITEC_ORG }}/apps/${{ vars.APP_NAME }}/envs/${{ env.ENVIRONMENT_ID }}/runtime \ + --token ${{ secrets.HUMANITEC_TOKEN }} \ + | grep '"status": "Failure"' -B 10 -A 1) \ + || true + if [[ "$DEPLOYMENT_ERRORS" = "[]" && -z "$RUNTIME_ERRORS" ]]; then echo "## Deployment successfully completed for ${{ env.ENVIRONMENT_ID }}! :tada:" echo "" else echo "## Deployment failed for ${{ env.ENVIRONMENT_ID }}! :x:" echo "" - echo "### Errors:" - echo "" - echo "$DEPLOYMENT_ERRORS" - echo "" + + if [ "$DEPLOYMENT_ERRORS" != "[]" ]; then + echo "### Deployment errors:" + echo "" + echo "$DEPLOYMENT_ERRORS" + echo "" + fi + + if [ -n "$RUNTIME_ERRORS" ]; then + echo "### Runtime errors:" + echo "" + echo "$RUNTIME_ERRORS" + echo "" + fi fi echo "### View in Humanitec: $ENV_URL" echo "" echo "### Deployment ID: $DEPLOYMENT_ID" echo "" - echo "### Domains:" + echo "### URLs:" echo "" echo "$DOMAINS" echo ""