Skip to content

Commit

Permalink
Merge pull request #1666 from tgstation/OpenDream
Browse files Browse the repository at this point in the history
Add OpenDream support

Closes #1577
  • Loading branch information
Cyberboss authored Nov 20, 2023
2 parents 8802e5c + 84c5359 commit 9b7e0c5
Show file tree
Hide file tree
Showing 189 changed files with 10,085 additions and 2,547 deletions.
85 changes: 74 additions & 11 deletions .github/workflows/ci-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ on:

env:
TGS_DOTNET_VERSION: 8
OD_DOTNET_VERSION: 7
TGS_DOTNET_QUALITY: ga
TGS_TEST_GITHUB_TOKEN: ${{ secrets.LIVE_TESTS_TOKEN }}
TGS_RELEASE_NOTES_TOKEN: ${{ secrets.DEV_PUSH_TOKEN }}
Expand Down Expand Up @@ -164,6 +165,50 @@ jobs:
fi
exit $retval
opendream-build:
name: Build DMAPI (OpenDream)
needs: start-ci-run-gate
if: (!(cancelled() || failure()) && needs.start-ci-run-gate.result == 'success')
strategy:
fail-fast: false
matrix:
committish: [ 'master', 'tgs-min-compat' ]
runs-on: ubuntu-latest
steps:
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '${{ env.OD_DOTNET_VERSION }}.0.x'
dotnet-quality: ${{ env.TGS_DOTNET_QUALITY }}

- name: Checkout (Branch)
uses: actions/checkout@v3
if: github.event_name == 'push' || github.event_name == 'schedule'

- name: Checkout (PR Merge)
uses: actions/checkout@v3
if: github.event_name != 'push' && github.event_name != 'schedule'
with:
ref: "refs/pull/${{ github.event.number }}/merge"

- name: Checkout OpenDream
run: |
cd $HOME
git clone https://github.com/OpenDreamProject/OpenDream
cd OpenDream
git checkout ${{ matrix.committish }}
git submodule update --init --recursive
- name: Create TGS Deployment
run: |
cd $HOME/OpenDream
dotnet run -c Release --project OpenDreamPackageTool -- --tgs -o tgs_deploy
- name: Build DMAPI
run: |
cd tests/DMAPI/BasicOperation
$HOME/OpenDream/tgs_deploy/bin/compiler/DMCompiler --verbose --notices-enabled basic_operation_test.dme
pages-build:
name: Build gh-pages
runs-on: ubuntu-latest
Expand All @@ -173,7 +218,8 @@ jobs:
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.TGS_DOTNET_VERSION }}
dotnet-version: '${{ env.TGS_DOTNET_VERSION }}.0.x'
dotnet-quality: ${{ env.TGS_DOTNET_QUALITY }}

- name: Checkout (Branch)
uses: actions/checkout@v3
Expand Down Expand Up @@ -275,6 +321,7 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: '${{ env.TGS_DOTNET_VERSION }}.0.x'
dotnet-quality: ${{ env.TGS_DOTNET_QUALITY }}

- name: Checkout (Branch)
uses: actions/checkout@v3
Expand Down Expand Up @@ -325,6 +372,7 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: '${{ env.TGS_DOTNET_VERSION }}.0.x'
dotnet-quality: ${{ env.TGS_DOTNET_QUALITY }}

- name: Checkout (Branch)
uses: actions/checkout@v3
Expand Down Expand Up @@ -360,8 +408,8 @@ jobs:

windows-integration-test:
name: Windows Live Tests
needs: dmapi-build
if: (!(cancelled() || failure()) && needs.dmapi-build.result == 'success')
needs: [dmapi-build, opendream-build]
if: (!(cancelled() || failure()) && needs.dmapi-build.result == 'success' && needs.opendream-build.result == 'success')
strategy:
fail-fast: false
matrix:
Expand All @@ -380,7 +428,10 @@ jobs:
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '${{ env.TGS_DOTNET_VERSION }}.0.x'
dotnet-version: |
${{ env.TGS_DOTNET_VERSION }}.0.x
${{ env.OD_DOTNET_VERSION }}.0.x
dotnet-quality: ${{ env.TGS_DOTNET_QUALITY }}

- name: Set TGS_TEST_DUMP_API_SPEC
if: ${{ matrix.configuration == 'Release' && matrix.watchdog-type == 'Advanced' && matrix.database-type == 'SqlServer' }}
Expand Down Expand Up @@ -538,8 +589,8 @@ jobs:

