From f948549932079364eea05f64c967082413643dc3 Mon Sep 17 00:00:00 2001 From: Elise Chouleur Date: Wed, 27 Sep 2023 10:22:06 +0200 Subject: [PATCH] Put Java setup, build and test commonly between tests and release --- .github/workflows/release.yml | 19 +----------------- .github/workflows/setup_and_test.yml | 29 ++++++++++++++++++++++++++++ .github/workflows/test.yml | 18 +---------------- 3 files changed, 31 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/setup_and_test.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c793d60b..2b6db853 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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} diff --git a/.github/workflows/setup_and_test.yml b/.github/workflows/setup_and_test.yml new file mode 100644 index 00000000..cf1042be --- /dev/null +++ b/.github/workflows/setup_and_test.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0e422973..b994e9bb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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