Java CI #4389
This file contains 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
name: Java CI | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
types: [ opened, reopened, synchronize ] | |
workflow_dispatch: | |
schedule: | |
# Run every 6 hours at minute 0: 06:00, 12:00, 18:00, 00:00 | |
- cron: '0 6,12,18,0 * * *' | |
concurrency: | |
group: ${{ github.workflow }} | |
permissions: | |
contents: write | |
env: | |
SAUCE_USERNAME: ${{secrets.SAUCE_USERNAME}} | |
SAUCE_ACCESS_KEY: ${{secrets.SAUCE_ACCESS_KEY}} | |
jobs: | |
unit_tests_job: | |
name: Unit Tests | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
cache: 'maven' | |
- name: Build with Maven | |
run: mvn clean test -Dtest="com.saucelabs.saucerest.unit.**" -Dgpg.skip -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -V | |
- name: Upload JaCoCo report to Codecov | |
uses: codecov/codecov-action@v5 | |
with: | |
flags: unittests,tests | |
upload_apps_job: | |
name: Upload My Demo Apps | |
# Only proceed if unit tests pass | |
needs: unit_tests_job | |
uses: ./.github/workflows/upload_my_demo_app.yml | |
secrets: inherit | |
integration_tests_job: | |
name: Integration Tests | |
needs: [ unit_tests_job, upload_apps_job ] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set env var for Integration Tests | |
# Only run integration tests if the code is coming from this repo and not forks | |
if: ${{ github.repository == github.event.pull_request.head.repo.full_name }} || ${{ github.event.push.head.repo.full_name == github.repository }} | |
run: | | |
echo "NOT_FROM_FORK=true" >> $GITHUB_ENV | |
- name: Print env var | |
run: | | |
echo "NOT_FROM_FORK: ${{ env.NOT_FROM_FORK }}" | |
- uses: actions/checkout@v4 | |
if: ${{ env.NOT_FROM_FORK }} == 'true' | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
if: ${{ env.NOT_FROM_FORK }} == 'true' | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
cache: 'maven' | |
- name: Setup Sauce Connect US-West | |
uses: saucelabs/sauce-connect-action@v2 | |
with: | |
username: ${{ secrets.SAUCE_USERNAME }} | |
accessKey: ${{ secrets.SAUCE_ACCESS_KEY }} | |
tunnelName: github-action-tunnel-us-west | |
configFile: ${{ github.workspace }}/src/test/resources/sauce-connect-config-us-west.yaml | |
- name: Setup Sauce Connect EU-Central | |
uses: saucelabs/sauce-connect-action@v2 | |
with: | |
username: ${{ secrets.SAUCE_USERNAME }} | |
accessKey: ${{ secrets.SAUCE_ACCESS_KEY }} | |
tunnelName: github-action-tunnel-eu-central | |
configFile: ${{ github.workspace }}/src/test/resources/sauce-connect-config-eu-central.yaml | |
- name: Build and Run Integration Tests | |
if: ${{ env.NOT_FROM_FORK }} == 'true' | |
uses: nick-invision/[email protected] | |
with: | |
timeout_minutes: 20 | |
max_attempts: 3 | |
command: | | |
mvn clean test -Dtest="com.saucelabs.saucerest.integration.**" -Dgpg.skip -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -Dsurefire.rerunFailingTestsCount=2 -V | |
- name: Upload JaCoCo report to Codecov | |
uses: codecov/codecov-action@v5 | |
with: | |
flags: integrationtests,tests |