Skip to content

Commit

Permalink
Add make-reusable-integrity (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
szepeviktor authored Oct 21, 2023
1 parent 2beb53a commit 7c1000a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/integrity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@ jobs:
name: "Integrity"
uses: "./.github/workflows/reusable-integrity.yml"
with:
executables: >-
bin/make-reusable-integrity.sh
not-printable-ascii-paths: >-
src/
resources/
tests/
export-excludes: >-
--exclude="bin" --exclude="bin/*"
--exclude="src" --exclude="src/*"
--exclude="resources" --exclude="resources/*"
exported-paths: >-
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@
# Tests

# Distribution
reusable-integrity.sh
35 changes: 35 additions & 0 deletions bin/make-reusable-integrity.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
#
# Convert reusable-integrity.yml to a shell script
#

SOURCE="./.github/workflows/reusable-integrity.yml"
TARGET="reusable-integrity.sh"

test -f "${SOURCE}"

cat <<"EOF" >"${TARGET}"
#!/bin/bash -x
set -e
export GIT_PAGER=""
mkdir -p ./tmp
GITHUB_STEP_SUMMARY="./tmp/github-summary.md"
EOF

yq -r '."jobs".*."steps"[] | select(."run") | ."run"' "${SOURCE}" >>"${TARGET}"

DEFAULT_VALUE="$(yq -r '."on"."workflow_call"."inputs"."executables"."default"' "${SOURCE}")"
sed -i -e "s#\${{ inputs\.executables }}#${DEFAULT_VALUE}#g" "${TARGET}"
DEFAULT_VALUE="$(yq -r '."on"."workflow_call"."inputs"."not-printable-ascii-paths"."default"' "${SOURCE}")"
sed -i -e "s#\${{ inputs\.not-printable-ascii-paths }}#${DEFAULT_VALUE}#g" "${TARGET}"
DEFAULT_VALUE="$(yq -r '."on"."workflow_call"."inputs"."export-excludes"."default"' "${SOURCE}")"
sed -i -e "s#\${{ inputs\.export-excludes }}#${DEFAULT_VALUE}#g" "${TARGET}"
DEFAULT_VALUE="$(yq -r '."on"."workflow_call"."inputs"."exported-paths"."default"' "${SOURCE}")"
sed -i -e "s#\${{ inputs\.exported-paths }}#${DEFAULT_VALUE}#g" "${TARGET}"

sed -i -e "s#\${{ runner\.temp }}#./tmp#g" "${TARGET}"
sed -i -e "s#test -f \.editorconfig#&\\neclint#g" "${TARGET}"

chmod +x "${TARGET}"
echo "OK."

0 comments on commit 7c1000a

Please sign in to comment.