Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API Implementation #5

Merged
merged 36 commits into from
Nov 5, 2024
Merged

Conversation

gmitch215
Copy link
Member

@gmitch215 gmitch215 commented Jul 31, 2024

Merges into #1.

Description

This PR does the following:

  • Implements CodeMC/API for the Bot
    • Performs a RegEx grouping expression on the GitHub repository link, to be used to determine if a project is freestyle, and used as parameters for username and jobName
    • Creates a Nexus Repository (/repository/username), Jenkins User (/job/username), and Jenkins Job (/job/username/job/jobName) automatically
    • Generates an arbitrary Nexus Password that is 32 characters long (see generator.kt for more details)
    • Performed Asynchronously with Kotlin Coroutines & Kotlin Serialization for better performance
  • Updates the requirements in config.json
    • New jenkins, nexus and database sections are now required to be inputted. Similar to Add Jenkins Automation to Accept Command #4, specify the host URLs, with admin login details that the bot should use.
    • A new role list called services is available. This includes direct interaction with the current services via API. The sample includes the Moderator and Administrator roles.
    • See config.json.sample for more information.
  • Adds a codemc Slash Command
  • Removes the project-url parameter in the Accept command, calculated according to the config.json instead
  • Updates Gradle to the latest version, which is 8.9.
  • Adds more missing directories to .gitignore.

API Implementation

The implementation details of the API are on the repository, which performs tests against Jenkins and Nexus containers with similar configuration, and collects code coverage. Thus, specific API changes must be made to the repository, which will then be updated here.

Copy link
Collaborator

@Andre601 Andre601 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of things to discuss, with some changes I would apreciate to be made.

src/main/java/io/codemc/bot/CodeMCBot.java Outdated Show resolved Hide resolved
src/main/java/io/codemc/bot/JavaContinuation.java Outdated Show resolved Hide resolved
src/main/java/io/codemc/bot/commands/CmdApplication.java Outdated Show resolved Hide resolved
src/main/java/io/codemc/bot/commands/CmdApplication.java Outdated Show resolved Hide resolved
src/main/java/io/codemc/bot/commands/CmdApplication.java Outdated Show resolved Hide resolved
src/main/java/io/codemc/bot/commands/CmdApplication.java Outdated Show resolved Hide resolved
src/main/java/io/codemc/bot/JavaContinuation.java Outdated Show resolved Hide resolved
src/main/java/io/codemc/bot/commands/CmdApplication.java Outdated Show resolved Hide resolved
src/main/java/io/codemc/bot/listeners/ModalListener.java Outdated Show resolved Hide resolved
@gmitch215 gmitch215 requested a review from Andre601 August 1, 2024 00:04
@gmitch215
Copy link
Member Author

gmitch215 commented Aug 5, 2024

Updates the implementation from CodeMC/API. Unit tests pass.

I will add CmdRemove into this PR as well.

I also added a dependabot.yml File for the dependencies in build.gradle.

@gmitch215 gmitch215 requested a review from sgdc3 August 5, 2024 19:06
@gmitch215 gmitch215 changed the title Add Nexus & Jenkins Automation Add API Implementation Aug 5, 2024
- Create Remove Command Class
- Add `service` section in `config.json` to interact directly with API Services
- Set sample to include Moderator and Administrator
@gmitch215 gmitch215 closed this Aug 5, 2024
@gmitch215 gmitch215 deleted the feat/automation branch August 5, 2024 20:01
@gmitch215 gmitch215 restored the feat/automation branch August 5, 2024 20:02
@gmitch215 gmitch215 deleted the feat/automation branch August 5, 2024 20:03
@gmitch215 gmitch215 restored the feat/automation branch August 5, 2024 20:04
@gmitch215 gmitch215 reopened this Aug 5, 2024
@gmitch215
Copy link
Member Author

GitHub is weird.

This was linked to issues Aug 5, 2024
@gmitch215 gmitch215 requested a review from Andre601 August 6, 2024 12:58
Copy link
Collaborator

@Andre601 Andre601 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few things that should be changed.
Main concern is the reliance on the Discord user, with the jenkins username only being optional. Not every user matches their GitHub and Discord names, and using something like the user's nickname is not a good aproach here.