linux-integration-tests:
name: Linux Live Tests
needs: dmapi-build
if: (!(cancelled() || failure()) && needs.dmapi-build.result == 'success')
needs: [dmapi-build, opendream-build]
if: (!(cancelled() || failure()) && needs.dmapi-build.result == 'success' && needs.opendream-build.result == 'success')
services: # We start all dbs here so we can just code the stuff once
mssql:
image: mcr.microsoft.com/mssql/server:2019-latest
Expand Down Expand Up @@ -601,7 +652,10 @@ jobs:
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '${{ env.TGS_DOTNET_VERSION }}.0.x'
dotnet-version: |
${{ env.TGS_DOTNET_VERSION }}.0.x
${{ env.OD_DOTNET_VERSION }}.0.x
dotnet-quality: ${{ env.TGS_DOTNET_QUALITY }}

- name: Set Sqlite Connection Info
if: ${{ matrix.database-type == 'Sqlite' }}
Expand Down Expand Up @@ -1105,6 +1159,7 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: '${{ env.TGS_DOTNET_VERSION }}.0.x'
dotnet-quality: ${{ env.TGS_DOTNET_QUALITY }}

- name: Checkout (Branch)
uses: actions/checkout@v3
Expand Down Expand Up @@ -1230,6 +1285,7 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: '${{ env.TGS_DOTNET_VERSION }}.0.x'
dotnet-quality: ${{ env.TGS_DOTNET_QUALITY }}

- name: Retrieve Latest winget-pkgs PULL_REQUEST_TEMPLATE commit SHA from GitHub API
id: get-sha
Expand Down Expand Up @@ -1283,7 +1339,8 @@ jobs:
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.TGS_DOTNET_VERSION }}
dotnet-version: '${{ env.TGS_DOTNET_VERSION }}.0.x'
dotnet-quality: ${{ env.TGS_DOTNET_QUALITY }}

- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -1346,7 +1403,8 @@ jobs:
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.TGS_DOTNET_VERSION }}
dotnet-version: '${{ env.TGS_DOTNET_VERSION }}.0.x'
dotnet-quality: ${{ env.TGS_DOTNET_QUALITY }}

- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -1409,6 +1467,7 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: '${{ env.TGS_DOTNET_VERSION }}.0.x'
dotnet-quality: ${{ env.TGS_DOTNET_QUALITY }}

- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -1459,6 +1518,7 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: '${{ env.TGS_DOTNET_VERSION }}.0.x'
dotnet-quality: ${{ env.TGS_DOTNET_QUALITY }}

- name: Checkout
uses: actions/checkout@v3
Expand All @@ -1482,6 +1542,7 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: '${{ env.TGS_DOTNET_VERSION }}.0.x'
dotnet-quality: ${{ env.TGS_DOTNET_QUALITY }}

- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -1690,9 +1751,10 @@ jobs:
if: (!(cancelled() || failure()) && needs.deploy-tgs.result == 'success')
steps:
- name: Setup dotnet
uses: actions/setup-dotnet@v2
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.TGS_DOTNET_VERSION }}
dotnet-version: '${{ env.TGS_DOTNET_VERSION }}.0.x'
dotnet-quality: ${{ env.TGS_DOTNET_QUALITY }}

- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -1780,6 +1842,7 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: '${{ env.TGS_DOTNET_VERSION }}.0.x'
dotnet-quality: ${{ env.TGS_DOTNET_QUALITY }}

- name: Install winget
uses: Cyberboss/install-winget@v1
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ Exposing the builtin Kestrel server to the internet directly over HTTP is highly

System administrators will most likely have their own configuration plans, but here are some basic guides for beginners.

Once complete, test that your configuration worked by visiting your proxy site from a browser on a different computer. You should recieve a 401 Unauthorized response.
Once complete, test that your configuration worked by visiting your proxy site from a browser on a different computer. You should receive a 401 Unauthorized response.

_NOTE: Your reverse proxy setup may interfere with SSE (Server-Sent Events) which is used for real-time job updates. If you find this to be the case, please open an issue describing what you did to fix it as there may be a way for us to bypass the need for a workaround from our end._

Expand Down
2 changes: 1 addition & 1 deletion build/Version.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<TgsCommonLibraryVersion>7.0.0</TgsCommonLibraryVersion>
<TgsApiLibraryVersion>13.0.0</TgsApiLibraryVersion>
<TgsClientVersion>15.0.0</TgsClientVersion>
<TgsDmapiVersion>6.7.1</TgsDmapiVersion>
<TgsDmapiVersion>7.0.0</TgsDmapiVersion>
<TgsInteropVersion>5.7.0</TgsInteropVersion>
<TgsHostWatchdogVersion>1.4.0</TgsHostWatchdogVersion>
<TgsContainerScriptVersion>1.2.1</TgsContainerScriptVersion>
Expand Down
6 changes: 3 additions & 3 deletions docs/API.dox
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ If the provided credentials are valid and your user account is enabled you will
}
@endcode

