Skip to content

Commit

Permalink
extract workflow actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrzemien committed Jun 22, 2022
1 parent f65364e commit fe0cc49
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 60 deletions.
13 changes: 13 additions & 0 deletions .github/actions/cleanup-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Cleanup build
description: Cleanup sbt build
runs:
using: "composite"
steps:
- name: Cleanup sbt
shell: bash
run: |
rm -rf "$HOME/.ivy2/local" || true
find $HOME/.ivy2/cache -name "ivydata-*.properties" -delete || true
find $HOME/.ivy2/cache -name "*-LM-SNAPSHOT*" -delete || true
find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete || true
find $HOME/.sbt -name "*.lock" -delete || true
17 changes: 17 additions & 0 deletions .github/actions/setup-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Setup build
description: Setup sbt build
inputs:
targetPlatform:
description: Target platform
required: true
runs:
using: "composite"
steps:
- name: Cache sbt
uses: actions/cache@v2
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier
key: sbt-cache-${{ runner.os }}-${{ inputs.targetPlatform }}-${{ hashFiles('project/build.properties') }}
74 changes: 28 additions & 46 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,29 @@ jobs:
java: [ '8', '11', '17' ]
fail-fast: false
steps:
- name: Set environment variables for Java 8
if: matrix.java == '8'
run: echo 'JAVA_OPTS=-Xmx5G' >> $GITHUB_ENV
- name: Set environment variables for Java 9+
if: matrix.java != '8'
run: echo 'JAVA_OPTS=-Xmx5G --add-opens java.base/java.lang=ALL-UNNAMED' >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: ${{ matrix.java }}
- name: Cache sbt
uses: actions/cache@v2
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier
key: sbt-cache-${{ runner.os }}-${{ hashFiles('project/build.properties') }}-${{ matrix.java }}
- name: Compile
run: sbt -v compile
- name: Test
run: sbt -v test
- name: Cleanup
run: |
rm -rf "$HOME/.ivy2/local" || true
find $HOME/.ivy2/cache -name "ivydata-*.properties" -delete || true
find $HOME/.ivy2/cache -name "*-LM-SNAPSHOT*" -delete || true
find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete || true
find $HOME/.sbt -name "*.lock" -delete || true
- name: Set environment variables for Java 8
if: matrix.java == '8'
run: echo 'JAVA_OPTS=-Xmx5G' >> $GITHUB_ENV
- name: Set environment variables for Java 9+
if: matrix.java != '8'
run: echo 'JAVA_OPTS=-Xmx5G --add-opens java.base/java.lang=ALL-UNNAMED' >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: ${{ matrix.java }}
- name: Setup build
uses: ./.github/actions/setup-build
with:
targetPlatform: ${{ matrix.java }}
- name: Compile
run: sbt -v compile
- name: Test
run: sbt -v test
- name: Cleanup build
uses: ./.github/actions/cleanup-build

publish:
name: Publish release
Expand All @@ -62,14 +53,10 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache sbt
uses: actions/cache@v2
- name: Setup build
uses: ./.github/actions/setup-build
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier
key: sbt-cache-${{ runner.os }}-${{ hashFiles('project/build.properties') }}
targetPlatform: 11
- name: Compile
run: sbt compile
- name: Publish artifacts
Expand All @@ -95,10 +82,5 @@ jobs:
version: "v${{ env.VERSION }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Cleanup
run: |
rm -rf "$HOME/.ivy2/local" || true
find $HOME/.ivy2/cache -name "ivydata-*.properties" -delete || true
find $HOME/.ivy2/cache -name "*-LM-SNAPSHOT*" -delete || true
find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete || true
find $HOME/.sbt -name "*.lock" -delete || true
- name: Cleanup build
uses: ./.github/actions/cleanup-build
19 changes: 5 additions & 14 deletions .github/workflows/scala-steward.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,10 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache sbt
uses: actions/cache@v2
- name: Setup build
uses: ./.github/actions/setup-build
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier
key: sbt-cache-${{ runner.os }}-JVM-${{ hashFiles('project/build.properties') }}
targetPlatform: 11
- name: Launch Scala Steward
uses: scala-steward-org/scala-steward-action@v2
with:
Expand All @@ -32,10 +28,5 @@ jobs:
github-token: ${{ secrets.REPO_GITHUB_TOKEN }}
repo-config: .scala-steward.conf
ignore-opts-files: false
- name: Cleanup
run: |
rm -rf "$HOME/.ivy2/local" || true
find $HOME/.ivy2/cache -name "ivydata-*.properties" -delete || true
find $HOME/.ivy2/cache -name "*-LM-SNAPSHOT*" -delete || true
find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete || true
find $HOME/.sbt -name "*.lock" -delete || true
- name: Cleanup build
uses: ./.github/actions/cleanup-build

0 comments on commit fe0cc49

Please sign in to comment.