From a221b0c68ddece8965aa2ad433995695d873feb7 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Wed, 19 Jul 2023 13:34:17 +0200 Subject: [PATCH 1/6] move lint checks to separate job Running the lint checks separately allows running tests to check code correctness even when targeting non-master branches or having outdated copyright headers. --- .github/workflows/ci.yml | 105 +++++++++++++++++++++------------------ 1 file changed, 56 insertions(+), 49 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6258209ee2..f0f9e90887 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,31 +57,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - with: - fetch-depth: 2 # In PR, has extra merge commit: ^1 = PR, ^2 = base - # submodules: true # Fails on nimyaml tests - - - name: Check copyright year (Linux) - if: github.event_name == 'pull_request' && runner.os == 'Linux' - run: | - excluded_files="config.yaml" - excluded_extensions="ans|json|md|png|ssz|txt" - - current_year=$(date +"%Y") - outdated_files=() - while read -r file; do - if ! grep -qE 'Copyright \(c\) .*'$current_year' Status Research & Development GmbH' "$file"; then - outdated_files+=("$file") - fi - done < <(git diff --name-only --diff-filter=AM --ignore-submodules HEAD^ HEAD | grep -vE '(\.('$excluded_extensions')|'$excluded_files')$' || true) - - if (( ${#outdated_files[@]} )); then - echo "The following files do not have an up-to-date copyright year:" - for file in "${outdated_files[@]}"; do - echo "- $file" - done - exit 2 - fi - name: MSYS2 (Windows amd64) if: runner.os == 'Windows' && matrix.target.cpu == 'amd64' @@ -164,25 +139,6 @@ jobs: ${make_cmd} -j ${ncpu} NIM_COMMIT=${{ matrix.branch }} ARCH_OVERRIDE=${PLATFORM} QUICK_AND_DIRTY_COMPILER=1 update ./env.sh nim --version - - name: Check submodules (Linux) - if: github.event_name == 'pull_request' && runner.os == 'Linux' - run: | - while read -r file; do - commit="$(git -C "$file" rev-parse HEAD)" - if ! branch="$(git config -f .gitmodules --get "submodule.$file.branch")"; then - echo "Submodule '$file': '.gitmodules' lacks 'branch' entry" - exit 2 - fi - if ! error="$(git -C "$file" fetch -q origin "$branch")"; then - echo "Submodule '$file': Failed to fetch '$branch': $error" - exit 2 - fi - if ! git -C "$file" merge-base --is-ancestor "$commit" "origin/$branch"; then - echo "Submodule '$file': '$commit' is not on '$branch'" - exit 2 - fi - done < <(git diff --name-only --diff-filter=AM HEAD^ HEAD | grep -f <(git config --file .gitmodules --get-regexp path | awk '{ print $2 }') || true) - - name: Get latest fixtures commit hash id: fixtures_version run: | @@ -223,13 +179,64 @@ jobs: name: Unit Test Results ${{ matrix.target.os }}-${{ matrix.target.cpu }} path: build/*.xml + lint: + name: "Lint" + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 2 # In PR, has extra merge commit: ^1 = PR, ^2 = base + submodules: 'recursive' + + - name: Check copyright year + if: github.event_name == 'pull_request' + run: | + excluded_files="config.yaml" + excluded_extensions="ans|json|md|png|ssz|txt" + + current_year=$(date +"%Y") + outdated_files=() + while read -r file; do + if ! grep -qE 'Copyright \(c\) .*'$current_year' Status Research & Development GmbH' "$file"; then + outdated_files+=("$file") + fi + done < <(git diff --name-only --diff-filter=AM --ignore-submodules HEAD^ HEAD | grep -vE '(\.('$excluded_extensions')|'$excluded_files')$' || true) + + if (( ${#outdated_files[@]} )); then + echo "The following files do not have an up-to-date copyright year:" + for file in "${outdated_files[@]}"; do + echo "- $file" + done + exit 2 + fi + + - name: Check submodules + if: github.event_name == 'pull_request' + run: | + while read -r file; do + commit="$(git -C "$file" rev-parse HEAD)" + if ! branch="$(git config -f .gitmodules --get "submodule.$file.branch")"; then + echo "Submodule '$file': '.gitmodules' lacks 'branch' entry" + exit 2 + fi + if ! error="$(git -C "$file" fetch -q origin "$branch")"; then + echo "Submodule '$file': Failed to fetch '$branch': $error" + exit 2 + fi + if ! git -C "$file" merge-base --is-ancestor "$commit" "origin/$branch"; then + echo "Submodule '$file': '$commit' is not on '$branch'" + exit 2 + fi + done < <(git diff --name-only --diff-filter=AM HEAD^ HEAD | grep -f <(git config --file .gitmodules --get-regexp path | awk '{ print $2 }') || true) + # https://github.com/EnricoMi/publish-unit-test-result-action event_file: name: "Event File" runs-on: ubuntu-latest steps: - - name: Upload - uses: actions/upload-artifact@v3 - with: - name: Event File - path: ${{ github.event_path }} + - name: Upload + uses: actions/upload-artifact@v3 + with: + name: Event File + path: ${{ github.event_path }} From 914ff8d63bf5661ff7995eec611a82f4e9abc882 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Wed, 19 Jul 2023 13:39:28 +0200 Subject: [PATCH 2/6] add some lint violations --- .github/workflows/ci.yml | 2 +- vendor/nim-web3 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f0f9e90887..c9601241fb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,5 @@ # beacon_chain -# Copyright (c) 2020-2023 Status Research & Development GmbH +# Copyright (c) 2020-2022 Status Research & Development GmbH # Licensed and distributed under either of # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). diff --git a/vendor/nim-web3 b/vendor/nim-web3 index 06ebe0ab18..31b447c7b2 160000 --- a/vendor/nim-web3 +++ b/vendor/nim-web3 @@ -1 +1 @@ -Subproject commit 06ebe0ab1850bd0805fbf3933764adf4af058421 +Subproject commit 31b447c7b2dc00288f301d5802ce34c68702290b From b0bce4a3ab606ecbf0f194053a67b74a919873a6 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Wed, 19 Jul 2023 13:42:25 +0200 Subject: [PATCH 3/6] try to run both lint checks in one go --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c9601241fb..fb87357a97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -210,6 +210,7 @@ jobs: done exit 2 fi + continue-on-error: true - name: Check submodules if: github.event_name == 'pull_request' @@ -229,6 +230,7 @@ jobs: exit 2 fi done < <(git diff --name-only --diff-filter=AM HEAD^ HEAD | grep -f <(git config --file .gitmodules --get-regexp path | awk '{ print $2 }') || true) + continue-on-error: true # https://github.com/EnricoMi/publish-unit-test-result-action event_file: From e387f3793920ab2e9ca457d7293fff975b475adf Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Wed, 19 Jul 2023 13:47:14 +0200 Subject: [PATCH 4/6] try with always --- .github/workflows/ci.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb87357a97..832a579c8b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -190,7 +190,7 @@ jobs: submodules: 'recursive' - name: Check copyright year - if: github.event_name == 'pull_request' + if: ${{ always() }} && github.event_name == 'pull_request' run: | excluded_files="config.yaml" excluded_extensions="ans|json|md|png|ssz|txt" @@ -210,10 +210,9 @@ jobs: done exit 2 fi - continue-on-error: true - name: Check submodules - if: github.event_name == 'pull_request' + if: ${{ always() }} && github.event_name == 'pull_request' run: | while read -r file; do commit="$(git -C "$file" rev-parse HEAD)" @@ -230,7 +229,6 @@ jobs: exit 2 fi done < <(git diff --name-only --diff-filter=AM HEAD^ HEAD | grep -f <(git config --file .gitmodules --get-regexp path | awk '{ print $2 }') || true) - continue-on-error: true # https://github.com/EnricoMi/publish-unit-test-result-action event_file: From c11d75cc0c5f21b65a2e03600dab93ccf1f597af Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Wed, 19 Jul 2023 13:49:19 +0200 Subject: [PATCH 5/6] allow cancellation --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 832a579c8b..4e1f476f42 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -190,7 +190,7 @@ jobs: submodules: 'recursive' - name: Check copyright year - if: ${{ always() }} && github.event_name == 'pull_request' + if: ${{ !cancelled() }} && github.event_name == 'pull_request' run: | excluded_files="config.yaml" excluded_extensions="ans|json|md|png|ssz|txt" @@ -212,7 +212,7 @@ jobs: fi - name: Check submodules - if: ${{ always() }} && github.event_name == 'pull_request' + if: ${{ !cancelled() }} && github.event_name == 'pull_request' run: | while read -r file; do commit="$(git -C "$file" rev-parse HEAD)" From 8fa7e252d0526a52c88e23caadd60d5fc83590eb Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Wed, 19 Jul 2023 13:52:04 +0200 Subject: [PATCH 6/6] Revert "add some lint violations" This reverts commit 914ff8d63bf5661ff7995eec611a82f4e9abc882. --- .github/workflows/ci.yml | 2 +- vendor/nim-web3 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e1f476f42..119571c4e6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,5 @@ # beacon_chain -# Copyright (c) 2020-2022 Status Research & Development GmbH +# Copyright (c) 2020-2023 Status Research & Development GmbH # Licensed and distributed under either of # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). diff --git a/vendor/nim-web3 b/vendor/nim-web3 index 31b447c7b2..06ebe0ab18 160000 --- a/vendor/nim-web3 +++ b/vendor/nim-web3 @@ -1 +1 @@ -Subproject commit 31b447c7b2dc00288f301d5802ce34c68702290b +Subproject commit 06ebe0ab1850bd0805fbf3933764adf4af058421