Skip to content

Commit

Permalink
fix ci problems
Browse files Browse the repository at this point in the history
  • Loading branch information
UnicornChance committed Mar 14, 2024
1 parent ecbc9cd commit cfa8a0e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 43 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Plugin Unit Tests
run: uds run dev-plugin
run: mvn -B package --file src/plugin/pom.xml
22 changes: 11 additions & 11 deletions docs/PLUGIN.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ See the `New uds-identity-config Image` section in the [CUSTOMIZE.md](./CUSTOMIZ

## Plugin Unit Testing / Code Coverage

The jacoco plugin is configured in the [pom.xml](./src/plugin/pom.xml). Some important commands that can be used when developing/testing on the plugin:
The maven surefire plugin is configured in the [pom.xml](./src/plugin/pom.xml). Some important commands that can be used when developing/testing on the plugin:

> [!IMPORTANT]
> `mvn` commands will need to be executed from inside of the `src/plugin` directory
Expand All @@ -31,19 +31,19 @@ The jacoco plugin is configured in the [pom.xml](./src/plugin/pom.xml). Some imp
|-------|-----------|
| `mvn clean install` | Cleans up build artifacts and then builds and installs project into local maven repository. |
| `mvn clean test` | Cleans up build artifacts and then compiles the source code and runs all tests in the project. |
| `mvn clean test jacoco:report` | Cleans up build artifacts and then compiles the source code and runs all tests in the project and then generates jacoco report. |
| `mvn clean test -Dtest=com.defenseunicorns.uds.keycloak.plugin.X509ToolsTest jacoco:report` | Same as `mvn clean test` but instead of running all tests in project, only runs the tests in designated file. |
| `mvn clean test -Dtest=com.defenseunicorns.uds.keycloak.plugin.X509ToolsTest` | Same as `mvn clean test` but instead of running all tests in project, only runs the tests in designated file. |
| `mvn surefire-report:report` | This command will run the `mvn clean test` and then generate the surefire-report.html file in `target/site` |

### Viewing the jacoco reports
### Viewing the Maven Surefire Reports

[Official JaCoCo Docs](https://www.jacoco.org/jacoco/trunk/doc/)

> JaCoCo tells you which parts of your code are being "covered" or executed by your tests and which parts are not.
After running a `mvn install` or `mvn test jacoco:report` there will be a `target` directory that is created and in that directory is a `site` folder.
```bash
# maven command from src/plugin directory
mvn surefire-report:report

The site folder will contain all the necessary pieces for viewing the jacoco test reports from your browser.
# uds command from base directory
uds run dev-plugin
```

Open the `index.html` file in your browser to view the test coverage. This will hot reload each time the site folder is rebuilt.
Open the `src/plugin/target/site/index.html` file in your browser to view the test coverage. This will hot reload each time the site folder is rebuilt.

Sometimes IDE's won't allow opening files in a browser, either download an extension for managing this or open it from file explorer.
27 changes: 0 additions & 27 deletions src/plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,36 +110,9 @@
--add-opens=java.base/java.util.stream=ALL-UNNAMED
--add-opens=java.base/java.net=ALL-UNNAMED
--add-opens=java.base/sun.security.jca=ALL-UNNAMED
-javaagent:${settings.localRepository}/org/jacoco/org.jacoco.agent/0.8.7/org.jacoco.agent-0.8.7-runtime.jar=destfile=target/jacoco.exec
</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.11</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
<configuration>
<excludes>
<!-- Exclude Common.class (it's just enums) -->
<exclude>com/defenseunicorns/uds/keycloak/plugin/Common.class</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
6 changes: 2 additions & 4 deletions tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,8 @@ tasks:
openssl x509 -req -in test.csr -CA ca.crt -CAkey ca.pem -CAcreateserial -out test.crt -days 365 -extensions v3_ext -extfile csr.conf
- name: dev-plugin
description: "Build and test the Keycloak Plugin and output jacoco report"
description: "Build and test the Keycloak Plugin"
actions:
- cmd: |
cd src/plugin
mvn install -DskipTests | egrep ".*"
mvn -o test | egrep ".*"
# mvn -B package --file src/plugin/pom.xml | egrep ".*"
mvn surefire-report:report | egrep ".*"

0 comments on commit cfa8a0e

Please sign in to comment.