If your account is disabled, you will recieve a 403 response.
If your account is disabled, you will receive a 403 response.

You may recognize the bearer value as a <a href="https://jwt.io">Json Web Token</a>. This is a secure representation of your identity to the server. It expires after a set period of time or until your password changes. It must be present for requests made to all other APIs. To do so add the following header to your other requests

- Authorization:Bearer `<your bearer token>`

Continue to use this token until you begin to recieve 401 responses from the API. Then repeat the process to get a new one if your credentials are still valid
Continue to use this token until you begin to receive 401 responses from the API. Then repeat the process to get a new one if your credentials are still valid

@subsection api_auth_o OAuth 2.0

Expand Down Expand Up @@ -467,7 +467,7 @@ I POST "/Config" @ref Tgstation.Server.Api.Models.ConfigurationFile => @ref Tgst

When creating a file, only @ref Tgstation.Server.Api.Models.ConfigurationFile.Path and @ref Tgstation.Server.Api.Models.ConfigurationFile.Content should be specified

If the file already exists, the @ref Tgstation.Server.Api.Models.ConfigurationFile.LastReadHash field must also be present with the last version recieved from the server for that file. If this does not match at the time of the request, 409 will be returned, indicating the file has changed since it was last viewed by the client.
If the file already exists, the @ref Tgstation.Server.Api.Models.ConfigurationFile.LastReadHash field must also be present with the last version received from the server for that file. If this does not match at the time of the request, 409 will be returned, indicating the file has changed since it was last viewed by the client.

To delete a file set @ref Tgstation.Server.Api.Models.ConfigurationFile.Content to null in the request.

Expand Down
26 changes: 18 additions & 8 deletions src/DMAPI/tgs.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// tgstation-server DMAPI

#define TGS_DMAPI_VERSION "6.7.1"
#define TGS_DMAPI_VERSION "7.0.0"

// All functions and datums outside this document are subject to change with any version and should not be relied on.

Expand Down Expand Up @@ -73,12 +73,12 @@
#define TGS_EVENT_REPO_MERGE_PULL_REQUEST 3
/// Before the repository makes a sychronize operation. Parameters: Absolute repostiory path.
#define TGS_EVENT_REPO_PRE_SYNCHRONIZE 4
/// Before a BYOND install operation begins. Parameters: [/datum/tgs_version] of the installing BYOND.
#define TGS_EVENT_BYOND_INSTALL_START 5
/// When a BYOND install operation fails. Parameters: Error message
#define TGS_EVENT_BYOND_INSTALL_FAIL 6
/// When the active BYOND version changes. Parameters: (Nullable) [/datum/tgs_version] of the current BYOND, [/datum/tgs_version] of the new BYOND.
#define TGS_EVENT_BYOND_ACTIVE_VERSION_CHANGE 7
/// Before a engine install operation begins. Parameters: Version string of the installing engine.
#define TGS_EVENT_ENGINE_INSTALL_START 5
/// When a engine install operation fails. Parameters: Error message
#define TGS_EVENT_ENGINE_INSTALL_FAIL 6
/// When the active engine version changes. Parameters: (Nullable) Version string of the current engine, version string of the new engine.
#define TGS_EVENT_ENGINE_ACTIVE_VERSION_CHANGE 7
/// When the compiler starts running. Parameters: Game directory path, origin commit SHA.
#define TGS_EVENT_COMPILE_START 8
/// When a compile is cancelled. No parameters.
Expand Down Expand Up @@ -108,7 +108,7 @@
// #define TGS_EVENT_DREAM_DAEMON_LAUNCH 22
/// After a single submodule update is performed. Parameters: Updated submodule name.
#define TGS_EVENT_REPO_SUBMODULE_UPDATE 23
/// After CodeModifications are applied, before DreamMaker is run. Parameters: Game directory path, origin commit sha, byond version.
/// After CodeModifications are applied, before DreamMaker is run. Parameters: Game directory path, origin commit sha, version string of the used engine.
#define TGS_EVENT_PRE_DREAM_MAKER 24
/// Whenever a deployment folder is deleted from disk. Parameters: Game directory path.
#define TGS_EVENT_DEPLOYMENT_CLEANUP 25
Expand All @@ -122,6 +122,7 @@
/// The watchdog will restart on reboot.
#define TGS_REBOOT_MODE_RESTART 2

// Note that security levels are currently meaningless in OpenDream
/// DreamDaemon Trusted security level.
#define TGS_SECURITY_TRUSTED 0
/// DreamDaemon Safe security level.
Expand All @@ -136,6 +137,11 @@
/// DreamDaemon invisible visibility level.
#define TGS_VISIBILITY_INVISIBLE 2

