From 064cac5a55abac18087744a1163fb4c8acb38854 Mon Sep 17 00:00:00 2001 From: Vyacheslav Rybalchenko Date: Thu, 2 May 2024 21:17:38 +0300 Subject: [PATCH 01/16] feat(objectionary#275): add copyright check script --- check_copyright.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 check_copyright.sh diff --git a/check_copyright.sh b/check_copyright.sh new file mode 100644 index 0000000..dbd423c --- /dev/null +++ b/check_copyright.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +# Get the current year +current_year=$(date +"%Y") + +# Ignore files and directories +ignore_files="(.git|node_modules|build|dist|temp|check_copyright.sh)" + +# Directory to search; default is current directory, customize as needed +search_dir="." + +# Pattern to look for: 'Copyright (c)' +pattern="Copyright (c)" + +exit_code=0 + +# Find files containing the copyright notice +echo "Checking files in $search_dir for outdated copyright years..." +echo "Current year is $current_year." + +# Use find to iterate over files, redirecting into while loop to avoid subshell +find $search_dir -type f -print0 > tmp.$$ || exit 1 +while IFS= read -r -d $'\0' file; do + # Skip files in the ignore list + if [[ "$file" =~ $ignore_files ]]; then + continue + fi + + # Use grep to find the line and awk to extract the year + year_line=$(grep "$pattern" "$file") + + if [[ -n "$year_line" ]]; then + # Extract year assuming the year is after 'Copyright (c)' + year=$(echo "$year_line" | grep -E -oh "[0-9]{4}-[0-9]{4}") + year=$(echo $year | awk -F'-' '{print $2}') + + # Check if the extracted year is not equal to the current year + if [[ "$year" -ne "$current_year" ]]; then + echo "Outdated copyright year ($year) in file: $file" + exit_code=1 + fi + fi +done < tmp.$$ +rm tmp.$$ # Clean up temporary file + +echo "Check complete." +exit $exit_code + From cf528ac2ad19f00ef1aa9de2d9cb5b0bfd4f3360 Mon Sep 17 00:00:00 2001 From: Vyacheslav Rybalchenko Date: Thu, 2 May 2024 21:18:03 +0300 Subject: [PATCH 02/16] feat(objectionary#275): add gha workflow --- .github/workflows/copyright_check.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/copyright_check.yml diff --git a/.github/workflows/copyright_check.yml b/.github/workflows/copyright_check.yml new file mode 100644 index 0000000..dc47e30 --- /dev/null +++ b/.github/workflows/copyright_check.yml @@ -0,0 +1,17 @@ +--- + +name: copyright +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + copyright: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - run: /bin/bash check_copyright.sh From 833abc739760b03838ec1ad2243f574d753aba14 Mon Sep 17 00:00:00 2001 From: Vyacheslav Rybalchenko Date: Thu, 2 May 2024 21:19:34 +0300 Subject: [PATCH 03/16] fix: shellcheck error --- check_copyright.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_copyright.sh b/check_copyright.sh index dbd423c..915a619 100644 --- a/check_copyright.sh +++ b/check_copyright.sh @@ -32,7 +32,7 @@ while IFS= read -r -d $'\0' file; do if [[ -n "$year_line" ]]; then # Extract year assuming the year is after 'Copyright (c)' year=$(echo "$year_line" | grep -E -oh "[0-9]{4}-[0-9]{4}") - year=$(echo $year | awk -F'-' '{print $2}') + year=$(echo "$year" | awk -F'-' '{print $2}') # Check if the extracted year is not equal to the current year if [[ "$year" -ne "$current_year" ]]; then From 8fba74ce4d8af86bf1765509105fc10d5064866b Mon Sep 17 00:00:00 2001 From: Vyacheslav Rybalchenko Date: Thu, 2 May 2024 21:24:54 +0300 Subject: [PATCH 04/16] fix: update copyright year --- test/test_mvnw.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/test_mvnw.js b/test/test_mvnw.js index fdea4fb..b230230 100644 --- a/test/test_mvnw.js +++ b/test/test_mvnw.js @@ -22,12 +22,12 @@ * SOFTWARE. */ -const {mvnw} = require('../src/mvnw'); +const { mvnw } = require("../src/mvnw"); -describe('mvnw', function() { - it('prints Maven own version', function(done) { - const opts = {batch: true}; - mvnw(['--version', '--quiet'], null, opts.batch); +describe("mvnw", function() { + it("prints Maven own version", function(done) { + const opts = { batch: true }; + mvnw(["--version", "--quiet"], null, opts.batch); done(); }); }); From 55f90912bc29ebdc8f6a0c77f9a20c9dedc22038 Mon Sep 17 00:00:00 2001 From: Vyacheslav Rybalchenko Date: Mon, 13 May 2024 18:09:38 +0300 Subject: [PATCH 05/16] raefactor: remove check_copyright.sh, embed into workflow yaml file --- .github/workflows/copyright_check.yml | 51 ++++++++++++++++++++++++++- check_copyright.sh | 48 ------------------------- 2 files changed, 50 insertions(+), 49 deletions(-) delete mode 100644 check_copyright.sh diff --git a/.github/workflows/copyright_check.yml b/.github/workflows/copyright_check.yml index dc47e30..97e380a 100644 --- a/.github/workflows/copyright_check.yml +++ b/.github/workflows/copyright_check.yml @@ -14,4 +14,53 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - - run: /bin/bash check_copyright.sh + - name: Run check + run: | + bash - << 'SCRIPT' + + # Get the current year + current_year=$(date +"%Y") + + # Ignore files and directories + ignore_files="(.git|node_modules|build|dist|temp|check_copyright.sh)" + + # Directory to search; default is current directory, customize as needed + search_dir="." + + # Pattern to look for: 'Copyright (c)' + pattern="Copyright (c)" + + exit_code=0 + + # Find files containing the copyright notice + echo "Checking files in $search_dir for outdated copyright years..." + echo "Current year is $current_year." + + # Use find to iterate over files, redirecting into while loop to avoid subshell + find $search_dir -type f -print0 > tmp.$$ || exit 1 + while IFS= read -r -d $'\0' file; do + # Skip files in the ignore list + if [[ "$file" =~ $ignore_files ]]; then + continue + fi + + # Use grep to find the line and awk to extract the year + year_line=$(grep "$pattern" "$file") + + if [[ -n "$year_line" ]]; then + # Extract year assuming the year is after 'Copyright (c)' + year=$(echo "$year_line" | grep -E -oh "[0-9]{4}-[0-9]{4}") + year=$(echo "$year" | awk -F'-' '{print $2}') + + # Check if the extracted year is not equal to the current year + if [[ "$year" -ne "$current_year" ]]; then + echo "Outdated copyright year ($year) in file: $file" + exit_code=1 + fi + fi + done < tmp.$$ + rm tmp.$$ # Clean up temporary file + + echo "Check complete." + exit $exit_code + SCRIPT diff --git a/check_copyright.sh b/check_copyright.sh deleted file mode 100644 index 915a619..0000000 --- a/check_copyright.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash - -# Get the current year -current_year=$(date +"%Y") - -# Ignore files and directories -ignore_files="(.git|node_modules|build|dist|temp|check_copyright.sh)" - -# Directory to search; default is current directory, customize as needed -search_dir="." - -# Pattern to look for: 'Copyright (c)' -pattern="Copyright (c)" - -exit_code=0 - -# Find files containing the copyright notice -echo "Checking files in $search_dir for outdated copyright years..." -echo "Current year is $current_year." - -# Use find to iterate over files, redirecting into while loop to avoid subshell -find $search_dir -type f -print0 > tmp.$$ || exit 1 -while IFS= read -r -d $'\0' file; do - # Skip files in the ignore list - if [[ "$file" =~ $ignore_files ]]; then - continue - fi - - # Use grep to find the line and awk to extract the year - year_line=$(grep "$pattern" "$file") - - if [[ -n "$year_line" ]]; then - # Extract year assuming the year is after 'Copyright (c)' - year=$(echo "$year_line" | grep -E -oh "[0-9]{4}-[0-9]{4}") - year=$(echo "$year" | awk -F'-' '{print $2}') - - # Check if the extracted year is not equal to the current year - if [[ "$year" -ne "$current_year" ]]; then - echo "Outdated copyright year ($year) in file: $file" - exit_code=1 - fi - fi -done < tmp.$$ -rm tmp.$$ # Clean up temporary file - -echo "Check complete." -exit $exit_code - From 2f13a594731299b94380b6423a1bf2d3229df824 Mon Sep 17 00:00:00 2001 From: Vyacheslav Rybalchenko Date: Mon, 13 May 2024 18:12:53 +0300 Subject: [PATCH 06/16] refactor: adjust line-length for yamllint in copyright_check.yml --- .github/workflows/copyright_check.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/copyright_check.yml b/.github/workflows/copyright_check.yml index 97e380a..acdcad2 100644 --- a/.github/workflows/copyright_check.yml +++ b/.github/workflows/copyright_check.yml @@ -24,7 +24,7 @@ jobs: # Ignore files and directories ignore_files="(.git|node_modules|build|dist|temp|check_copyright.sh)" - # Directory to search; default is current directory, customize as needed + # Directory to search search_dir="." # Pattern to look for: 'Copyright (c)' @@ -36,7 +36,7 @@ jobs: echo "Checking files in $search_dir for outdated copyright years..." echo "Current year is $current_year." - # Use find to iterate over files, redirecting into while loop to avoid subshell + # Iterate over files, redirecting into while loop to avoid subshell find $search_dir -type f -print0 > tmp.$$ || exit 1 while IFS= read -r -d $'\0' file; do # Skip files in the ignore list From a3459ab4fc1dc8c4878dbb36d2bba81d363e522b Mon Sep 17 00:00:00 2001 From: Vyacheslav Rybalchenko Date: Tue, 28 May 2024 12:26:52 +0300 Subject: [PATCH 07/16] revert: test_mvnw.js --- test/test_mvnw.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/test_mvnw.js b/test/test_mvnw.js index b230230..fdea4fb 100644 --- a/test/test_mvnw.js +++ b/test/test_mvnw.js @@ -22,12 +22,12 @@ * SOFTWARE. */ -const { mvnw } = require("../src/mvnw"); +const {mvnw} = require('../src/mvnw'); -describe("mvnw", function() { - it("prints Maven own version", function(done) { - const opts = { batch: true }; - mvnw(["--version", "--quiet"], null, opts.batch); +describe('mvnw', function() { + it('prints Maven own version', function(done) { + const opts = {batch: true}; + mvnw(['--version', '--quiet'], null, opts.batch); done(); }); }); From 4ae63d98f65cb0f192b49e36221c048e0716b7bc Mon Sep 17 00:00:00 2001 From: Vyacheslav Rybalchenko Date: Tue, 28 May 2024 15:53:48 +0300 Subject: [PATCH 08/16] feat: skip macos and node12 --- .github/workflows/itest.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/itest.yml b/.github/workflows/itest.yml index fca555a..935c65e 100644 --- a/.github/workflows/itest.yml +++ b/.github/workflows/itest.yml @@ -35,6 +35,7 @@ jobs: java: [11, 18] node: [12, 16] runs-on: ${{ matrix.os }} + if: ${{ matrix.os != 'macos-latest' || matrix.node != 12 }} steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 From 3af218dfdccc0b5f1d5b4c978ce52a1f662c13fe Mon Sep 17 00:00:00 2001 From: Vyacheslav Rybalchenko Date: Tue, 28 May 2024 15:58:19 +0300 Subject: [PATCH 09/16] fix: proper syntax --- .github/workflows/itest.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/itest.yml b/.github/workflows/itest.yml index 935c65e..0480d67 100644 --- a/.github/workflows/itest.yml +++ b/.github/workflows/itest.yml @@ -34,8 +34,10 @@ jobs: os: [ubuntu-latest, macos-latest, windows-latest] java: [11, 18] node: [12, 16] + exclude: + - os: macos-latest + node: 12 runs-on: ${{ matrix.os }} - if: ${{ matrix.os != 'macos-latest' || matrix.node != 12 }} steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 From a22fbcdd60c10e1c0050f5276428628a0e3db017 Mon Sep 17 00:00:00 2001 From: Vyacheslav Rybalchenko Date: Tue, 28 May 2024 16:23:31 +0300 Subject: [PATCH 10/16] feat: node 12 -> 14 in itest.yml --- .github/workflows/itest.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/itest.yml b/.github/workflows/itest.yml index 0480d67..3037acc 100644 --- a/.github/workflows/itest.yml +++ b/.github/workflows/itest.yml @@ -33,10 +33,7 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] java: [11, 18] - node: [12, 16] - exclude: - - os: macos-latest - node: 12 + node: [14, 16] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 From b8dda45cd07e14ffd9ac035ad277b2d44e584f8c Mon Sep 17 00:00:00 2001 From: Vyacheslav Rybalchenko Date: Tue, 28 May 2024 16:25:03 +0300 Subject: [PATCH 11/16] feat: skip macos and node14 --- .github/workflows/itest.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/itest.yml b/.github/workflows/itest.yml index 3037acc..26f3252 100644 --- a/.github/workflows/itest.yml +++ b/.github/workflows/itest.yml @@ -34,6 +34,9 @@ jobs: os: [ubuntu-latest, macos-latest, windows-latest] java: [11, 18] node: [14, 16] + exclude: + - os: macos-latest + node: 14 runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 From de7327211b100638b83b76034c7d4b1122ec6289 Mon Sep 17 00:00:00 2001 From: Vyacheslav Rybalchenko Date: Tue, 28 May 2024 16:59:25 +0300 Subject: [PATCH 12/16] fix: windows powershell command --- .github/workflows/itest.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/itest.yml b/.github/workflows/itest.yml index 26f3252..3dde374 100644 --- a/.github/workflows/itest.yml +++ b/.github/workflows/itest.yml @@ -59,3 +59,14 @@ jobs: node ../src/eoc.js clean node ../src/eoc.js "--parser=$p" "--home-tag=$t" --batch \ test + if: ${{ matrix.os != 'windows-latest' }} + - run: | + cd itest + node ../src/eoc.js "--parser=0.36.0" "--home-tag=0.36.0" --batch ` + dataize program + node ../src/eoc.js "--parser=0.36.0" "--home-tag=0.36.0" --alone ` + --batch dataize program + node ../src/eoc.js clean + node ../src/eoc.js "--parser=0.36.0" "--home-tag=0.36.0" --batch ` + test + if: ${{ matrix.os == 'windows-latest' }} From 8943c0bd25231cfbba6899bda2ce6772576c16e3 Mon Sep 17 00:00:00 2001 From: Vyacheslav Rybalchenko Date: Tue, 28 May 2024 17:18:57 +0300 Subject: [PATCH 13/16] fix: add shell pwsh to fix actionlint error --- .github/workflows/itest.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/itest.yml b/.github/workflows/itest.yml index 3dde374..71c4310 100644 --- a/.github/workflows/itest.yml +++ b/.github/workflows/itest.yml @@ -69,4 +69,5 @@ jobs: node ../src/eoc.js clean node ../src/eoc.js "--parser=0.36.0" "--home-tag=0.36.0" --batch ` test + shell: pwsh if: ${{ matrix.os == 'windows-latest' }} From 5e4fe1692faabdb8c9fb2414f0cf05395686abf3 Mon Sep 17 00:00:00 2001 From: Vyacheslav Rybalchenko Date: Mon, 10 Jun 2024 02:11:00 +0300 Subject: [PATCH 14/16] fix(objectionary#275): copyright_check script --- .github/workflows/copyright_check.yml | 67 +++++++++++++++++++-------- 1 file changed, 47 insertions(+), 20 deletions(-) diff --git a/.github/workflows/copyright_check.yml b/.github/workflows/copyright_check.yml index acdcad2..4c5ab9a 100644 --- a/.github/workflows/copyright_check.yml +++ b/.github/workflows/copyright_check.yml @@ -1,3 +1,24 @@ +# The MIT License (MIT) +# +# Copyright (c) 2022-2024 Objectionary.com +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. --- name: copyright @@ -15,14 +36,14 @@ jobs: steps: - uses: actions/checkout@v4 - name: Run check + shell: bash run: | - bash - << 'SCRIPT' - # Get the current year current_year=$(date +"%Y") # Ignore files and directories - ignore_files="(.git|node_modules|build|dist|temp|check_copyright.sh)" + ignore_files=("*/.git/*" "*/.github/workflows/copyright_check.yml" + "*/node_modules/*" "*/build/*" "*/dist/*" "*/temp/*") # Directory to search search_dir="." @@ -37,30 +58,36 @@ jobs: echo "Current year is $current_year." # Iterate over files, redirecting into while loop to avoid subshell - find $search_dir -type f -print0 > tmp.$$ || exit 1 - while IFS= read -r -d $'\0' file; do + find $search_dir -type f -print0 | while IFS= read -r -d $'\0' file; + do # Skip files in the ignore list - if [[ "$file" =~ $ignore_files ]]; then + skip_file=false + for ignore_pattern in "${ignore_files[@]}"; do + if [[ "$file" == $ignore_pattern ]]; then + skip_file=true + break + fi + done + if $skip_file; then continue fi # Use grep to find the line and awk to extract the year - year_line=$(grep "$pattern" "$file") + # If grep fails + if year_line=$(grep "$pattern" "$file"); then + if [[ -n "$year_line" ]]; then + # Extract year assuming the year is after 'Copyright (c)' + year=$(echo "$year_line" | grep -E -oh "[0-9]{4}-[0-9]{4}") + year=$(echo "$year" | awk -F'-' '{print $2}') - if [[ -n "$year_line" ]]; then - # Extract year assuming the year is after 'Copyright (c)' - year=$(echo "$year_line" | grep -E -oh "[0-9]{4}-[0-9]{4}") - year=$(echo "$year" | awk -F'-' '{print $2}') - - # Check if the extracted year is not equal to the current year - if [[ "$year" -ne "$current_year" ]]; then - echo "Outdated copyright year ($year) in file: $file" - exit_code=1 - fi + # Check if extracted year is not equal to the current year + if [[ "$year" -ne "$current_year" ]]; then + echo "Outdated copyright year ($year) in file: $file" + exit_code=1 + fi + fi fi - done < tmp.$$ - rm tmp.$$ # Clean up temporary file + done echo "Check complete." exit $exit_code - SCRIPT From a5dd1c86000b1bd68d4e2c7afac3c3df9f7173ff Mon Sep 17 00:00:00 2001 From: Vyacheslav Rybalchenko Date: Mon, 10 Jun 2024 02:27:56 +0300 Subject: [PATCH 15/16] fix(objectionary#275): shellcheck error --- .github/workflows/copyright_check.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/copyright_check.yml b/.github/workflows/copyright_check.yml index 4c5ab9a..d3e8930 100644 --- a/.github/workflows/copyright_check.yml +++ b/.github/workflows/copyright_check.yml @@ -58,11 +58,12 @@ jobs: echo "Current year is $current_year." # Iterate over files, redirecting into while loop to avoid subshell - find $search_dir -type f -print0 | while IFS= read -r -d $'\0' file; - do + find $search_dir -type f -print0 > tmp.$$ || exit 1 + while IFS= read -r -d $'\0' file; do # Skip files in the ignore list skip_file=false for ignore_pattern in "${ignore_files[@]}"; do + # shellcheck disable=SC2254 if [[ "$file" == $ignore_pattern ]]; then skip_file=true break @@ -87,7 +88,8 @@ jobs: fi fi fi - done + done < tmp.$$ + rm tmp.$$ # Clean up temporary file echo "Check complete." exit $exit_code From 01d1e9ae0e2a5b0135c12c3c4dc90080db98da43 Mon Sep 17 00:00:00 2001 From: Vyacheslav Rybalchenko Date: Mon, 10 Jun 2024 02:32:44 +0300 Subject: [PATCH 16/16] fix(objectionary#275): replace regex with grep --- .github/workflows/copyright_check.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/copyright_check.yml b/.github/workflows/copyright_check.yml index d3e8930..883eba1 100644 --- a/.github/workflows/copyright_check.yml +++ b/.github/workflows/copyright_check.yml @@ -63,8 +63,7 @@ jobs: # Skip files in the ignore list skip_file=false for ignore_pattern in "${ignore_files[@]}"; do - # shellcheck disable=SC2254 - if [[ "$file" == $ignore_pattern ]]; then + if echo "$file" | grep -qE "$ignore_pattern"; then skip_file=true break fi