src/main/java/io/codemc/bot/commands/CmdRemove.java Outdated Show resolved Hide resolved
src/main/java/io/codemc/bot/commands/CmdRemove.java Outdated Show resolved Hide resolved
src/main/java/io/codemc/bot/commands/CmdRemove.java Outdated Show resolved Hide resolved
src/main/java/io/codemc/bot/commands/CmdRemove.java Outdated Show resolved Hide resolved
src/main/resources/config.json Outdated Show resolved Hide resolved
src/main/resources/config.json.sample Outdated Show resolved Hide resolved
@gmitch215 gmitch215 linked an issue Aug 24, 2024 that may be closed by this pull request
@gmitch215
Copy link
Member Author

Added a /codemc changepassword subcommand, along with /codemc unlink and a few other utilities.

src/main/java/io/codemc/bot/commands/CmdCodeMC.java Outdated Show resolved Hide resolved
src/main/java/io/codemc/bot/commands/CmdCodeMC.java Outdated Show resolved Hide resolved
src/main/java/io/codemc/bot/commands/CmdCodeMC.java Outdated Show resolved Hide resolved
src/main/java/io/codemc/bot/commands/CmdCodeMC.java Outdated Show resolved Hide resolved
src/main/java/io/codemc/bot/utils/APIUtil.java Outdated Show resolved Hide resolved
src/main/java/io/codemc/bot/utils/APIUtil.java Outdated Show resolved Hide resolved
src/main/java/io/codemc/bot/utils/APIUtil.java Outdated Show resolved Hide resolved
src/main/resources/config.json Outdated Show resolved Hide resolved
src/main/resources/config.json.sample Outdated Show resolved Hide resolved
@gmitch215 gmitch215 linked an issue Aug 27, 2024 that may be closed by this pull request
@gmitch215
Copy link
Member Author

That should be all of them. I also upgraded Gradle to the most recent version.

build.gradle Outdated Show resolved Hide resolved
src/main/java/io/codemc/bot/commands/CmdCodeMC.java Outdated Show resolved Hide resolved
src/main/java/io/codemc/bot/commands/CmdCodeMC.java Outdated Show resolved Hide resolved
src/main/java/io/codemc/bot/commands/CmdCodeMC.java Outdated Show resolved Hide resolved
gmitch215 and others added 11 commits October 2, 2024 09:08
Removed `suspend` Modifiers from Kotlin API
- Remove Unused JavaContinutation
- Fix Validation Command
- Add Response Message for Change Password
Explicitly set Repository Link to Optional
- Add Logging for Connectivity
- Fix Jenkins Authorization
- Fix Message Parsing for Success Message
- Move API Methods before Message is Sent
- Add Reason for Deny Button
- Fix `lacksRole` Method
@gmitch215
Copy link
Member Author

gmitch215 commented Oct 6, 2024

Tested everything on a Bot with a Docker Setup.

A few notes:

  • There were a few bugs in the API regarding bot-specific actions, like the validate command where it could create inconsistencies between Jenkins and Nexus passwords.
  • Added more logging for future debugging and just general information.
  • submit now denies users that apply with the same name.
    • It also appears JDA makes fields required by default, meaning optionality must be explicit.
  • There were a few bugs regarding typos in configuration paths, along with a small bug for lacksRole in ButtonListener.
  • The Deny button has a literal "Reason not Provided" as a reason, since making it null replaces it with the Jenkins URL for success
  • The remove command uses the database to remove the author role from the discord user, removing it as a parameter.
  • I removed a lot of suspend modifiers in the API, which allows for better interoperability with Java. I also noticed a lack of faster runtime for having coroutines in the validate command where it validates all Jenkins users, so I also removed it there. This means that JavaContinuation no longer exists.
  • I fixed the dependencies issue by adding all of the necessary dependencies, along with the CodeMC API itself.

Add Database Check for `remove` Command
- Check Credentials for `/codemc validate`
- Improve `/codemc validate` Responses
- Improve Success with `/codemc change-password`
@gmitch215 gmitch215 changed the base branch from feat/context-menu-action+command-customization to master November 5, 2024 21:39
@gmitch215 gmitch215 merged commit da99a29 into CodeMC:master Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Change Password User Remote Commands validate Admin Command remove Admin Command CodeMC API v1
3 participants