forked from thesamet/sbt-protoc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use hashing instead of timestamps * change CI routines * Inline actions
- Loading branch information
Showing
4 changed files
with
154 additions
and
3 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,50 @@ | ||
name: restore-sbt-cache | ||
description: 'cache sbt deps and compiled classes' | ||
author: 'Dmitry Muzyka' | ||
inputs: | ||
clean_build: | ||
description: 'build all' | ||
required: false | ||
default: "false" | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Make cache key files | ||
shell: bash | ||
run: | | ||
echo "${LAST_COMPLETED_JOB_SHA1}" > last-completed-job.sha1 | ||
echo "${GITHUB_SHA}" > current.sha1 | ||
echo "${LATEST_CACHE_SHA1}" > latest-maybe-failed.sha1 | ||
date +%Y-%m > current_month | ||
- name: Restore compilation cache | ||
if: ${{ inputs.clean_build != 'true' }} | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: | | ||
build_cache | ||
key: v2-build-cache-${{ github.job }}-${{ hashFiles('current_month') }}-${{ hashFiles('current.sha1') }} | ||
restore-keys: | | ||
v2-build-cache-${{ github.job }}-${{ hashFiles('current_month') }}-${{ hashFiles('current.sha1') }} | ||
v2-build-cache-${{ github.job }}-${{ hashFiles('current_month') }}-${{ hashFiles('latest-maybe-failed.sha1') }} | ||
v2-build-cache-${{ github.job }}-${{ hashFiles('current_month') }}-${{ hashFiles('last-completed-job.sha1') }} | ||
v2-build-cache-${{ github.job }}-${{ hashFiles('current_month') }}- | ||
- name: Apply compilation cache | ||
if: ${{ inputs.clean_build != 'true' }} | ||
shell: bash | ||
run: | | ||
RUNNER_TRACKING_ID="" && tar -xf build_cache/targets.tar 2>/dev/null & | ||
- name: cleanup sbt cache once per month | ||
shell: bash | ||
run: | | ||
mkdir -p ~/.cache | ||
test -f ~/.cache/.timecreated || touch ~/.cache/.timecreated | ||
if test "$(find ~/.cache/.timecreated -mtime +30)"; then | ||
echo "run cleanup" | ||
find ~/.cache ~/.ivy2 -type f -mtime +30 -delete | ||
find ~/.cache ~/.ivy2 -type d -empty -delete | ||
mkdir -p ~/.cache | ||
touch ~/.cache/.timecreated | ||
fi |
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,44 @@ | ||
name: save-sbt-cache | ||
description: 'cache sbt deps and compiled classes' | ||
author: 'Dmitry Muzyka' | ||
inputs: | ||
clean_build: | ||
description: 'build all' | ||
required: false | ||
default: "false" | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Build cache directory | ||
shell: bash | ||
run: | | ||
targets=$(git clean -ndx | cut -c14- | grep /$ | grep -E -v '(build_cache|persist|test_results)') | ||
tar -cf build_cache/targets.tar --exclude=*/target/test-reports/*.xml --exclude=*.log --exclude=*/target/scoverage-report --exclude=*/target/coverage-report --exclude=project/target/active.json $targets || : | ||
- name: Make cache key file | ||
shell: bash | ||
run: | | ||
echo "${GITHUB_SHA}" > current.sha1 | ||
date +%Y-%m > current_month | ||
- name: check if compilation cache exists | ||
id: check-compilation-cache | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: | | ||
build_cache | ||
key: v2-build-cache-${{ github.job }}-${{ hashFiles('current_month') }}-${{ hashFiles('current.sha1') }} | ||
lookup-only: 'true' | ||
|
||
- name: Save compilation cache | ||
if: steps.check-compilation-cache.outputs.cache-hit != 'true' | ||
uses: actions/cache/save@v3 | ||
with: | ||
path: | | ||
build_cache | ||
key: v2-build-cache-${{ github.job }}-${{ hashFiles('current_month') }}-${{ hashFiles('current.sha1') }} | ||
|
||
- name: Clean up | ||
shell: bash | ||
run: rm -rf build_cache current.sha1 | ||
# / save sbt cache |
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,57 @@ | ||
name: set-ci-vars | ||
description: 'set ci vars.' | ||
author: 'Dmitry Muzyka' | ||
inputs: | ||
clean_build: | ||
description: 'build all' | ||
required: false | ||
default: "false" | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: "set git config" | ||
shell: bash | ||
run: | | ||
git config --global --add safe.directory "$(pwd)" | ||
git fetch origin master | ||
git describe --tags --abbrev=0 --first-parent | ||
# set vars | ||
- name: set branch | ||
shell: bash | ||
run: | | ||
branch="$(echo -n ${{ github.event.ref }} | sed 's#refs/heads/##g; s#/#-#g' | tr '[:upper:]' '[:lower:]')" | ||
echo "branch=\"${branch}\"" >> $GITHUB_ENV | ||
- name: set new version | ||
shell: bash | ||
run: | | ||
if [[ ${{env.branch}} == "master" ]]; then | ||
version="$(date +'%Y.%m.%d')-${{github.run_number}}" | ||
else | ||
version="$(date +'%Y.%m.%d')-${branch}-${{github.run_number}}" | ||
fi | ||
version=$(echo $version | sed 's/"//g') | ||
echo "version=$version" | ||
echo "version=$version" >> $GITHUB_ENV | ||
- name: Set LAST_COMPLETED_JOB_SHA1 | ||
shell: bash | ||
run: | | ||
if [[ '${{ inputs.clean_build }}' == 'true' ]]; then | ||
echo "clean build, will bundle & test all" | ||
echo "LAST_COMPLETED_JOB_SHA1=None" >> $GITHUB_ENV | ||
else | ||
.github/helpers/set-last-completed-job-sha1.sh | ||
fi | ||
- name: print debug info | ||
shell: bash | ||
run: | | ||
echo "previous successful build sha: ${LAST_COMPLETED_JOB_SHA1}" | ||
echo "previous successful version: $(git tag --points-at ${LAST_COMPLETED_JOB_SHA1})" | ||
echo "latest cache sha: ${LATEST_CACHE_SHA1}" | ||
echo "branch: ${branch}" | ||
echo "version: ${version}" | ||
# /set vars |
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