CI: Update Workflows (#1879)

* Update Workflows

#1875

* Updated requested changes
This commit is contained in:
Subhrodip Mohanta 2021-10-28 00:14:00 +05:30 committed by GitHub
parent bee1283371
commit 72bb189dc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 22 deletions

View File

@ -24,6 +24,9 @@
# This workflow will build a Java project with Maven # This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
# We are using two jobs here for testing our code on the latest JDK 11 build as well as a more satble build version of 11.0.3
# You can see the full discussion here https://github.com/iluwatar/java-design-patterns/pull/1868#issue-1029459688
name: Java CI name: Java CI
on: on:
@ -33,12 +36,11 @@ on:
jobs: jobs:
build: # This Workflow Job will build this project and run Sonar analysis using JDK 11.0.3
build-and-analyze:
name: Build and Run Sonar analysis on JDK 11.0.3
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
strategy:
matrix:
java-version: [ 11.0.3, 11 ]
steps: steps:
- name: Checkout Code - name: Checkout Code
@ -47,12 +49,14 @@ jobs:
# Disabling shallow clone for improving relevancy of SonarQube reporting # Disabling shallow clone for improving relevancy of SonarQube reporting
fetch-depth: 0 fetch-depth: 0
- name: Set up JDK ${{ matrix.java-version }} - name: Set up JDK 11.0.3
uses: actions/setup-java@v2 uses: actions/setup-java@v2
with: with:
java-version: ${{ matrix.java-version }} java-version: 11.0.3
distribution: 'zulu' distribution: 'zulu'
cache: 'maven'
# Cache Sonar packages which as used to run anaylysis and collect metrics
- name: Cache SonarCloud packages - name: Cache SonarCloud packages
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
@ -60,14 +64,6 @@ jobs:
key: ${{ runner.os }}-sonar key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven dependencies
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# Some tests need screen access # Some tests need screen access
- name: Install xvfb - name: Install xvfb
run: sudo apt-get install -y xvfb run: sudo apt-get install -y xvfb
@ -78,3 +74,28 @@ jobs:
# These two env variables are needed for sonar analysis # These two env variables are needed for sonar analysis
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# This Workflow Job is going to build the project on the latest stable JDK 11
build:
name: Build and Test on JDK 11
runs-on: ubuntu-20.04
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Set up JDK 11 (Latest)
uses: actions/setup-java@v2
with:
java-version: 11
distribution: 'zulu'
cache: 'maven'
# Some tests need screen access
- name: Install xvfb
run: sudo apt-get install -y xvfb
- name: Build with Maven
run: xvfb-run ./mvnw clean verify

View File

@ -34,11 +34,13 @@ on:
jobs: jobs:
build: build:
name: Build JDP
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
strategy: strategy:
matrix: matrix:
java-version: [ 11.0.3, 11 ] java-version: [ 11.0.3, 11 ]
steps: steps:
- name: Checkout Code - name: Checkout Code
uses: actions/checkout@v2 uses: actions/checkout@v2
@ -47,14 +49,7 @@ jobs:
with: with:
java-version: ${{ matrix.java-version }} java-version: ${{ matrix.java-version }}
distribution: 'zulu' distribution: 'zulu'
cache: 'maven'
- name: Cache Maven Dependecies
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# Some tests need screen access # Some tests need screen access
- name: Install xvfb - name: Install xvfb