Skip to content

Commit

Permalink
update .github/actions
Browse files Browse the repository at this point in the history
  • Loading branch information
cbarbian-sap committed Jul 16, 2023
1 parent 054f565 commit f437a72
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 59 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
1 change: 1 addition & 0 deletions .github/actions/get-highest-tag/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ 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)
Expand Down
82 changes: 40 additions & 42 deletions .github/actions/setup-helm-docs/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,53 @@ description: Setup helm-docs
inputs:
version:
description: Version
required: true
default: latest
install-directory:
description: Target installation directory
required: false
default: '$HOME/.helm-docs/bin'
outputs:
path:
description: Path to the installed helm-docs executable
value: ${{ steps.install.outputs.path }}
runs:
using: "composite"
using: composite
steps:
- name: Install helm-docs
id: install
shell: bash
run: |
version=${{ inputs.version}}
install_directory=${{ inputs.install-directory }}
if [ "$version" == latest ]; then
version=$(curl -sSf https://github.com/gitapi/repos/norwoodj/helm-docs/releases/latest | jq -r .tag_name)
fi
version=${version/#v/}
case $(uname -s) in
Linux)
os=Linux
;;
*)
>&1 echo "Unsupported OS: $(uname -s)"
exit 1
;;
esac
case $(uname -m) in
arm64|aarch64)
arch=arm64
;;
x86_64|amd64)
arch=x86_64
;;
*)
>&1 echo "§Unsupported architecture: $(uname -m)"
exit 1
;;
esac
mkdir -p "$install_directory"
temp_directory=$(mktemp -d)
trap 'rm -rf $temp_directory' EXIT
curl -sSfL https://github.com/norwoodj/helm-docs/releases/download/v${version}/helm-docs_${version}_${os}_${arch}.tar.gz | tar xz -C $temp_directory
cp -f $temp_directory/helm-docs $install_directory
chmod a+x "$install_directory/helm-docs"
echo "$install_directory" >> $GITHUB_PATH
echo "path=$install_directory/helm-docs" >> $GITHUB_OUTPUT
- name: Install helm-docs
id: install
shell: bash
run: |
version=${{ inputs.version}}
install_directory=${{ inputs.install-directory }}
if [ "$version" == latest ]; then
version=$(curl -sSf https://github.com/gitapi/repos/norwoodj/helm-docs/releases/latest | jq -r .tag_name)
fi
version=${version/#v/}
case $(uname -s) in
Linux)
os=Linux
;;
*)
>&1 echo "Unsupported OS: $(uname -s)"
exit 1
;;
esac
case $(uname -m) in
arm64|aarch64)
arch=arm64
;;
x86_64|amd64)
arch=x86_64
;;
*)
>&1 echo "§Unsupported architecture: $(uname -m)"
exit 1
;;
esac
mkdir -p "$install_directory"
temp_directory=$(mktemp -d)
trap 'rm -rf $temp_directory' EXIT
curl -sSfL https://github.com/norwoodj/helm-docs/releases/download/v${version}/helm-docs_${version}_${os}_${arch}.tar.gz | tar xz -C $temp_directory
cp -f $temp_directory/helm-docs $install_directory
chmod a+x "$install_directory/helm-docs"
echo "$install_directory" >> $GITHUB_PATH
echo "path=$install_directory/helm-docs" >> $GITHUB_OUTPUT
32 changes: 15 additions & 17 deletions .github/actions/setup-semver/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,28 @@ description: Setup semver
inputs:
version:
description: Version
required: true
default: latest
install-directory:
description: Target installation directory
required: false
default: '$HOME/.semver/bin'
outputs:
path:
description: Path to the installed semver executable
value: ${{ steps.install.outputs.path }}
runs:
using: "composite"
using: composite
steps:
- name: Install semver
id: install
shell: bash
run: |
version=${{ inputs.version}}
install_directory=${{ inputs.install-directory }}
if [ "$version" == latest ]; then
version=master
fi
mkdir -p "$install_directory"
curl -sSf -L -o "$install_directory/semver" https://github.com/raw/fsaintjacques/semver-tool/$version/src/semver
chmod a+x "$install_directory/semver"
echo "$install_directory" >> $GITHUB_PATH
echo "path=$install_directory/semver" >> $GITHUB_OUTPUT
- name: Install semver
id: install
shell: bash
run: |
version=${{ inputs.version}}
install_directory=${{ inputs.install-directory }}
if [ "$version" == latest ]; then
version=master
fi
mkdir -p "$install_directory"
curl -sSf -L -o "$install_directory/semver" https://github.com/raw/fsaintjacques/semver-tool/$version/src/semver
chmod a+x "$install_directory/semver"
echo "$install_directory" >> $GITHUB_PATH
echo "path=$install_directory/semver" >> $GITHUB_OUTPUT

0 comments on commit f437a72

Please sign in to comment.