Skip to content

Commit

Permalink
Optimize CI build with hashver-maven-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
avodonosov committed Dec 8, 2020
1 parent 049d3d6 commit 1d68c64
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,32 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Cache local Maven repository
- name: Generate random cache key to ensure the cach directories are saved after build
# see https://github.com/actions/cache/issues/432#issuecomment-740376179
id: random-cache-key
run: head /dev/random -c 32 > random-cache-key
- name: Setup caching directories for local Maven repo and for DB of successfuly built hashversioned modules
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
path: |
~/.m2/repository
~/successful-hashvers
key: ${{ runner.os }}-maven-${{ hashFiles('random-cache-key') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build with Maven
run: mvn -B verify --file pom.xml
- name: Determine affected Maven projects
id: affected-projects
shell: bash
run: |
find "${HOME}/successful-hashvers" || true # print the dir content, for troubleshooting
mkdir -p "${HOME}/successful-hashvers" || true
mvn pro.avodonosov:hashver-maven-plugin:1.6:projects-to-build -DdbDir="${HOME}/successful-hashvers"
echo "::set-output name=list::$(cat target/hashver-projects-to-build)"
- name: Build the affected Maven projects
if: ${{ steps.affected-projects.outputs.list }}
run: mvn -B verify -pl ${{ steps.affected-projects.outputs.list }} -am
- name: Save successfull hashvers
if: ${{ steps.affected-projects.outputs.list && success() }}
run: |
cp -r target/hashver-db-additions/* "${HOME}/successful-hashvers"
find "${HOME}/successful-hashvers" || true # print the dir content, for troubleshooting

0 comments on commit 1d68c64

Please sign in to comment.