From ef8c33fd8593308caec64b6a59de6148a7e6f63b Mon Sep 17 00:00:00 2001 From: mrekucci Date: Wed, 3 Jul 2024 18:06:23 +0200 Subject: [PATCH] refactor: integrate infrastructure workflow into ci workflow --- .github/workflows/ci.yml | 9 +++++++++ .../workflows/{infrstructure.yml => infrastructure.yml} | 9 ++------- infrastructure/nomad/playbooks/deploy.yml | 8 ++++++-- 3 files changed, 17 insertions(+), 9 deletions(-) rename .github/workflows/{infrstructure.yml => infrastructure.yml} (98%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0390f38b..cc6ec6985 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -216,3 +216,12 @@ jobs: git diff --name-only --exit-code . || (echo "Generated files not in parity with the source files." && exit 1) git reset --hard HEAD working-directory: contracts-abi + + infrastructure: + uses: ./.github/workflows/infrastructure.yml + secrets: inherit + needs: + - commitlint + - go-modules + - foundry + - contracts diff --git a/.github/workflows/infrstructure.yml b/.github/workflows/infrastructure.yml similarity index 98% rename from .github/workflows/infrstructure.yml rename to .github/workflows/infrastructure.yml index 0069101c6..0b49965b4 100644 --- a/.github/workflows/infrstructure.yml +++ b/.github/workflows/infrastructure.yml @@ -1,11 +1,7 @@ name: infrastructure on: - workflow_run: - workflows: - - ci - types: - - completed + workflow_call: workflow_dispatch: inputs: profile: @@ -50,7 +46,6 @@ jobs: name: Setup and Test Nomad Cluster runs-on: ubuntu-22.04 timeout-minutes: 180 - if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }} steps: - name: Setup Environment @@ -104,7 +99,7 @@ jobs: uses: actions/checkout@v4 with: submodules: recursive - ref: ${{ github.event.workflow_run.head_branch }} + ref: ${{ github.event.workflow_run.head_branch || github.event.inputs.branch || github.ref }} - name: Setup Cache uses: actions/cache@v4 diff --git a/infrastructure/nomad/playbooks/deploy.yml b/infrastructure/nomad/playbooks/deploy.yml index ccc108032..d5f56853f 100644 --- a/infrastructure/nomad/playbooks/deploy.yml +++ b/infrastructure/nomad/playbooks/deploy.yml @@ -573,7 +573,11 @@ ansible.builtin.shell: | RESULT="$(nomad run {{ ansible_env.HOME }}/{{ env }}/{{ job.name }}.nomad 2>&1)" if [ $? -ne 0 ]; then - echo "Failed to deploy {{ job.name }}: ${RESULT}." + echo "Failed to deploy {{ job.name }}:\n${RESULT}." + echo "{{ job.name }} stdout logs:" + nomad alloc logs -stdout -job "{{ job.name }}" | tail -n 100 + echo "{{ job.name }} error logs:" + nomad alloc logs -stderr -job "{{ job.name }}" | tail -n 100 exit 1 fi @@ -581,7 +585,7 @@ START_TIME=$(date +%s) RESULT=$(nomad job status -json "{{ job.name }}") if [ $? -ne 0 ]; then - echo "Failed to get job status for {{ job.name }}: ${RESULT}." + echo "Failed to get job status for {{ job.name }}:\n${RESULT}." exit 1 fi JOB_TYPE=$(echo "${RESULT}" | jq -r '.[0].Allocations[0].JobType')