move lint checks to separate job (#5200)
Running the lint checks separately allows running tests to check code correctness even when targeting non-master branches or having outdated copyright headers.
This commit is contained in:
parent
971b4483c5
commit
722b7f6f6b
|
@ -57,31 +57,6 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
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)
|
- name: MSYS2 (Windows amd64)
|
||||||
if: runner.os == 'Windows' && matrix.target.cpu == '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
|
${make_cmd} -j ${ncpu} NIM_COMMIT=${{ matrix.branch }} ARCH_OVERRIDE=${PLATFORM} QUICK_AND_DIRTY_COMPILER=1 update
|
||||||
./env.sh nim --version
|
./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
|
- name: Get latest fixtures commit hash
|
||||||
id: fixtures_version
|
id: fixtures_version
|
||||||
run: |
|
run: |
|
||||||
|
@ -223,13 +179,64 @@ jobs:
|
||||||
name: Unit Test Results ${{ matrix.target.os }}-${{ matrix.target.cpu }}
|
name: Unit Test Results ${{ matrix.target.os }}-${{ matrix.target.cpu }}
|
||||||
path: build/*.xml
|
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: ${{ !cancelled() }} && 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: ${{ !cancelled() }} && 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
|
# https://github.com/EnricoMi/publish-unit-test-result-action
|
||||||
event_file:
|
event_file:
|
||||||
name: "Event File"
|
name: "Event File"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Upload
|
- name: Upload
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: Event File
|
name: Event File
|
||||||
path: ${{ github.event_path }}
|
path: ${{ github.event_path }}
|
||||||
|
|
Loading…
Reference in New Issue