From a5d81256fa48b612275772db9fcbf78cef43375f Mon Sep 17 00:00:00 2001 From: nomaxg Date: Wed, 27 Mar 2024 14:40:36 -0400 Subject: [PATCH 1/7] workflow that fails if process compose is edited but docker compose isn't --- .github/workflows/check-demo-consistency.yml | 28 ++++++++++++++++++++ process-compose.yaml | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/check-demo-consistency.yml diff --git a/.github/workflows/check-demo-consistency.yml b/.github/workflows/check-demo-consistency.yml new file mode 100644 index 0000000000..076695add6 --- /dev/null +++ b/.github/workflows/check-demo-consistency.yml @@ -0,0 +1,28 @@ +# Fails if process-compose is edited but not docker-compose +name: Check Demo Consistency + +on: + pull_request: + paths: + - 'process-compose.yaml' + - 'docker-compose.yml' + +jobs: + check-edits: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v3 + + - name: Check for file edits + run: | + FILES_CHANGED=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }}) + + # Check if process-compose.yaml is edited + if echo "$FILES_CHANGED" | grep -q "process-compose.yaml"; then + # Fail if docker-compose.yml is not also edited + if ! echo "$FILES_CHANGED" | grep -q "docker-compose.yml"; then + echo "process-compose.yaml is edited but not docker-compose.yml" + exit 1 + fi + fi diff --git a/process-compose.yaml b/process-compose.yaml index 96514d402a..036e2beb80 100644 --- a/process-compose.yaml +++ b/process-compose.yaml @@ -19,7 +19,7 @@ processes: exec: command: "[ $(docker inspect -f '{{.State.Health.Status}}' espresso-sequencer-demo-l1-network-1) = 'healthy' ]" initial_delay_seconds: 5 - period_seconds: 5 + period_seconds: 6 timeout_seconds: 5 success_threshold: 1 failure_threshold: 20 From e3dcff0cdb504df4230446b72d99e73e3e34a9e2 Mon Sep 17 00:00:00 2001 From: nomaxg Date: Wed, 27 Mar 2024 14:44:39 -0400 Subject: [PATCH 2/7] typo --- .github/workflows/check-demo-consistency.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/check-demo-consistency.yml b/.github/workflows/check-demo-consistency.yml index 076695add6..20e5f4e7de 100644 --- a/.github/workflows/check-demo-consistency.yml +++ b/.github/workflows/check-demo-consistency.yml @@ -5,7 +5,7 @@ on: pull_request: paths: - 'process-compose.yaml' - - 'docker-compose.yml' + - 'docker-compose.yaml' jobs: check-edits: @@ -19,10 +19,10 @@ jobs: FILES_CHANGED=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }}) # Check if process-compose.yaml is edited - if echo "$FILES_CHANGED" | grep -q "process-compose.yaml"; then + if echo "$FILES_CHANGED" | grep -q "process-compose.yml"; then # Fail if docker-compose.yml is not also edited - if ! echo "$FILES_CHANGED" | grep -q "docker-compose.yml"; then - echo "process-compose.yaml is edited but not docker-compose.yml" + if ! echo "$FILES_CHANGED" | grep -q "docker-compose.yaml"; then + echo "process-compose.yaml is edited but not docker-compose.yaml" exit 1 fi fi From 62afd082dd624ac33dc58edb6689e68ae2e35bea Mon Sep 17 00:00:00 2001 From: nomaxg Date: Wed, 27 Mar 2024 14:48:44 -0400 Subject: [PATCH 3/7] increase fetch depth --- .github/workflows/check-demo-consistency.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/check-demo-consistency.yml b/.github/workflows/check-demo-consistency.yml index 20e5f4e7de..766fde064c 100644 --- a/.github/workflows/check-demo-consistency.yml +++ b/.github/workflows/check-demo-consistency.yml @@ -13,6 +13,8 @@ jobs: steps: - name: Check out code uses: actions/checkout@v3 + with: + fetch-depth: 2 - name: Check for file edits run: | From d1eb7f8922ce1e29339a35ee7513a9d6e52d7c42 Mon Sep 17 00:00:00 2001 From: nomaxg Date: Wed, 27 Mar 2024 14:50:42 -0400 Subject: [PATCH 4/7] fix git diff --- .github/workflows/check-demo-consistency.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-demo-consistency.yml b/.github/workflows/check-demo-consistency.yml index 766fde064c..48496d7e25 100644 --- a/.github/workflows/check-demo-consistency.yml +++ b/.github/workflows/check-demo-consistency.yml @@ -18,7 +18,7 @@ jobs: - name: Check for file edits run: | - FILES_CHANGED=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }}) + FILES_CHANGED=$(git diff --name-only origin/main..HEAD) # Check if process-compose.yaml is edited if echo "$FILES_CHANGED" | grep -q "process-compose.yml"; then From 79e7d23c002803a6c6069e478983fa0860dc54b9 Mon Sep 17 00:00:00 2001 From: nomaxg Date: Wed, 27 Mar 2024 14:58:20 -0400 Subject: [PATCH 5/7] fetch main --- .github/workflows/check-demo-consistency.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/check-demo-consistency.yml b/.github/workflows/check-demo-consistency.yml index 48496d7e25..ad2f1c16aa 100644 --- a/.github/workflows/check-demo-consistency.yml +++ b/.github/workflows/check-demo-consistency.yml @@ -18,6 +18,7 @@ jobs: - name: Check for file edits run: | + git fetch origin main FILES_CHANGED=$(git diff --name-only origin/main..HEAD) # Check if process-compose.yaml is edited From c761de3935880bb99a70e873a89da41516d80109 Mon Sep 17 00:00:00 2001 From: nomaxg Date: Wed, 27 Mar 2024 15:04:06 -0400 Subject: [PATCH 6/7] grep properly --- .github/workflows/check-demo-consistency.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-demo-consistency.yml b/.github/workflows/check-demo-consistency.yml index ad2f1c16aa..39435f4eea 100644 --- a/.github/workflows/check-demo-consistency.yml +++ b/.github/workflows/check-demo-consistency.yml @@ -22,9 +22,9 @@ jobs: FILES_CHANGED=$(git diff --name-only origin/main..HEAD) # Check if process-compose.yaml is edited - if echo "$FILES_CHANGED" | grep -q "process-compose.yml"; then + if echo "$FILES_CHANGED" | grep "process-compose.yaml"; then # Fail if docker-compose.yml is not also edited - if ! echo "$FILES_CHANGED" | grep -q "docker-compose.yaml"; then + if ! echo "$FILES_CHANGED" | grep "docker-compose.yaml"; then echo "process-compose.yaml is edited but not docker-compose.yaml" exit 1 fi From fae314c239df57cf994de8a28ed7ab2eb81f2bca Mon Sep 17 00:00:00 2001 From: nomaxg Date: Wed, 27 Mar 2024 15:06:04 -0400 Subject: [PATCH 7/7] add disclaimer about things being fine if intentional --- .github/workflows/check-demo-consistency.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/check-demo-consistency.yml b/.github/workflows/check-demo-consistency.yml index 39435f4eea..a5dbc6d085 100644 --- a/.github/workflows/check-demo-consistency.yml +++ b/.github/workflows/check-demo-consistency.yml @@ -26,6 +26,7 @@ jobs: # Fail if docker-compose.yml is not also edited if ! echo "$FILES_CHANGED" | grep "docker-compose.yaml"; then echo "process-compose.yaml is edited but not docker-compose.yaml" + echo "If this was intentional, you may ignore this failure" exit 1 fi fi