CI (Java SDK) #124
This file contains hidden or 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
# Copyright 2024 ScopeDB, Inc. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
name: CI (Java SDK) | |
on: | |
pull_request: | |
branches: [ main ] | |
paths: [ 'java/**' ] | |
schedule: | |
# ScopeDB edge is cut every day at 02:04, so we run the CI at 04:02 to ensure the latest version is tested. | |
- cron: '2 4 * * *' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.number || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
check: | |
name: Check | |
runs-on: ubuntu-22.04 | |
if: ${{ github.event_name != 'schedule' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: '21' | |
cache: 'maven' | |
- name: Build and check | |
working-directory: java | |
run: | | |
./mvnw clean compile spotless:check | |
test: | |
name: Build and test | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
java: [ 8, 11, 17, 21 ] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK ${{ matrix.java }} | |
uses: actions/setup-java@v4 | |
with: | |
java-version: ${{ matrix.java }} | |
distribution: 'zulu' | |
cache: 'maven' | |
- name: Prepare Composed Environment | |
if: ${{ github.repository == 'scopedb/scopedb-sdk' }} | |
run: docker compose -f ./dev/docker-compose.yml up -d | |
- name: Run tests | |
if: ${{ github.repository == 'scopedb/scopedb-sdk' }} | |
timeout-minutes: 10 | |
run: ./mvnw test | |
working-directory: java | |
required: | |
name: Required | |
runs-on: ubuntu-22.04 | |
if: ${{ always() }} | |
needs: | |
- check | |
- test | |
steps: | |
- name: Guardian | |
run: | | |
if [[ ! ( \ | |
("${{ needs.check.result }}" == "success" || ${{ github.event_name != 'schedule' }}) \ | |
&& "${{ needs.test.result }}" == "success" \ | |
) ]]; then | |
echo "Required jobs haven't been completed successfully." | |
exit -1 | |
fi |