Skip to content

Commit

Permalink
add go cache
Browse files Browse the repository at this point in the history
  • Loading branch information
jgreat committed Apr 26, 2023
1 parent c2d7e64 commit f5dc11b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 44 deletions.
54 changes: 10 additions & 44 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ no_color='\033[0m'
bold_white='\033[1;37m'
red='\033[0;31m'
green='\033[0;32m'
yellow='\033[0;33m'

# Set default headers
header="${bold_white}[pre-commit]${no_color}"
ok="${green}[ OK ]${no_color}"
failed="${red}[ FAILED ]${no_color}"
skipped="${yellow}[ SKIPPED ]${no_color}"

# Check the results and print output if there are errors.
check_results()
Expand All @@ -32,9 +34,9 @@ error="false"
files=$(git diff --cached --name-only --diff-filter=ACM)

# Run shellcheck if installed
if which shellcheck >/dev/null 2>&1
echo -e -n "${header} Run shellcheck on files included in the commit "
if command -v shellcheck >/dev/null 2>&1
then
echo -e -n "${header} Run shellcheck on files included in the commit "

out=""
for f in ${files}
Expand All @@ -51,10 +53,12 @@ then

# check for error status and print results
check_results
else
echo -e "- shellcheck not found ${skipped}"
fi

# Run actionlint to check GHA workflow syntax
if which actionlint >/dev/null 2>&1
if command -v actionlint >/dev/null 2>&1
then
echo -e -n "${header} Run actionlint on GHA workflow files "

Expand All @@ -66,35 +70,12 @@ then

# check for error status and print results
check_results
else
echo -e "- actionlint not found ${skipped}"
fi

# Run helm lint on charts included in .internal-ci/helm
# if which helm >/dev/null 2>&1
# then
# echo -e -n "${header} Run helm lint on charts in .internal-ci/helm "

# out=""

# # Find Chart.yaml files
# chart_base=".internal-ci/helm"
# chart_files=$(find "${chart_base}" -name Chart.yaml -type f)

# # helm lint on directories where there are chart.yaml files
# for c in ${chart_files}
# do
# chart=$(dirname "${c}")
# if ! out+=$(helm lint --quiet "${chart}" 2>&1)
# then
# error="true"
# fi
# done

# # check for error status and print results
# check_results
# fi

# Run hadolint on Dockerfiles included in .internal-ci/docker
if which hadolint >/dev/null 2>&1
if command -v hadolint >/dev/null 2>&1
then
echo -e -n "${header} Run hadolint on Dockerfiles"

Expand All @@ -116,18 +97,3 @@ then
# check for error status and print results
check_results
fi

# Run flake8 linting
# if which flake8 >/dev/null 2>&1
# then
# echo -e -n "${header} Run flake8 linter "

# out=""
# if ! out+=$(flake8 2>&1)
# then
# error="true"
# fi

# # check for error status and print results
# check_results
# fi
33 changes: 33 additions & 0 deletions cache-go-binaries/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Mobilecoin Go Binary Cache
description: Standardized golang binary cache setup

inputs:
cache_buster:
description: "string to make cache unique"
required: false
path:
description: "path to mount cache"
required: false
default: |
go_build_artifacts
additional_keys:
description: "additional values to add to the cache key"
required: false
default: ""

outputs:
cache-hit:
description: "did we get a cache hit?"
value: ${{ steps.cache.outputs.cache-hit }}

runs:
using: composite
steps:
- name: Cache build binaries
id: cache
uses: actions/cache@v3
with:
path: ${{ inputs.path }}
# Key is a hash of all the .go, .p files.
# if code changes, invalidate cache and rebuild
key: ${{ inputs.cache_buster }}${{ inputs.additional_keys }}-${{ runner.os }}-${{ hashFiles('**/*.go', 'go.mod', 'go.sum') }}-go-build-artifacts

0 comments on commit f5dc11b

Please sign in to comment.