From 9925c6fb3e21ca868f508145f516388dbe23a955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Mon, 25 Sep 2023 18:54:31 +0000 Subject: [PATCH 1/9] Add Integrity workflow --- .github/workflows/back-end.yml | 86 ------------ .github/workflows/integrity.yml | 39 ++++++ .github/workflows/reusable-integrity.yml | 168 +++++++++++++++++++++++ .github/workflows/spelling.yml | 2 +- 4 files changed, 208 insertions(+), 87 deletions(-) create mode 100644 .github/workflows/integrity.yml create mode 100644 .github/workflows/reusable-integrity.yml diff --git a/.github/workflows/back-end.yml b/.github/workflows/back-end.yml index 320dbd920..969711d82 100644 --- a/.github/workflows/back-end.yml +++ b/.github/workflows/back-end.yml @@ -17,28 +17,6 @@ concurrency: cancel-in-progress: true jobs: - byte_level: - name: "0️⃣ Byte-level" - runs-on: "ubuntu-22.04" - timeout-minutes: 1 - steps: - - - name: "Checkout repository" - uses: "actions/checkout@v3" - - - name: "Check file permissions" - run: | - test "$(find ./ -type f -not -path './.git/*' -executable)" = "" - - - name: "Check for byte order mark (BOM)" - run: | - ! git grep --perl-regexp -I -e '^\xEF\xBB\xBF' - - - # https://html.spec.whatwg.org/multipage/named-characters.html - name: "Find non-printable ASCII characters" - run: | - ! LC_ALL=C.UTF-8 git grep --perl-regexp --line-number -e '[^ -~]' -- '*.php' - syntax_errors: name: "1️⃣ Syntax errors" runs-on: "ubuntu-22.04" @@ -55,10 +33,6 @@ jobs: - name: "Checkout repository" uses: "actions/checkout@v3" - - - name: "Search for conflict markers 🐌" - run: | - ! git grep --line-number -e '^\(<<<<<<<\s\|=======\s\|=======$\|>>>>>>>\s\||||||||\s\)' - name: "Search for invalid complex curly syntax 🐌" run: | @@ -66,7 +40,6 @@ jobs: - name: "Check source code for syntax errors" run: "composer exec --no-interaction -- parallel-lint src/" - # @TODO Check template files for syntax errors unit_tests: name: "2️⃣ Unit and functional tests" @@ -187,16 +160,6 @@ jobs: - name: "Checkout repository" uses: "actions/checkout@v3" - - - name: "Check EditorConfig configuration" - run: "test -f .editorconfig" - - - name: "Check adherence to EditorConfig" - uses: "greut/eclint-action@v0" - - - name: "Look for TAB characters in the middle of the line 🐌" - run: | - ! git grep --perl-regexp --line-number -I '^(?!//)[^\t]+\t' - name: "Install dependencies" uses: "ramsey/composer-install@v2" @@ -213,52 +176,3 @@ jobs: name: "Annotate Pint results" if: "${{ failure() && steps.pint.outcome == 'failure' }}" run: "composer exec -- pint --test --format=checkstyle | cs2pr" - - - # Move TODO-s into GitHub issues! - name: "Search for TODO-s and FIXME-s 🐌" - run: | - ! git grep --extended-regexp --ignore-case '\b(TODO|FIXME)\b' -- ':!:*/back-end\.yml' - - - name: "Remove blank first lines and multiple blank lines 🐌" - run: | - git ls-files --cached -z -- ':(exclude,glob)**/yarn.lock' \ - | xargs --null -L 1 -- sed -i -e '/./,$!d' -e '/^$/N;/^\n$/D' - - - name: "Check differences to repository" - run: "git diff --exit-code" - - exported_files: - name: "5️⃣ Exported files" - needs: - - "byte_level" - - "syntax_errors" - runs-on: "ubuntu-22.04" - timeout-minutes: 1 - steps: - - - name: "Checkout repository" - uses: "actions/checkout@v3" - - - name: "Check for ignored files in the index 🐌" - run: | - IGNORED_FILES="$(git ls-files --cached --ignored --exclude-standard)" - test -z "${IGNORED_FILES}" - - - name: "Check exported files" - run: | - EXPECTED="LICENSE,README.md,composer.json,package.json" - CURRENT="$( - git archive HEAD \ - | tar --list --exclude="src" --exclude="src/*" \ - --exclude="config" --exclude="config/*" \ - --exclude="database" --exclude="database/*" \ - --exclude="public" --exclude="public/*" \ - --exclude="resources" --exclude="resources/*" \ - --exclude="routes" --exclude="routes/*" \ - --exclude="src" --exclude="src/*" \ - --exclude="stubs" --exclude="stubs/*" \ - | paste --serial --delimiters="," - )" - echo "CURRENT =${CURRENT}" - echo "EXPECTED=${EXPECTED}" - test "${CURRENT}" = "${EXPECTED}" diff --git a/.github/workflows/integrity.yml b/.github/workflows/integrity.yml new file mode 100644 index 000000000..df3f422af --- /dev/null +++ b/.github/workflows/integrity.yml @@ -0,0 +1,39 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow + +name: "Integrity" +# This workflow prevents earthquakes. + +on: + pull_request: null + push: + branches: + - "master" + +permissions: {} + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + +jobs: + call_workflow_integrity: + name: "Integrity" + uses: "./.github/workflows/reusable-integrity.yml" + with: + not-printable-ascii-paths: >- + src/ + resources/ + tests/ + export-excludes: >- + --exclude="config" --exclude="config/*" + --exclude="database" --exclude="database/*" + --exclude="public" --exclude="public/*" + --exclude="resources" --exclude="resources/*" + --exclude="routes" --exclude="routes/*" + --exclude="src" --exclude="src/*" + --exclude="stubs" --exclude="stubs/*" + exported-paths: >- + LICENSE + README.md + composer.json + package.json diff --git a/.github/workflows/reusable-integrity.yml b/.github/workflows/reusable-integrity.yml new file mode 100644 index 000000000..db9e14049 --- /dev/null +++ b/.github/workflows/reusable-integrity.yml @@ -0,0 +1,168 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow + +name: "Shared Integrity" +# This action prevents earthquakes. + +on: + workflow_call: + inputs: + executables: + description: "List of executable files" + type: "string" + default: "" + required: false + not-printable-ascii-paths: + description: "Paths to be searched for characters outside the printable ASCII range" + type: "string" + default: "src/ tests/" + required: false + export-excludes: + description: "List of the expected exported directories" + type: "string" + default: "--exclude='src' --exclude='src/*'" + required: false + exported-paths: + description: "List of the expected exported files" + type: "string" + default: "LICENSE README.md composer.json" + required: false + +permissions: {} + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}-reusable-integrity" + cancel-in-progress: true + +jobs: + file: + name: "File" + runs-on: "ubuntu-22.04" + timeout-minutes: 1 + steps: + - + name: "Checkout repository" + uses: "actions/checkout@v3" + - + name: "Check file permissions" + run: | + test "$( + git ls-files --stage \ + | grep -v '^100644' \ + | cut -c '51-' + )" = "${{ inputs.executables }}" + - + # https://github.com/greut/eclint/issues/6 + name: "Check for byte order mark (BOM)" + run: | + ! git grep --perl-regexp -I -e '^\xEF\xBB\xBF' + - + # https://html.spec.whatwg.org/multipage/named-characters.html + name: "Search for characters outside the printable ASCII range" + run: | + ! LC_ALL=C.UTF-8 git grep --perl-regexp --line-number -I -e '[^ -~]' \ + -- ${{ inputs.not-printable-ascii-paths }} + - + name: "Check EditorConfig configuration" + run: "test -f .editorconfig" + - + name: "Check adherence to EditorConfig" + uses: "greut/eclint-action@v0" + - + name: "Look for TAB characters in the middle of the line 🐌" + run: | + ! git grep --perl-regexp --line-number -I -e '^(?!//)[^\t]+\t' + - + name: "Look for multiple space characters in the middle of the line 🐌" + run: | + # Exclude docblocks: grep -v -F ' * @' + ! git grep --perl-regexp --line-number -I -e '(?!^#)\S\s\s' \ + -- ':!:*.md' ':!:.github/**.yml' + - + # Move TODO-s into GitHub issues! + name: "Search for TODO-s and FIXME-s 🐌" + run: | + ! git grep --extended-regexp --ignore-case -I -e '\b(TODO|FIXME)\b' \ + -- ':!:.github/workflows/reusable-integrity.yml' ':!:.github/workflows/back-end.yml' + - + name: "Remove blank first lines and multiple blank lines 🐌" + run: | + # Exclude binary files, empty files and ones with linguist-generated attribute set + git grep --files-with-matches -I -e '.' \ + | git check-attr --stdin --all \ + | sed -n -e 's#^\(.\+\): linguist-generated: set$#":!:\1"#p' \ + | xargs -L 1 -- git ls-files --cached -z -- \ + | xargs --null -n 1 -- sed -i -e '/./,$!d' -e '/^$/N;/^\n$/D' + - + name: "Check differences to repository" + run: "git diff --exit-code" + + cloc: + name: "Lines of Code" + runs-on: "ubuntu-22.04" + timeout-minutes: 1 + steps: + - + name: "Checkout repository" + uses: "actions/checkout@v3" + - + name: "Count Lines of Code" + env: + GH_TOKEN: "${{ github.token }}" + run: | + mkdir -p "${{ runner.temp }}/cloc" + RELEASE_ASSET_URL="$( + # v1.98 + gh api /repos/AlDanial/cloc/releases/117882376 \ + --jq '."assets"[] | select(."name" | test("^cloc-.+\\.pl$")) | ."browser_download_url"' + )" + wget --secure-protocol=TLSv1_3 --max-redirect=1 --retry-on-host-error --retry-connrefused --tries=3 \ + --no-verbose --output-document="${{ runner.temp }}/cloc/cloc" "${RELEASE_ASSET_URL}" + { + git ls-files -- ':!:LICENSE' ':!:package-lock.json' >"${{ runner.temp }}/cloc/include-list" + echo '```' + perl "${{ runner.temp }}/cloc/cloc" --hide-rate \ + --list-file="${{ runner.temp }}/cloc/include-list" \ + --ignored="${{ runner.temp }}/cloc/.clocignored" + cat "${{ runner.temp }}/cloc/.clocignored" + echo '```' + } >>"${GITHUB_STEP_SUMMARY}" + + commit: + name: "Commit" + runs-on: "ubuntu-22.04" + timeout-minutes: 1 + steps: + - + name: "Checkout repository" + uses: "actions/checkout@v3" + - + name: "Search for conflict markers 🐌" + run: | + ! git grep --line-number -e '^\(<<<<<<<\s\|=======\s\|=======$\|>>>>>>>\s\||||||||\s\)' + + git_archive: + name: "Git archive" + runs-on: "ubuntu-22.04" + timeout-minutes: 1 + steps: + - + name: "Checkout repository" + uses: "actions/checkout@v3" + - + name: "Check for ignored files in the index 🐌" + run: | + # Add negated files: ':!:path/to/negated' + IGNORED_FILES="$(git ls-files --cached --ignored --exclude-standard)" + test -z "${IGNORED_FILES}" + - + name: "Check exported files" + run: | + EXPECTED="${{ inputs.exported-paths }}" + CURRENT="$( + git archive HEAD \ + | tar --list ${{ inputs.export-excludes }} \ + | paste --serial --delimiters=" " + )" + echo "CURRENT =${CURRENT}" + echo "EXPECTED=${EXPECTED}" + test "${CURRENT}" = "${EXPECTED}" diff --git a/.github/workflows/spelling.yml b/.github/workflows/spelling.yml index d7a738a8c..b09903638 100644 --- a/.github/workflows/spelling.yml +++ b/.github/workflows/spelling.yml @@ -2,7 +2,7 @@ name: "Spelling" -on: # yamllint disable-line rule:truthy +on: pull_request: null push: branches: From 135b43506a9899edd68889b92ab8b993faac4132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Mon, 25 Sep 2023 18:55:58 +0000 Subject: [PATCH 2/9] Fix CI --- .github/workflows/back-end.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/back-end.yml b/.github/workflows/back-end.yml index 969711d82..44029af51 100644 --- a/.github/workflows/back-end.yml +++ b/.github/workflows/back-end.yml @@ -44,7 +44,6 @@ jobs: unit_tests: name: "2️⃣ Unit and functional tests" needs: - - "byte_level" - "syntax_errors" strategy: fail-fast: false @@ -100,7 +99,6 @@ jobs: static_analysis: name: "3️⃣ Static Analysis" needs: - - "byte_level" - "syntax_errors" runs-on: "ubuntu-22.04" timeout-minutes: 5 @@ -144,7 +142,6 @@ jobs: coding_standards: name: "4️⃣ Coding Standards" needs: - - "byte_level" - "syntax_errors" runs-on: "ubuntu-22.04" timeout-minutes: 5 From e7da8ae642305db61514f290937242030ab8a1d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Mon, 25 Sep 2023 18:58:37 +0000 Subject: [PATCH 3/9] Replace TAB characters --- resources/sass/config/_dark-colors.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/sass/config/_dark-colors.scss b/resources/sass/config/_dark-colors.scss index 1d48f9f7c..6f332e625 100644 --- a/resources/sass/config/_dark-colors.scss +++ b/resources/sass/config/_dark-colors.scss @@ -138,8 +138,8 @@ $colors: ( ), 'scrollbar': ( 'thumb-background': hsl(0 0% 100% / 15%), - 'thumb-background-hover': hsl(0 0% 100% / 25%), - 'track-background': hsl(0 0% 100% / 5%), + 'thumb-background-hover': hsl(0 0% 100% / 25%), + 'track-background': hsl(0 0% 100% / 5%), ), 'widget': ( 'icon-background': color.adjust($dark-color-black, $lightness: 5%), From e6185aa0270d1ba15a5e55049df11eb791c07a26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Mon, 25 Sep 2023 18:59:52 +0000 Subject: [PATCH 4/9] Fix CS --- src/Console/Commands/ResourceMake.php | 1 - src/RootApplicationServiceProvider.php | 1 - src/Widgets/Metric.php | 1 - 3 files changed, 3 deletions(-) diff --git a/src/Console/Commands/ResourceMake.php b/src/Console/Commands/ResourceMake.php index 5ee57d674..2ac24db80 100644 --- a/src/Console/Commands/ResourceMake.php +++ b/src/Console/Commands/ResourceMake.php @@ -3,7 +3,6 @@ namespace Cone\Root\Console\Commands; use Illuminate\Console\GeneratorCommand; -use Illuminate\Support\Str; use Symfony\Component\Console\Input\InputOption; class ResourceMake extends GeneratorCommand diff --git a/src/RootApplicationServiceProvider.php b/src/RootApplicationServiceProvider.php index 86b34d2cc..77fc45395 100644 --- a/src/RootApplicationServiceProvider.php +++ b/src/RootApplicationServiceProvider.php @@ -2,7 +2,6 @@ namespace Cone\Root; -use Illuminate\Routing\Router; use Illuminate\Support\Facades\Gate; use Illuminate\Support\ServiceProvider; diff --git a/src/Widgets/Metric.php b/src/Widgets/Metric.php index cd3089263..e55fa137f 100644 --- a/src/Widgets/Metric.php +++ b/src/Widgets/Metric.php @@ -4,7 +4,6 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\App; -use Illuminate\Support\Facades\Redis; abstract class Metric extends Widget { From 6abbeebef8a41157d54e40781deb797ee1388a23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Mon, 25 Sep 2023 19:03:02 +0000 Subject: [PATCH 5/9] Allow longer lines --- .editorconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index 75084693c..dc54cdef4 100644 --- a/.editorconfig +++ b/.editorconfig @@ -13,7 +13,7 @@ block_comment = * block_comment_end = */ [{*.php,*.js,*.scss}] -max_line_length = 120 +max_line_length = 160 [*.blade.php] max_line_length = 3000 From 44266a037d18915658b70e97c7329a2a56e408f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Mon, 25 Sep 2023 19:38:27 +0000 Subject: [PATCH 6/9] Fix double space search --- .github/workflows/reusable-integrity.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/reusable-integrity.yml b/.github/workflows/reusable-integrity.yml index db9e14049..baf509ade 100644 --- a/.github/workflows/reusable-integrity.yml +++ b/.github/workflows/reusable-integrity.yml @@ -74,9 +74,10 @@ jobs: - name: "Look for multiple space characters in the middle of the line 🐌" run: | - # Exclude docblocks: grep -v -F ' * @' - ! git grep --perl-regexp --line-number -I -e '(?!^#)\S\s\s' \ - -- ':!:*.md' ':!:.github/**.yml' + # Exclude docblocks + ! git grep --perl-regexp --line-number -I \ + -e '(?!^#)\S\s\s' --and --not -e ' \* @' \ + -- ':!:*.lock' ':!:*.md' ':!:.github/**.yml' - # Move TODO-s into GitHub issues! name: "Search for TODO-s and FIXME-s 🐌" From 79e25d3df9080148cb23111134bb80ab6bfdb3ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Mon, 25 Sep 2023 19:42:19 +0000 Subject: [PATCH 7/9] Fix CI --- .github/workflows/reusable-integrity.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-integrity.yml b/.github/workflows/reusable-integrity.yml index baf509ade..aa400312c 100644 --- a/.github/workflows/reusable-integrity.yml +++ b/.github/workflows/reusable-integrity.yml @@ -77,7 +77,7 @@ jobs: # Exclude docblocks ! git grep --perl-regexp --line-number -I \ -e '(?!^#)\S\s\s' --and --not -e ' \* @' \ - -- ':!:*.lock' ':!:*.md' ':!:.github/**.yml' + -- ':!:*.lock' ':!:*.md' ':!:.github/**.yml' ':!:public/build/' - # Move TODO-s into GitHub issues! name: "Search for TODO-s and FIXME-s 🐌" From e81265c14bcaf2f69835b2525ad6a824949b1cc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Mon, 25 Sep 2023 19:48:55 +0000 Subject: [PATCH 8/9] Fix blank line search --- .github/workflows/reusable-integrity.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-integrity.yml b/.github/workflows/reusable-integrity.yml index aa400312c..3a2a06f88 100644 --- a/.github/workflows/reusable-integrity.yml +++ b/.github/workflows/reusable-integrity.yml @@ -91,7 +91,7 @@ jobs: git grep --files-with-matches -I -e '.' \ | git check-attr --stdin --all \ | sed -n -e 's#^\(.\+\): linguist-generated: set$#":!:\1"#p' \ - | xargs -L 1 -- git ls-files --cached -z -- \ + | xargs -- git ls-files --cached -z -- \ | xargs --null -n 1 -- sed -i -e '/./,$!d' -e '/^$/N;/^\n$/D' - name: "Check differences to repository" From b08e795cb43aa588a1d94a2731d22c3e76c66571 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Mon, 25 Sep 2023 20:14:25 +0000 Subject: [PATCH 9/9] Check tests for syntax errors --- .github/workflows/back-end.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/back-end.yml b/.github/workflows/back-end.yml index 44029af51..bbf0080db 100644 --- a/.github/workflows/back-end.yml +++ b/.github/workflows/back-end.yml @@ -39,7 +39,7 @@ jobs: ! git grep -e '\${[A-Z_a-z]' -- '*.php' '*.scss' - name: "Check source code for syntax errors" - run: "composer exec --no-interaction -- parallel-lint src/" + run: "composer exec --no-interaction -- parallel-lint src/ tests/" unit_tests: name: "2️⃣ Unit and functional tests"