Skip to content

Commit

Permalink
Put Java setup, build and test commonly between tests and release
Browse files Browse the repository at this point in the history
  • Loading branch information
EliseChouleur committed Sep 27, 2023
1 parent d0fa5a6 commit f948549
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 35 deletions.
19 changes: 1 addition & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

- name: Add $JAVA_HOME to library path
run: |
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JAVA_HOME/lib/server" >> "$GITHUB_ENV"
- name: Checkout sources
uses: actions/checkout@v2

- name: Build
run: cargo build --verbose

- name: Run tests
run: cargo test --verbose
- uses: ./.github/workflows/setup_and_test.yml

- name: Publish release
run: cargo publish --token ${CRATES_TOKEN}
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/setup_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Java setup, build and test

on:
workflow_call:

jobs:
tests:
name: Run tests
runs-on: ubuntu-latest

steps:
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

- name: Add $JAVA_HOME to library path
run: |
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JAVA_HOME/lib/server" >> "$GITHUB_ENV"
- name: Checkout sources
uses: actions/checkout@v2

- name: Build
run: cargo build --verbose

- name: Run tests
run: cargo test --verbose
18 changes: 1 addition & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,4 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Install JDK
run: |
TEMP_DIR=$(mktemp -d)
wget https://raw.githubusercontent.com/travis-ci/travis-cookbooks/master/cookbooks/travis_jdk/files/install-jdk.sh -P $TEMP_DIR
chmod +x $TEMP_DIR/install-jdk.sh
export JAVA_HOME=$HOME/openjdk11
echo "JAVA_HOME=$HOME/openjdk11" >> "$GITHUB_ENV"
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JAVA_HOME/lib/server" >> "$GITHUB_ENV"
$TEMP_DIR/install-jdk.sh -F 17 --target $JAVA_HOME
- name: Checkout sources
uses: actions/checkout@v2

- name: Build
run: cargo build --verbose

- name: Run tests
run: cargo test --verbose
- uses: ./.github/workflows/setup_and_test.yml

0 comments on commit f948549

Please sign in to comment.