Skip to content

Commit

Permalink
Removed build steps for DevInt & SIT.
Browse files Browse the repository at this point in the history
  • Loading branch information
ericdeback committed May 24, 2024
1 parent bddc4cd commit 927c060
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 98 deletions.
87 changes: 4 additions & 83 deletions .github/workflows/CICD_Main_Pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:

jobs:
DevVer:
runs-on: [self-hosted]
runs-on: [self-hosted, OPENSUSE2]
strategy:
matrix:
browser: [ chrome ]
Expand Down Expand Up @@ -85,60 +85,14 @@ jobs:
path: target/surefire-reports/

DevInt:
runs-on: [self-hosted]
runs-on: [self-hosted, OPENSUSE2]
needs: DevVer
strategy:
matrix:
browser: [ chrome, firefox ]
profile: [ Localtests ]
environment: [ DevInt ]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Cache JDK
id: cache-java
uses: actions/cache@v4
with:
path: ~/action-runner/_work/_tool/Java_Zulu_jdk/19.0.2-7/x64
key: ${{ runner.os }}-java-19-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-java-
#DEBUG
- name: Debug Cache
run: |
echo "Cache hit: ${{ steps.cache-java.outputs.cache-hit }}"
ls -la ~/action-runner/_work/_tool/Java_Zulu_jdk/19.0.2-7/x64
- name: Verify Java version
run: java -version

- name: Check JAVA_HOME
run: echo $JAVA_HOME
#DEBUG

- name: Set up JDK 19
if: steps.cache-java.outputs.cache-hit != 'true'
uses: actions/setup-java@v4
with:
java-version: '19'
distribution: 'zulu'
install-path: ~/action-runner/_work/_tool/Java_Zulu_jdk/19.0.2-7/x64

- name: Verify Java version
run: java -version
- name: Print JAVA_HOME
run: echo $JAVA_HOME

- name: Cache Maven packages
uses: actions/[email protected]
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build & Test DevInt with Maven
run: mvn -B package --file pom.xml -Denvironment=${{matrix.environment}} -Dbrowser=${{ matrix.browser }} -P ${{ matrix.profile}}
- name: Upload test results
Expand All @@ -148,46 +102,13 @@ jobs:
path: target/surefire-reports/

SIT:
runs-on: [self-hosted]
runs-on: [self-hosted, OPENSUSE2]
needs: DevInt
strategy:
matrix:
profile: [ Browserstack ]
environment: [ SIT ]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Cache JDK
id: cache-java
uses: actions/cache@v4
with:
path: ~/action-runner/_work/_tool/Java_Zulu_jdk/19.0.2-7/x64
key: ${{ runner.os }}-java-19-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-java-
- name: Set up JDK 19
if: steps.cache-java.outputs.cache-hit != 'true'
uses: actions/setup-java@v4
with:
java-version: '19'
distribution: 'zulu'
install-path: ~/action-runner/_work/_tool/Java_Zulu_jdk/19.0.2-7/x64

- name: Verify Java version
run: java -version
- name: Print JAVA_HOME
run: echo $JAVA_HOME

- name: Cache Maven packages
uses: actions/[email protected]
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build & test SIT with Maven
run: mvn -B package --file pom.xml -D environment=${{matrix.environment}} -P ${{ matrix.profile}}

Expand All @@ -205,7 +126,7 @@ jobs:
path: target/surefire-reports/

Production:
runs-on: [self-hosted]
runs-on: [self-hosted, OPENSUSE2]
needs: SIT
steps:
- name: Deploy to production
Expand Down
72 changes: 57 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,63 @@ I built this project to demonstrate the basics principles of CICD pipeline devel
Done. using matrix syntax in workflow yml. Safari is supported if self-hosted host has Safari installed. No Safari support on Linux.
Multiple profiles in pom.xml can be used to refine which test cases are executed.

1. A JAR deployment for CICD will require the test cases to be packaged and deployed also. If the JAR itself is a managed item that can, in theory,
be promoted to production, it should not contain any test classes. It is possible to build a jar with the SUT classes and a separate JAR with test classes:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
1. Produce a build JAR with test cases and one without (-> production)

<groupId>com.example</groupId>
<artifactId>my-app</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>

<dependencies>
<!-- Your dependencies go here -->
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>tests</classifier>
</configuration>
</execution>
<execution>
<id>default-jar</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<excludes>
<exclude>**/*Test.class</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<additionalClasspathElements>
<additionalClasspathElement>${project.build.directory}/${project.build.finalName}-tests.jar</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
</plugins>
</build>


Note: Building and testing on a runner is different from building and running on a dedicated Cloud environment. In a microservices architecture, is this the right convoluted approach?
- Build jar and test jar on a runner (mvn package -no test)
Expand Down

0 comments on commit 927c060

Please sign in to comment.