utPLSQL-java-api/CONTRIBUTING.md at develop · utPLSQL/utPLSQL-java-api
Repository navigation
CONTRIBUTING.md
Latest commit
History
History
View commit history for this file.
CONTRIBUTING.md
File metadata and controls
Raw
Contributing
Changes are welcome from all members of the community. This is the single place for contribution rules: setup, workflow, standards and releasing. AI coding agents follow it too, and AGENTS.md adds only agent-specific rules.
Getting started
Don't forget to configure your JAVA_HOME environment variable. The project needs a JDK 17 or newer.
For each change you want to make:
- Create a branch from
develop. Name itfeature/feature_nameorbugfix/fixed_issue_name. - Keep the change focused on the requested behavior. Don't fix unrelated things in passing.
- Cover the change with tests (see Tests ).
- Verify that the code compiles and that all existing and new tests pass. The quickest way to have a pull request rejected is to submit code that doesn't compile or pass tests.
- Submit a pull request into
develop.
Local database with utPLSQL and utPLSQL-demo-project
To contribute usefully you need a local database with the latest utPLSQL v3 and the utPLSQL-demo-project installed. The demo project serves as the test user.
scripts/1_install_utplsql.sh and scripts/2_install_demo_project.sh install both using dockerized sqlplus, and .github/workflows/build.yml shows how CI runs them against a gvenzl/oracle-free:23-slim-faststart service container. They read the connect string from the DB_URL environment variable (for example //localhost:1521/FREEPDB1) and expect the SYS password oracle.
By default, tests run against the app/app user of localhost:1521/FREEPDB1. To use another database, set DB_URL, DB_USER and DB_PASS, either as environment variables or as system properties (see EnvironmentVariableUtil).
Building and testing
./mvnw is the Maven Wrapper, which pins the Maven version (.mvn/wrapper/), so you don't need Maven installed. On Windows PowerShell use .\mvnw.cmd. Plain mvn also works if a compatible Maven is installed, and CI uses it.
Without a database, run the unit tests only:
./mvnw test
With the local database set up, run the complete build including integration tests:
./mvnw verify
Run a single unit test class:
./mvnw test -Dtest=VersionObjectTest
Run a single integration test class, without running the unit tests:
./mvnw verify -Dtest=NoUnitTests -Dsurefire.failIfNoSpecifiedTests=false -Dit.test=TestRunnerStatementProviderIT
Don't use -DskipTests for this: it skips the integration tests as well.
Maven profiles: -Pcoverage adds JaCoCo coverage, and -Prelease adds javadoc, sources and GPG signing.
Tests
- Every new functionality needs tests that cover the happy path as well as edge cases and error paths. Follow the testing pyramid or the testing diamond.
- Lack of sufficient tests is a valid reason to reject a pull request.
- Classes whose names end in
ITare integration tests. They run in failsafe duringverifyand need the database. They extendAbstractDatabaseTest, which provides the connection setup. - Plain
*Testclasses run in surefire and don't need a database.
Coding standards
- Match the naming, formatting and error handling of the code around your change.
- Don't comment what the code does. The code should make that clear. Comment the reason for the code, or background that isn't obvious from it or easy to find with an internet search, and only where it adds real value.
- Update the README or other documentation when a change affects documented behavior.
- Treat public classes and method signatures as a published API: utPLSQL-cli and utPLSQL-maven-plugin depend on them. Don't change or remove them unless the task calls for it, and call it out in the pull request when you do.
- Put version-specific behavior in the compatibility layer (
CompatibilityProxy,OptionalFeatures, the provider classes), not in scattered version checks.
Engineering principles
Every change (Java, SQL scripts, GitHub workflows, tooling) follows these principles of Extreme Programming (XP):
- KISS - Keep It Simple, Stupid : choose the simplest solution that works and is easy to read. No clever constructs where a plain one will do.
- DRY - Don't Repeat Yourself : every piece of knowledge has one authoritative place. Reuse existing classes and helpers instead of copying logic. In GitHub workflows, define a value once and reference it.
- YAGNI - You Aren't Gonna Need It : implement only what the task needs now. No speculative parameters, options, abstractions or "future" code paths.
Apply the SOLID principles where they fit, and don't force them onto simple code:
- Single Responsibility : a class or method has one cohesive purpose and one reason to change. Keep methods short and focused.
- Open/Closed : extend behavior without modifying working code. For example, add a version-specific implementation behind an existing interface (such as a new
OutputBuffer) instead of another branch in a largeif/switch. - Liskov Substitution : a subtype must be usable wherever its base type is expected, without changing the contract of the base type's methods.
- Interface Segregation : keep interfaces small and focused. Make a method public only if something needs it.
- Dependency Inversion : depend on interfaces and abstract types, not on concrete implementations. Don't reach into another module's internals.
Refactoring
Before each refactoring step:
- Check test coverage first. Make sure existing tests cover the logic being refactored, including its edge cases and error paths. If they don't, add the missing tests and see them pass against the current code before changing it.
- Find tests that the change would break. Look for tests that call the methods or classes being moved, merged or removed. Where you can, rewrite those tests to call a higher-level method that keeps its contract. The tests then check behavior rather than internal structure, and still pass after the refactoring.
Performance work
- Compare results using the same Oracle version, environment and workload.
- Report the measurements and conditions used. Don't present an unmeasured performance improvement as established.
Security
- For security-sensitive changes, consider input validation, dynamic SQL, schema and object name handling, and privilege boundaries. Follow the existing patterns in the relevant code.
- If you find a possible security vulnerability, don't disclose it in a public issue or pull request. Report it privately, as described in SECURITY.md .
Commit messages
A commit message describes how things are after the change, not how they were before it. Mention the earlier state only where the change can't be explained without it, as in a bug fix commit.
Architecture
Everything is under src/main/java/org/utplsql/api. The same public API (TestRunner, ReporterFactory, OutputBuffer) has to work against different utPLSQL database versions, so version-specific behavior is chosen at runtime.
compatibility/CompatibilityProxy: built from aConnection, it reads the installed utPLSQL version (Version) and decides what is supported.OptionalFeaturesis an enum of features with a minimum version, checked withisAvailableFor(connection | version). Other components consult the proxy instead of branching on versions themselves.TestRunner/TestRunnerOptions: the fluent entry point that collects paths, reporters, coverage and file-mapping options. It delegates execution totestRunner/TestRunnerStatementProvider, which picks aTestRunnerStatement.DynamicTestRunnerStatementbuilds theut_runner.runcall with only the parameters the connected database version accepts (db/DynamicParameterList).reporter/:ReporterFactorycreatesReporterinstances (DocumentationReporter,CoverageHTMLReporter, custom ones) via registered factory methods. A reporter is initialized on a connection and then owns an output buffer.outputBuffer/:OutputBufferProviderpicks the implementation for the database version (DefaultOutputBuffer,CompatibilityOutputBufferPre310,NonOutputBuffer). Reporter output can be read from a second connection while the tests run on the first.db/andDBHelper: version and database information, plus helpers for Oracle-specific calls.exception/:UtPLSQLNotInstalledException,DatabaseNotCompatibleException,SomeTestsFailedExceptionand others, thrown by the above.
Publishing a new release
To publish a new release manually, run the Release workflow . Provide the release version and, optionally, the next snapshot version (default: the patch version incremented).
The workflow deploys to Maven Central, tags the release, bumps pom.xml to the next -SNAPSHOT, creates the GitHub release and announces it through utPLSQL/.github/actions/announce-release. The announcement uses the API_TOKEN_GITHUB secret, which should come from the organization. A stale repository-level secret with the same name overrides it and makes the announcement step fail with 401 Bad credentials.
Pushes to develop publish a snapshot and trigger snapshot builds of utPLSQL-cli and utPLSQL-maven-plugin.