-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#275: Update copyright year and GHA to check year #282
Merged
Merged
Changes from 14 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
064cac5
feat(objectionary#275): add copyright check script
slry cf528ac
feat(objectionary#275): add gha workflow
slry 833abc7
fix: shellcheck error
slry 8fba74c
fix: update copyright year
slry 55f9091
raefactor: remove check_copyright.sh, embed into workflow yaml file
slry 2f13a59
refactor: adjust line-length for yamllint in copyright_check.yml
slry a3459ab
revert: test_mvnw.js
slry f845c19
Merge branch 'master' of https://github.com/slry/eoc into 275_copyright
slry 4ae63d9
feat: skip macos and node12
slry 3af218d
fix: proper syntax
slry a22fbcd
feat: node 12 -> 14 in itest.yml
slry b8dda45
feat: skip macos and node14
slry de73272
fix: windows powershell command
slry 8943c0b
fix: add shell pwsh to fix actionlint error
slry 3fb53c6
Merge branch 'master' into 275_copyright
slry 5e4fe16
fix(objectionary#275): copyright_check script
slry a5dd1c8
fix(objectionary#275): shellcheck error
slry 01d1e9a
fix(objectionary#275): replace regex with grep
slry File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
|
||
name: copyright | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
copyright: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- 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 | ||
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." | ||
|
||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,10 @@ jobs: | |
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
java: [11, 18] | ||
node: [12, 16] | ||
node: [14, 16] | ||
exclude: | ||
- os: macos-latest | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @slry even Node 14 is not supported on MacOS? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @maxonfjvipon I have tested it, unfortunately its not... |
||
node: 14 | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
@@ -56,3 +59,15 @@ 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 | ||
shell: pwsh | ||
if: ${{ matrix.os == 'windows-latest' }} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@slry I can't understand, why do you need to run Bash script through this
SCRIPT
file? can't you just directly use the text?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yegor256 this script just do not work in yaml for some reason, so this is a workaround I found
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@slry it's a weird workaround. I suggest you try to make it work as all other scripts.