/// The Build Your Own Net Dream engine.
#define TGS_ENGINE_TYPE_BYOND 0
/// The OpenDream engine.
#define TGS_ENGINE_TYPE_OPENDREAM 1

//REQUIRED HOOKS

/**
Expand Down Expand Up @@ -449,6 +455,10 @@
/world/proc/TgsVersion()
return

/// Returns the running engine type
/world/proc/TgsEngine()
return

/// Returns the current [/datum/tgs_version] of the DMAPI being used if it was activated, null otherwise. This function may sleep if the call to [/world/proc/TgsNew] is sleeping!
/world/proc/TgsApiVersion()
return
Expand Down
7 changes: 7 additions & 0 deletions src/DMAPI/tgs/core/core.dm
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@
if(api)
return api.ApiVersion()

/world/TgsEngine()
#ifdef OPENDREAM
return TGS_ENGINE_TYPE_OPENDREAM
#else
return TGS_ENGINE_TYPE_BYOND
#endif

/world/TgsInstanceName()
var/datum/tgs_api/api = TGS_READ_GLOBAL(tgs)
if(api)
Expand Down
2 changes: 1 addition & 1 deletion src/DMAPI/tgs/v5/_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#define DMAPI5_TOPIC_REQUEST_LIMIT 65528
#define DMAPI5_TOPIC_RESPONSE_LIMIT 65529

#define DMAPI5_BRIDGE_COMMAND_PORT_UPDATE 0
#define DMAPI5_BRIDGE_COMMAND_STARTUP 1
#define DMAPI5_BRIDGE_COMMAND_PRIME 2
#define DMAPI5_BRIDGE_COMMAND_REBOOT 3
Expand All @@ -18,6 +17,7 @@

#define DMAPI5_PARAMETER_ACCESS_IDENTIFIER "accessIdentifier"
#define DMAPI5_PARAMETER_CUSTOM_COMMANDS "customCommands"
#define DMAPI5_PARAMETER_TOPIC_PORT "topicPort"

#define DMAPI5_CHUNK "chunk"
#define DMAPI5_CHUNK_PAYLOAD "payload"
Expand Down
9 changes: 8 additions & 1 deletion src/DMAPI/tgs/v5/api.dm
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

var/datum/tgs_version/api_version = ApiVersion()
version = null // we want this to be the TGS version, not the interop version
var/list/bridge_response = Bridge(DMAPI5_BRIDGE_COMMAND_STARTUP, list(DMAPI5_BRIDGE_PARAMETER_MINIMUM_SECURITY_LEVEL = minimum_required_security_level, DMAPI5_BRIDGE_PARAMETER_VERSION = api_version.raw_parameter, DMAPI5_PARAMETER_CUSTOM_COMMANDS = ListCustomCommands()))
var/list/bridge_response = Bridge(DMAPI5_BRIDGE_COMMAND_STARTUP, list(DMAPI5_BRIDGE_PARAMETER_MINIMUM_SECURITY_LEVEL = minimum_required_security_level, DMAPI5_BRIDGE_PARAMETER_VERSION = api_version.raw_parameter, DMAPI5_PARAMETER_CUSTOM_COMMANDS = ListCustomCommands(), DMAPI5_PARAMETER_TOPIC_PORT = GetTopicPort()))
if(!istype(bridge_response))
TGS_ERROR_LOG("Failed initial bridge request!")
return FALSE
Expand Down Expand Up @@ -106,6 +106,13 @@
initialized = TRUE
return TRUE

/datum/tgs_api/v5/proc/GetTopicPort()
#if defined(OPENDREAM) && defined(OPENDREAM_TOPIC_PORT_EXISTS)
return "[world.opendream_topic_port]"
#else
return null
#endif

/datum/tgs_api/v5/proc/RequireInitialBridgeResponse()
TGS_DEBUG_LOG("RequireInitialBridgeResponse()")
var/logged = FALSE
Expand Down
9 changes: 7 additions & 2 deletions src/DMAPI/tgs/v5/bridge.dm
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,16 @@
TGS_ERROR_LOG("Failed bridge request: [bridge_request]")
return

var/response_json = file2text(export_response["CONTENT"])
if(!response_json)
var/content = export_response["CONTENT"]
if(!content)
TGS_ERROR_LOG("Failed bridge request, missing content!")
return

var/response_json = file2text(content)
if(!response_json)
TGS_ERROR_LOG("Failed bridge request, failed to load content!")
return

var/list/bridge_response = json_decode(response_json)
if(!bridge_response)
TGS_ERROR_LOG("Failed bridge request, bad json: [response_json]")
Expand Down
Loading

0 comments on commit 9b7e0c5

Please sign in to comment.