Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
cbarbian-sap committed Aug 21, 2023
1 parent 4ffe531 commit 9145032
Show file tree
Hide file tree
Showing 30 changed files with 21,415 additions and 61 deletions.
42 changes: 42 additions & 0 deletions .github/actions/check-go-license-boilerplate/action.yaml
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
45 changes: 45 additions & 0 deletions .github/actions/check-go-license-headers/action.yaml
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
8 changes: 8 additions & 0 deletions .github/actions/get-highest-tag/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.idea
*.swp
*.swo
*~

.DS_Store

node_modules
7 changes: 7 additions & 0 deletions .github/actions/get-highest-tag/Makefile
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



14 changes: 14 additions & 0 deletions .github/actions/get-highest-tag/action.yaml
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
Loading

0 comments on commit 9145032

Please sign in to comment.