generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4ffe531
commit 9145032
Showing
30 changed files
with
21,415 additions
and
61 deletions.
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,42 @@ | ||
name: Check Go license boilerplate | ||
description: Check license boilerplate used in Go files | ||
inputs: | ||
boilerplate-path: | ||
description: License boilerplate file path | ||
required: true | ||
boilerplate-content: | ||
description: License boilerplate content | ||
default: |- | ||
/* | ||
SPDX-FileCopyrightText: ${YEAR} SAP SE or an SAP affiliate company and ${REPOSITORY} contributors | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Check boilerplate file | ||
shell: bash | ||
env: | ||
INPUT_BOILERPLATE_PATH: ${{ inputs.boilerplate-path }} | ||
INPUT_BOILERPLATE_CONTENT: ${{ inputs.boilerplate-content }} | ||
run: | | ||
this_year=$(date +%Y) | ||
last_year=$((this_year-1)) | ||
repository=$(echo $GITHUB_REPOSITORY | cut -d/ -f2) | ||
tempdir=$(mktemp -d) | ||
trap 'rm -rf $tempdir' EXIT | ||
printenv INPUT_BOILERPLATE_CONTENT | YEAR=$this_year REPOSITORY=$repository envsubst > $tempdir/boilerplate-this-year | ||
printenv INPUT_BOILERPLATE_CONTENT | YEAR=$last_year REPOSITORY=$repository envsubst > $tempdir/boilerplate-last-year | ||
if diff -q $INPUT_BOILERPLATE_PATH $tempdir/boilerplate-this-year >/dev/null; then | ||
exit 0 | ||
fi | ||
if diff -q $INPUT_BOILERPLATE_PATH $tempdir/boilerplate-last-year >/dev/null; then | ||
>&1 echo "Warning: license boilerplate outdated ($last_year); next year, this will result in an error." | ||
exit 0 | ||
fi | ||
>&1 echo "Error: incorrect license boilerplate." | ||
exit 1 |
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,45 @@ | ||
name: Check Go license headers | ||
description: Check license headers of Go files | ||
inputs: | ||
base-path: | ||
description: Base directory | ||
default: . | ||
boilerplate-path: | ||
description: License header file path | ||
required: true | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Check files | ||
shell: ruby {0} | ||
env: | ||
INPUT_BASE_PATH: ${{ inputs.base-path }} | ||
INPUT_BOILERPLATE_PATH: ${{ inputs.boilerplate-path }} | ||
run: | | ||
base_path = ENV["INPUT_BASE_PATH"] | ||
raise "Input parameter base-path must not start with slash" if base_path.start_with?("/") | ||
raise "Input parameter base-path must not be empty" if base_path.empty? | ||
raise "Specified base-path does not exist: #{base_path}" if !Dir.exists?(base_path) | ||
boilerplate_path = ENV["INPUT_BOILERPLATE_PATH"] | ||
raise "Input parameter boilerplate-path must not start with slash" if boilerplate_path.start_with?("/") | ||
raise "Input parameter boilerplate-path must not be empty" if boilerplate_path.empty? | ||
boilerplate = File.readlines(boilerplate_path) | ||
errors = 0 | ||
Dir.glob("**/*.go").each do |p| | ||
file = File.readlines(p) | ||
file.each_with_index do |line,i| | ||
next if line =~ /^\/\/go:build/ | ||
next if line =~ /^\/\/\s*\+build/ | ||
next if line =~ /^\s*$/ | ||
if file[i,boilerplate.size] != boilerplate then | ||
STDERR.puts "#{p}: bad or missing license header" | ||
errors += 1 | ||
end | ||
break | ||
end | ||
end | ||
exit 1 if errors > 0 |
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,8 @@ | ||
.idea | ||
*.swp | ||
*.swo | ||
*~ | ||
|
||
.DS_Store | ||
|
||
node_modules |
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,7 @@ | ||
.PHONY: build | ||
build: | ||
npm ci | ||
ncc build src/index.js --license licenses.txt | ||
|
||
|
||
|
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,14 @@ | ||
name: Get highest tag | ||
description: Get highest semver tag in current repository | ||
inputs: | ||
prefix: | ||
description: Tag prefix (only tags with that prefix are considered) | ||
default: '' | ||
outputs: | ||
tag: | ||
description: Highest tag (according to semver ordering) | ||
version: | ||
description: Highest version (i.e. determined highest tag, stripped by prefix) | ||
runs: | ||
using: node16 | ||
main: dist/index.js |
Oops, something went wrong.